My Project
Data Types | Functions/Subroutines | Variables
mod_clock Module Reference

Data Types

type  watch
 
interface  watch_lap
 

Functions/Subroutines

subroutine watch_init (MYWATCH)
 
real(dp) function watch_time (MYWATCH)
 
subroutine watch_reset (MYWATCH)
 
subroutine watch_lap_noprint (MYWATCH)
 
subroutine watch_start_lap (MYWATCH)
 
subroutine watch_stop_lap (MYWATCH)
 
subroutine watch_report (MYWATCH, UNIT, MSG)
 
subroutine watch_lap_print (MYWATCH, UNIT, MSG)
 
subroutine gettime (INSTRING, INSECS)
 
subroutine get_timestamp (TS)
 
subroutine report_time (IINT, ISTART, IEND, STIME)
 

Variables

type(watchreport_watch
 

Function/Subroutine Documentation

◆ get_timestamp()

subroutine mod_clock::get_timestamp ( character(len=*)  TS)

Definition at line 322 of file mod_clock.f90.

322  CHARACTER(LEN=*) TS
323  CHARACTER(LEN=8) D
324  CHARACTER(LEN=10) T
325 
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)
real(sp), dimension(:), allocatable, target d
Definition: mod_main.f90:1132
real(sp), dimension(:,:), allocatable, target t
Definition: mod_main.f90:1286
Here is the caller graph for this function:

◆ gettime()

subroutine mod_clock::gettime ( character(len=13), intent(inout)  INSTRING,
integer, intent(in)  INSECS 
)

Definition at line 279 of file mod_clock.f90.

279 
280  IMPLICIT NONE
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
286 
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)
291 
292  IF(dtcp >= 10000 ) then
293 
294  instring = "> 10000 DAYS"
295  return
296 
297  else if (dtcp < 0) THEN
298 
299  instring = " < 0 DAYS?"
300  return
301 
302  else
303 
304  WRITE(s0,"(I4.4)")int(dtcp)
305 
306  END IF
307 
308  WRITE(s1,"(I2.2)")int(htcp)
309 
310  WRITE(s2,"(I2.2)")int(mtcp)
311 
312  WRITE(s3,"(I2.2)")int(stcp)
313 
314 
315  instring = s0//":"//s1//":"//s2//":"//s3
316 
real(sp), dimension(:,:), allocatable, target s1
Definition: mod_main.f90:1308
real(sp), dimension(:,:), allocatable, target s2
Definition: mod_main.f90:1316
real(sp), dimension(:,:), allocatable, target s0
Definition: mod_main.f90:1315
Here is the caller graph for this function:

◆ report_time()

subroutine mod_clock::report_time ( integer(itime), intent(in)  IINT,
integer(itime), intent(in)  ISTART,
integer(itime), intent(in)  IEND,
type(time), intent(in)  STIME 
)

Definition at line 334 of file mod_clock.f90.

