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