forked from altMITgcm/MITgcm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tim.c
58 lines (55 loc) · 1.31 KB
/
tim.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
//BOP
// !ROUTINE: cloc
// !INTERFACE:
cloc( double *curtim )
*/
#ifdef TARGET_LINUX
#undef FORTRAN_MANGLE_TRAILING_UNDERSCORE
#else
#define FORTRAN_MANGLE_TRAILING_UNDERSCORE
#endif
#define TIM_USES_GETTIMEOFDAY
#ifdef FORTRAN_MANGLE_TRAILING_UNDERSCORE
#define procedure_cloc cloc_
#else
#define procedure_cloc cloc
#endif
/*
// !DESCRIPTION:
// *======================================================*
// | cloc( double* timeinsec)
// *======================================================*
// | Call system time routines and return elapsed time
// | in seconds as a 64-bit float.
// *======================================================*
//EOP
*/
#ifdef TIM_USES_OSF_GETCLOCK
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <sys/time.h>
void procedure_cloc ( double *curtim )
{
struct timespec tv1;
getclock(TIMEOFDAY, &tv1);
*curtim = (double)((tv1.tv_nsec)+(tv1.tv_sec)*1.E9);
*curtim = *curtim/1E9;
}
#endif
#ifdef TIM_USES_GETTIMEOFDAY
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <sys/time.h>
void procedure_cloc ( double *curtim )
{
struct timeval tv1;
gettimeofday(&tv1 , (void *)NULL );
*curtim = (double)((tv1.tv_usec)+(tv1.tv_sec)*1.E6);
*curtim = *curtim/1.E6;
}
#endif