SURFEX v8.1
General documentation of Surfex
cptime.F90
Go to the documentation of this file.
1 !RJ: make interfaceable; generalization
2 SUBROUTINE cptime(PVCP,PTCP)
3 USE parkind1, ONLY : jprd, jpim
4 IMPLICIT NONE
5 REAL(KIND=JPRD) :: PVCP
6 REAL(KIND=JPRD) :: PTCP
7 !
8 #if defined (NEWTIMER)
9 ! this routine should work better with OpenMP
10 ! But doesn't work on Cray - and in any case does not return
11 ! CPU time for all threads combined
12 INTEGER(KIND=JPIM),SAVE :: IFIRST=1
13 INTEGER(KIND=JPIM),SAVE :: KFIRST,KTPS
14 INTEGER(KIND=JPIM) :: KTICK
15 ! Usage of Fortran95 intrinsic function system_clock for ELAPSED time,
16 ! thus taking into account the parallelism if inside an open-mp region. REK
17 IF(ifirst.EQ.1) THEN
18  ifirst=0
19  CALL system_clock(kfirst,ktps)
20  pvcp=0.0_jprd
21  ptcp=pvcp
22 ELSE
23  CALL system_clock(ktick)
24  pvcp=REAL(ktick-kfirst,kind=jprd)/REAL(ktps,kind=jprd)
25  ptcp=pvcp
26 ENDIF
27 #else
28 INTEGER(KIND=JPIM),SAVE :: ifirst=0
29 REAL(KIND=JPRD),SAVE :: ZFIRST
30 REAL(KIND=JPRD) :: ZSEC
31 ! Usage of Fortran95 intrinsic function for CPU timing.
32 IF(ifirst.EQ.0) THEN
33  ifirst=1
34  CALL cpu_time(zfirst)
35  pvcp=0.0_jprd
36  ptcp=pvcp
37 ELSE
38  CALL cpu_time(zsec)
39  pvcp=zsec-zfirst
40  ptcp=pvcp
41 ENDIF
42 #endif
43 !
44 RETURN
45 END SUBROUTINE cptime
integer, parameter jpim
Definition: parkind1.F90:13
integer, parameter jprd
Definition: parkind1.F90:39
subroutine cptime(PVCP, PTCP)
Definition: cptime.F90:3