65 INTEGER :: count_rate,count_max
67 INTEGER :: count_current, count_last
117 TYPE(
watch) :: MYWATCH
119 mywatch%COUNT_RATE = 0
120 mywatch%COUNT_MAX = 0
121 mywatch%COUNT_CURRENT = 0
122 mywatch%COUNT_LAST = 0
124 mywatch%Lap_Count = 0
126 CALL system_clock (mywatch%COUNT_CURRENT, mywatch%COUNT_RATE, mywatch%COUNT_MAX)
128 mywatch%COUNT_0 = mywatch%COUNT_CURRENT
129 mywatch%COUNT_LAST = mywatch%COUNT_CURRENT
132 & (
"MOD_CLOCK: FORTRAN DOES NOT RECOGNIZE YOUR SYSTEM CLOCK!",&
133 &
"INTIRINISIC, SYSTEM_CLOCK returned COUNT_MAX==0")
136 & (
"MOD_CLOCK: FORTRAN DOES NOT RECOGNIZE YOUR SYSTEM CLOCK!",&
137 & .LE.
"INTIRINISIC, SYSTEM_CLOCK returned COUNT_RATE 0")
140 & (
"MOD_CLOCK: FORTRAN DOES NOT RECOGNIZE YOUR SYSTEM CLOCK!",&
141 & .LT.
"INTIRINISIC, SYSTEM_CLOCK returned COUNT 0")
150 TYPE(
watch) :: mywatch
152 INTEGER(ITIME) :: big_count
155 CALL system_clock(count=my_count)
156 big_count = my_count - mywatch%COUNT_0
157 IF (big_count < 0) big_count = big_count + mywatch%COUNT_MAX
159 watch_time = dble(big_count) / dble(mywatch%COUNT_RATE)
168 TYPE(
watch) :: MYWATCH
170 CALL system_clock(mywatch%COUNT_CURRENT)
171 mywatch%LAP_Count = 0
172 mywatch%Count_LAST = mywatch%COUNT_CURRENT
173 mywatch%Count_0 = mywatch%COUNT_CURRENT
182 TYPE(
watch) :: MYWATCH
184 mywatch%COUNT_LAST = mywatch%COUNT_CURRENT
185 CALL system_clock(mywatch%COUNT_CURRENT)
186 mywatch%LAP_Count = mywatch%LAP_Count + 1
195 TYPE(
watch) :: MYWATCH
197 CALL system_clock(mywatch%COUNT_CURRENT)
199 mywatch%Count_0 =mywatch%Count_0 + (mywatch%COUNT_CURRENT - mywatch%COUNT_LAST)
208 TYPE(
watch) :: MYWATCH
210 CALL system_clock(mywatch%COUNT_CURRENT)
211 mywatch%COUNT_LAST = mywatch%COUNT_CURRENT
212 mywatch%LAP_Count = mywatch%LAP_Count + 1
222 TYPE(
watch) :: MYWATCH
223 integer,
intent(in) :: unit
224 Character(len=*),
intent(in) :: MSG
225 INTEGER(ITIME) :: BIG_COUNT
226 Character(len=16) :: lcnt,ltime
229 write(lcnt,
'(I8.8)')mywatch%LAP_COUNT
231 big_count = mywatch%COUNT_CURRENT - mywatch%COUNT_0
232 IF (big_count < 0) big_count = big_count + mywatch%COUNT_MAX
234 avg_time = dble(big_count) / dble(mywatch%COUNT_RATE * mywatch%LAP_COUNT)
236 write(ltime,
'(F16.6)') avg_time
238 write(unit,*)
"! === "//trim(msg)//
" ===" 239 write(unit,*)
"! Average Lap Time(seconds):"//trim(adjustl(ltime))//
"; & 240 &Lap Count:"//trim(adjustl(lcnt))
241 write(unit,*)
"! ===============================" 252 TYPE(
watch) :: MYWATCH
253 integer,
intent(in) :: unit
254 Character(len=*),
intent(in) :: MSG
255 INTEGER(ITIME) :: BIG_COUNT
257 Character(len=16) :: ltime
261 big_count = mywatch%COUNT_CURRENT - mywatch%COUNT_LAST
262 IF (big_count < 0) big_count = big_count + mywatch%COUNT_MAX
264 lap_time = dble(big_count) / dble(mywatch%COUNT_RATE)
266 write(ltime,
'(F16.6)') lap_time
268 write(unit,*)
"! === "//trim(msg)//
" ===" 269 write(unit,*)
"! Last Lap Time(seconds):"//trim(adjustl(ltime))
270 write(unit,*)
"! ===============================" 278 SUBROUTINE gettime(INSTRING,INSECS)
281 INTEGER,
INTENT(IN) :: INSECS
282 CHARACTER(LEN=13),
INTENT(INOUT) :: INSTRING
283 CHARACTER(LEN=4) :: S0
284 CHARACTER(LEN=2) :: S1,S2,S3
285 INTEGER :: DTCP,HTCP,MTCP,STCP
287 dtcp = insecs/(3600*24)
288 htcp =
mod(insecs,(3600*24))/3600
289 mtcp =
mod(insecs,(3600))/60
290 stcp = insecs - (dtcp*3600*24 + htcp*3600 + mtcp*60)
292 IF(dtcp >= 10000 )
then 294 instring =
"> 10000 DAYS" 297 else if (dtcp < 0)
THEN 299 instring =
" < 0 DAYS?" 304 WRITE(s0,
"(I4.4)")int(dtcp)
308 WRITE(s1,
"(I2.2)")int(htcp)
310 WRITE(s2,
"(I2.2)")int(mtcp)
312 WRITE(s3,
"(I2.2)")int(stcp)
315 instring = s0//
":"//s1//
":"//s2//
":"//s3
326 CALL date_and_time ( date=d,
time=t )
327 ts = d(7:8)//
'/'//d(5:6)//
'/'//d(1:4)//
' '//t(1:2)//
':'//t(3:4)
336 INTEGER(itime),
INTENT(IN) :: IINT,ISTART,IEND
337 Type(
time),
INTENT(IN) :: STIME
338 REAL(SP) :: TTCP,TAVE
339 CHARACTER(LEN=80) :: SIMTIME,FINTIME
340 CHARACTER(LEN=22) :: PCOMP
341 INTEGER :: I,ICMP,ICMP2
342 INTEGER(ITIME) :: BIG_COUNT
343 LOGICAL,
SAVE :: INITIALIZED
345 real(DP):: tmp, seconds
346 integer :: hours, minutes
347 Character(len=2) :: h, m
348 Character(Len=9) :: s
349 Character(Len=6) :: d
351 IF(.not. initialized)
THEN 368 IF (big_count < 0) big_count = big_count +
report_watch%COUNT_MAX
372 IF(tave < 0) tave = 0.0_sp
377 ttcp = tave*(iend-iint)
379 CALL gettime(fintime,int(ttcp))
387 icmp = int( 100.*float(iint-istart+1)/float(iend-istart+1))
405 IF(
mod(iint-1,10_dp) ==0)
THEN 408 WRITE(
ipt,101)iint,simtime,fintime,tave,pcomp
412 tmp = real(stime%MuSOD,dp) / real(
million,dp)
415 minutes = (tmp-hours*3600)/60
416 seconds =
mod(tmp,60.0_dp)
418 write(d,
'(i6.6)') stime%mjd
419 write(h,
'(i2.2)') hours
420 write(m,
'(i2.2)') minutes
421 write(s,
'(F9.6)') seconds
423 simtime =
"D"//d//
"T"//h//
":"//m//
":"//s
424 IF(
mod(iint-1,10_dp) ==0)
THEN 428 WRITE(
ipt,101)iint,simtime,fintime,tave,pcomp
432 101
FORMAT(1x,
"!",i7,3x,a26,3x,a13,3x,f8.4,2x,a22)
433 102
FORMAT(1x,
"! IINT ",6x,
" SIMTIME(UTC) ",9x,
" FINISH IN ",5x,
" SECS/IT ",1x,
" PERCENT COMPLETE ")
434 103
FORMAT(1x,
"! IINT ",6x,
" SIMTIME ",14x,
" FINISH IN ",5x,
" SECS/IT ",1x,
" PERCENT COMPLETE ")
subroutine get_timestamp(TS)
subroutine watch_init(MYWATCH)
subroutine report_time(IINT, ISTART, IEND, STIME)
real(dp) function watch_time(MYWATCH)
subroutine watch_lap_noprint(MYWATCH)
subroutine watch_reset(MYWATCH)
subroutine watch_report(MYWATCH, UNIT, MSG)
logical use_real_world_time
subroutine fatal_error(ER1, ER2, ER3, ER4)
subroutine watch_start_lap(MYWATCH)
subroutine gettime(INSTRING, INSECS)
subroutine watch_lap_print(MYWATCH, UNIT, MSG)
integer(itime), parameter million
subroutine watch_stop_lap(MYWATCH)
character(len=80) function write_datetime(mjdin, prec, TZONE)