334 
335  IMPLICIT NONE
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
344 
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
350 
351  IF(.not. initialized) THEN
352  CALL watch_init(report_watch)
353 
354  tave = -1.0_sp
355  fintime = " UNKNOWN"
356  initialized = .true.
357 
358  ELSE
359  !
360  ! CALCULATE CURRENT TIME
361  !
362  CALL watch_lap(report_watch)
363 
364  !
365  ! CALCULATE AVERAGE TIME/ITERATION
366  !
367  big_count = report_watch%COUNT_CURRENT - report_watch%COUNT_0
368  IF (big_count < 0) big_count = big_count + report_watch%COUNT_MAX
369 
370  tave = dble(big_count) / dble(report_watch%COUNT_RATE * report_watch%LAP_COUNT)
371 
372  IF(tave < 0) tave = 0.0_sp
373 
374  !
375  ! CALCULATE TIME TO COMPLETION
376  !
377  ttcp = tave*(iend-iint)
378 
379  CALL gettime(fintime,int(ttcp))
380 
381  END IF
382 
383 !
384 ! CALCULATE COMPLETION PERCENTAGE GRAPHIC
385 !
386 ! IF(MOD(IINT,1) /= 0) RETURN
387  icmp = int( 100.*float(iint-istart+1)/float(iend-istart+1))
388  icmp2 = icmp/5
389  pcomp = " "
390  pcomp(1:1) = "|"
391  pcomp(22:22) = "|"
392 
393  DO i=2,icmp2+1
394  pcomp(i:i) = "="
395  END DO
396 
397  if (use_real_world_time) then
398  ! Get the date and time of the current iterationr
399  simtime = write_datetime(stime,6,"UTC")
400 
401 
402  !
403  ! REPORT
404  !
405  IF(mod(iint-1,10_dp) ==0) THEN
406  WRITE(ipt,102)
407  END IF
408  WRITE(ipt,101)iint,simtime,fintime,tave,pcomp
409 
410  else
411 
412  tmp = real(stime%MuSOD,dp) / real(million,dp)
413 
414  hours = tmp/3600
415  minutes = (tmp-hours*3600)/60
416  seconds = mod(tmp,60.0_dp)
417 
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
422 
423  simtime = "D"//d//"T"//h//":"//m//":"//s
424  IF(mod(iint-1,10_dp) ==0) THEN
425  WRITE(ipt,103)
426  END IF
427 
428  WRITE(ipt,101)iint,simtime,fintime,tave,pcomp
429  end if
430 
431  return
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 ")
435 
integer(itime) iend
Definition: mod_main.f90:853
real(sp), dimension(:), allocatable, target d
Definition: mod_main.f90:1132
real(sp), dimension(:,:), allocatable, target s
Definition: mod_main.f90:1288
real(sp), dimension(:), allocatable, target h
Definition: mod_main.f90:1131
integer m
Definition: mod_main.f90:56
integer(itime) istart
Definition: mod_main.f90:852
integer(itime) iint
Definition: mod_main.f90:850
logical use_real_world_time
Definition: mod_main.f90:131
real(dp) function seconds(MJD)
Definition: mod_time.f90:742
integer, parameter dp
Definition: mod_prec.f90:52
integer ipt
Definition: mod_main.f90:922
integer(itime), parameter million
Definition: mod_time.f90:160
character(len=80) function write_datetime(mjdin, prec, TZONE)
Definition: mod_time.f90:682
Here is the call graph for this function:
Here is the caller graph for this function:

◆ watch_init()

