fortran interface implementation for common trace functions.
[charm.git] / src / ck-perf / tracef.C
1 /****************************************************************************
2              Fortran API for common Trace functions
3 ****************************************************************************/
4
5 #include<charm++.h>
6 #include<charm-api.h>
7                                                                                 
8 CpvDeclare(int, a);
9                                                                                 
10 static int isInitialized=0;
11                                                                                 
12 void checkInit(void) {
13         if (isInitialized) return;
14         isInitialized=1;
15         CpvInitialize(int,a);
16         CpvAccess(a)=0;
17 }
18
19 FDECL {
20 void FTN_NAME(FTRACEBEGIN, ftracebegin)()
21 {
22           checkInit();
23           if ( CpvAccess(a) ==0)
24                 {
25                         traceBegin();
26                         CpvAccess(a)++;
27                 }
28           else
29                 { CpvAccess(a)++;}
30 }
31
32 void FTN_NAME(FTRACEEND, ftraceend)()
33 {
34           checkInit();
35           if ( CpvAccess(a) == 1)
36                 {
37                         traceEnd();
38                         CpvAccess(a)--;
39                 }
40           else
41                 { CpvAccess(a)--;}
42                                                                                 
43 }
44
45 void FTN_NAME(FTRACEREGISTERUSEREVENT, ftraceregisteruserevent)(char *x, int *ein, int *eout, int len)
46 {
47   char *newstr = new char[len + 1];
48   _MEMCHECK(newstr);
49   strncpy(newstr, x, len);
50   newstr[len] = 0;
51   int newe = traceRegisterUserEvent(newstr, *ein);
52   *eout = newe;
53 }
54
55 void FTN_NAME(FTRACEUSERBRACKETEVENT, ftraceuserbracketevent)(int *e, double *begint, double *endt)
56 {
57   traceUserBracketEvent(*e, *begint, *endt);
58 }
59
60 void FTN_NAME(FCMIWALLTIMER, fcmiwalltimer)(double *t)
61 {
62   *t = CmiWallTimer();
63 }
64
65 }  // FDECL
66