Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:36:14 UTC

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
379dd6c9e4 Jean*0001 /*
                0002  */
3c4b42f3fc Patr*0003 #include <sys/types.h>
                0004 #include <sys/times.h>
                0005 #include <sys/time.h>
07e713c9a1 Cons*0006 #include <unistd.h>
                0007 /*  Here, we get the definition of the FC_NAMEMANGLE() macro. */
                0008 #include "FC_NAMEMANGLE.h"
3c4b42f3fc Patr*0009 
07e713c9a1 Cons*0010    static long clktck = 0;
                0011    static double invclktck = 0.0;
3c4b42f3fc Patr*0012 
0584962966 Chri*0013    double FC_NAMEMANGLE(cusertime) (void);
                0014    double FC_NAMEMANGLE(csystemtime) (void);
07e713c9a1 Cons*0015    double FC_NAMEMANGLE(timenow) ();
                0016    void init_timer();
                0017 
                0018   void init_timer()
                0019    {
                0020      clktck = sysconf(_SC_CLK_TCK);
                0021      invclktck = 1.0/clktck;
                0022      return;
                0023    }
                0024 
0584962966 Chri*0025   double FC_NAMEMANGLE(cusertime) (void)
3c4b42f3fc Patr*0026    {
                0027      clock_t blabla;
                0028      struct tms timest;
07e713c9a1 Cons*0029 /* This is useless overhead but we'd need to call init_timer() elsewhere */ 
                0030      if (clktck == 0) init_timer();
                0031  
3c4b42f3fc Patr*0032      blabla = times(&timest);
07e713c9a1 Cons*0033      return invclktck*timest.tms_utime;
3c4b42f3fc Patr*0034   
                0035    }
                0036 
0584962966 Chri*0037   double FC_NAMEMANGLE(csystemtime) (void)
3c4b42f3fc Patr*0038    {
                0039      clock_t blabla;
                0040      struct tms timest;
07e713c9a1 Cons*0041 /* This is useless overhead but we'd need to call init_timer() elsewhere */
                0042      if (clktck == 0) init_timer();
3c4b42f3fc Patr*0043      
                0044      blabla = times(&timest);
07e713c9a1 Cons*0045      return invclktck*timest.tms_stime;
3c4b42f3fc Patr*0046   
                0047    }
                0048 
                0049 
                0050 
07e713c9a1 Cons*0051  double FC_NAMEMANGLE(timenow) (void)
3c4b42f3fc Patr*0052   {
                0053 struct timeval timestr;
                0054    void *Tzp=0;
                0055  gettimeofday(&timestr, Tzp);
                0056 
                0057   return (double)timestr.tv_sec+1.0E-06*(double)timestr.tv_usec;
                0058  }
                0059