NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
instrument.f
Go to the documentation of this file.
1
4
46 SUBROUTINE instrument(K,KALL,TTOT,TMIN,TMAX)
47 IMPLICIT NONE
48 INTEGER,INTENT(IN):: K
49 INTEGER,INTENT(OUT):: KALL
50 REAL,INTENT(OUT):: TTOT,TMIN,TMAX
51 INTEGER,SAVE:: KMAX=0
52 INTEGER,DIMENSION(:),ALLOCATABLE,SAVE:: KALLS
53 REAL,DIMENSION(:),ALLOCATABLE,SAVE:: TTOTS,TMINS,TMAXS
54 INTEGER,DIMENSION(8),SAVE:: IDAT
55 INTEGER,DIMENSION(8):: JDAT
56 REAL,DIMENSION(5):: RINC
57 INTEGER:: KA
58! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59 ka=abs(k)
60! ALLOCATE MONITORING ARRAYS IF INITIAL INVOCATION
61 IF(kmax.EQ.0) THEN
62 kmax=k
63 ALLOCATE(kalls(kmax))
64 ALLOCATE(ttots(kmax))
65 ALLOCATE(tmins(kmax))
66 ALLOCATE(tmaxs(kmax))
67 kalls=0
68 ka=0
69! OR RESET ALL STATISTICS BACK TO ZERO
70 ELSEIF(k.EQ.0) THEN
71 kalls=0
72! OR COUNT TIME SINCE LAST INVOCATION AGAINST THIS SECTION
73 ELSEIF(k.GT.0) THEN
74 CALL w3utcdat(jdat)
75 CALL w3difdat(jdat,idat,4,rinc)
76 kalls(k)=kalls(k)+1
77 IF(kalls(k).EQ.1) THEN
78 ttots(k)=rinc(4)
79 tmins(k)=rinc(4)
80 tmaxs(k)=rinc(4)
81 ELSE
82 ttots(k)=ttots(k)+rinc(4)
83 tmins(k)=min(tmins(k),rinc(4))
84 tmaxs(k)=max(tmaxs(k),rinc(4))
85 ENDIF
86 ENDIF
87! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
88! RETURN STATISTICS
89
90! FRIMEL and KALINA, DECOMPOSE THE IF STATEMENT, SAFER FOR SOME
91! COMPILERS. Since No Guarantee on order of evaluation, and when
92! evaluation will stop.
93! MAKE SURE KA.GE.1 BEFORE TESTING IF KALLS(KA).GT.0, ELSE
94! MAY ENCOUNTER A RUNTIME SIGSEGV SEGEMENTATION FAULT.
95! Since Subscript #1 of the array KALLS can have value 0 which
96! is less than the lower bound of 1
97! IF(KA.GE.1.AND.KA.LE.KMAX.AND.KALLS(KA).GT.0) THEN
98
99 IF(ka.GE.1.AND.ka.LE.kmax) THEN
100 IF(kalls(ka).GT.0) THEN
101 kall=kalls(ka)
102 ttot=ttots(ka)
103 tmin=tmins(ka)
104 tmax=tmaxs(ka)
105 ENDIF
106 IF(kalls(ka).LE.0) THEN
107 kall=0
108 ttot=0
109 tmin=0
110 tmax=0
111 ENDIF
112 END IF
113! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
114! KEEP CURRENT TIME FOR NEXT INVOCATION
115 IF(k.GE.0) CALL w3utcdat(idat)
116 END SUBROUTINE instrument
subroutine instrument(k, kall, ttot, tmin, tmax)
This subprogram is useful in instrumenting a code by monitoring the number of times each given sectio...
Definition instrument.f:47
subroutine w3difdat(jdat, idat, it, rinc)
Returns the elapsed time interval from an NCEP absolute date and time given in the second argument un...
Definition w3difdat.f:29
subroutine w3utcdat(idat)
This subprogram returns the utc (greenwich) date and time in the NCEP absolute date and time data str...
Definition w3utcdat.f:23