fortran interface implementation for common trace functions.
authorGengbin Zheng <gzheng@illinois.edu>
Thu, 19 Feb 2004 23:40:02 +0000 (23:40 +0000)
committerGengbin Zheng <gzheng@illinois.edu>
Thu, 19 Feb 2004 23:40:02 +0000 (23:40 +0000)
src/ck-perf/tracef.C [new file with mode: 0644]

diff --git a/src/ck-perf/tracef.C b/src/ck-perf/tracef.C
new file mode 100644 (file)
index 0000000..02b1fda
--- /dev/null
@@ -0,0 +1,66 @@
+/****************************************************************************
+             Fortran API for common Trace functions
+****************************************************************************/
+
+#include<charm++.h>
+#include<charm-api.h>
+                                                                                
+CpvDeclare(int, a);
+                                                                                
+static int isInitialized=0;
+                                                                                
+void checkInit(void) {
+        if (isInitialized) return;
+        isInitialized=1;
+        CpvInitialize(int,a);
+        CpvAccess(a)=0;
+}
+
+FDECL {
+void FTN_NAME(FTRACEBEGIN, ftracebegin)()
+{
+          checkInit();
+          if ( CpvAccess(a) ==0)
+                {
+                        traceBegin();
+                        CpvAccess(a)++;
+                }
+          else
+                { CpvAccess(a)++;}
+}
+
+void FTN_NAME(FTRACEEND, ftraceend)()
+{
+          checkInit();
+          if ( CpvAccess(a) == 1)
+                {
+                        traceEnd();
+                        CpvAccess(a)--;
+                }
+          else
+                { CpvAccess(a)--;}
+                                                                                
+}
+
+void FTN_NAME(FTRACEREGISTERUSEREVENT, ftraceregisteruserevent)(char *x, int *ein, int *eout, int len)
+{
+  char *newstr = new char[len + 1];
+  _MEMCHECK(newstr);
+  strncpy(newstr, x, len);
+  newstr[len] = 0;
+  int newe = traceRegisterUserEvent(newstr, *ein);
+  *eout = newe;
+}
+
+void FTN_NAME(FTRACEUSERBRACKETEVENT, ftraceuserbracketevent)(int *e, double *begint, double *endt)
+{
+  traceUserBracketEvent(*e, *begint, *endt);
+}
+
+void FTN_NAME(FCMIWALLTIMER, fcmiwalltimer)(double *t)
+{
+  *t = CmiWallTimer();
+}
+
+}  // FDECL
+