subroutine mod_clock::watch_init ( type(watch MYWATCH)

Definition at line 116 of file mod_clock.f90.

116  IMPLICIT NONE
117  TYPE(WATCH) :: MYWATCH
118 
119  mywatch%COUNT_RATE = 0
120  mywatch%COUNT_MAX = 0
121  mywatch%COUNT_CURRENT = 0
122  mywatch%COUNT_LAST = 0
123  mywatch%COUNT_0 = 0
124  mywatch%Lap_Count = 0
125 
126  CALL system_clock (mywatch%COUNT_CURRENT, mywatch%COUNT_RATE, mywatch%COUNT_MAX)
127 
128  mywatch%COUNT_0 = mywatch%COUNT_CURRENT
129  mywatch%COUNT_LAST = mywatch%COUNT_CURRENT
130 
131  IF(mywatch%COUNT_MAX == 0) CALL fatal_error &
132  & ("MOD_CLOCK: FORTRAN DOES NOT RECOGNIZE YOUR SYSTEM CLOCK!",&
133  & "INTIRINISIC, SYSTEM_CLOCK returned COUNT_MAX==0")
134 
135  IF(mywatch%COUNT_RATE .LE. 0) CALL fatal_error &
136  & ("MOD_CLOCK: FORTRAN DOES NOT RECOGNIZE YOUR SYSTEM CLOCK!",&
137  & .LE."INTIRINISIC, SYSTEM_CLOCK returned COUNT_RATE 0")
138 
139  IF(mywatch%COUNT_0 .LT. 0) CALL fatal_error &
140  & ("MOD_CLOCK: FORTRAN DOES NOT RECOGNIZE YOUR SYSTEM CLOCK!",&
141  & .LT."INTIRINISIC, SYSTEM_CLOCK returned COUNT 0")
142 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ watch_lap_noprint()

subroutine mod_clock::watch_lap_noprint ( type(watch MYWATCH)

Definition at line 181 of file mod_clock.f90.

181  IMPLICIT NONE
182  TYPE(WATCH) :: MYWATCH
183 
184  mywatch%COUNT_LAST = mywatch%COUNT_CURRENT
185  CALL system_clock(mywatch%COUNT_CURRENT)
186  mywatch%LAP_Count = mywatch%LAP_Count + 1
187 
Here is the caller graph for this function:

◆ watch_lap_print()

subroutine mod_clock::watch_lap_print ( type(watch MYWATCH,
integer, intent(in)  UNIT,
character(len=*), intent(in)  MSG 
)

Definition at line 249 of file mod_clock.f90.

249  IMPLICIT NONE
250 
251 
252  TYPE(WATCH) :: MYWATCH
253  integer, intent(in) :: unit
254  Character(len=*), intent(in) :: MSG
255  INTEGER(ITIME) :: BIG_COUNT
256  REAL(DP) :: LAP_TIME
257  Character(len=16) :: ltime
258 
259 
260  CALL watch_lap_noprint(mywatch)
261  big_count = mywatch%COUNT_CURRENT - mywatch%COUNT_LAST
262  IF (big_count < 0) big_count = big_count + mywatch%COUNT_MAX
263 
264  lap_time = dble(big_count) / dble(mywatch%COUNT_RATE)
265 
266  write(ltime,'(F16.6)') lap_time
267 
268  write(unit,*) "! === "//trim(msg)//" ==="
269  write(unit,*) "! Last Lap Time(seconds):"//trim(adjustl(ltime))
270  write(unit,*) "! ==============================="
271 
Here is the call graph for this function:

◆ watch_report()

subroutine mod_clock::watch_report ( type(watch MYWATCH,
integer, intent(in)  UNIT,
character(len=*), intent(in)  MSG 
)

Definition at line 219 of file mod_clock.f90.

219  IMPLICIT NONE
220 
221 
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
227  REAL(DP) :: AVG_TIME
228 
229  write(lcnt,'(I8.8)')mywatch%LAP_COUNT
230 
231  big_count = mywatch%COUNT_CURRENT - mywatch%COUNT_0
232  IF (big_count < 0) big_count = big_count + mywatch%COUNT_MAX
233 
234  avg_time = dble(big_count) / dble(mywatch%COUNT_RATE * mywatch%LAP_COUNT)
235 
236  write(ltime,'(F16.6)') avg_time
237 
238  write(unit,*) "! === "//trim(msg)//" ==="
239  write(unit,*) "! Average Lap Time(seconds):"//trim(adjustl(ltime))//"; &
240  &Lap Count:"//trim(adjustl(lcnt))
241  write(unit,*) "! ==============================="
242 
243 
Here is the caller graph for this function:

◆ watch_reset()

subroutine mod_clock::watch_reset ( type(watch MYWATCH)

Definition at line 167 of file mod_clock.f90.

167  IMPLICIT NONE
168  TYPE(WATCH) :: MYWATCH
169 
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
174 

◆ watch_start_lap()

subroutine mod_clock::watch_start_lap ( type(watch MYWATCH)

Definition at line 194 of file mod_clock.f90.

194  IMPLICIT NONE
195  TYPE(WATCH) :: MYWATCH
196 
197  CALL system_clock(mywatch%COUNT_CURRENT)
198  !IGNORE TIME SINCE LAST STOP
199  mywatch%Count_0 =mywatch%Count_0 + (mywatch%COUNT_CURRENT - mywatch%COUNT_LAST)
200 
Here is the caller graph for this function:

◆ watch_stop_lap()

subroutine mod_clock::watch_stop_lap ( type(watch MYWATCH)

Definition at line 207 of file mod_clock.f90.

207  IMPLICIT NONE
208  TYPE(WATCH) :: MYWATCH
209 
210  CALL system_clock(mywatch%COUNT_CURRENT)
211  mywatch%COUNT_LAST = mywatch%COUNT_CURRENT
212  mywatch%LAP_Count = mywatch%LAP_Count + 1
213 
Here is the caller graph for this function:

◆ watch_time()

real(dp) function mod_clock::watch_time ( type(watch MYWATCH)

Definition at line 149 of file mod_clock.f90.

149  IMPLICIT NONE
150  TYPE(WATCH) :: MYWATCH
151  REAL(DP) :: WATCH_TIME
152  INTEGER(ITIME) :: BIG_COUNT
153  INTEGER :: MY_COUNT
154 
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
158 
159  watch_time = dble(big_count) / dble(mywatch%COUNT_RATE)
160 

Variable Documentation

◆ report_watch

type(watch) mod_clock::report_watch

Definition at line 71 of file mod_clock.f90.

71  TYPE(WATCH):: Report_watch