MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
timermodule Module Reference

Functions/Subroutines

subroutine, public print_start_time ()
 Start simulation timer. More...
 
subroutine, public elapsed_time (iout, iprtim)
 Get end time and calculate elapsed time. More...
 
subroutine, public code_timer (it, t1, ts)
 Get end time and calculate elapsed time. More...
 

Variables

integer(i4b), dimension(8) ibdt
 

Function/Subroutine Documentation

◆ code_timer()

subroutine, public timermodule::code_timer ( integer(i4b), intent(in)  it,
real(dp), intent(inout)  t1,
real(dp), intent(inout)  ts 
)

Timer for subroutines

Definition at line 158 of file Timer.f90.

159  ! -- dummy
160  integer(I4B), intent(in) :: it
161  real(DP), intent(inout) :: t1
162  real(DP), intent(inout) :: ts
163  ! -- local
164  real(DP) :: dt
165  !
166  if (it == 0) then
167  call cpu_time(t1)
168  else
169  call cpu_time(dt)
170  ts = ts + dt - t1
171  end if
Here is the caller graph for this function:

◆ elapsed_time()

subroutine, public timermodule::elapsed_time ( integer(i4b), intent(in)  iout,
integer(i4b), intent(in)  iprtim 
)

Definition at line 35 of file Timer.f90.

36  ! -- dummy
37  integer(I4B), intent(in) :: iout
38  integer(I4B), intent(in) :: iprtim
39  ! -- local
40  character(len=LINELENGTH) :: line
41  integer(I4B) :: IEDT(8), IDPM(12)
42  integer(I4B) :: NSPD
43  integer(I4B) :: i
44  integer(I4B) :: ndays, leap, ibd, ied, mb, me, nm, mc, m
45  integer(I4B) :: nhours, nmins, nsecs, msecs, nrsecs
46  real(DP) :: elsec, rsecs
47  data idpm/31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31/ !< Days per month
48  data nspd/86400/ !< Seconds per day
49  ! -- formats
50  character(len=*), parameter :: fmtdt = &
51  "(1x,'Run end date and time (yyyy/mm/dd hh:mm:ss): ', &
52  &I4,'/',I2.2,'/',I2.2,1x,I2,':',I2.2,':',I2.2)"
53  character(len=*), parameter :: fmttma = &
54  "(1x,'Elapsed run time: ',I3,' Days, ',I2,' Hours, ',I2, &
55  &' Minutes, ', I2, ' Seconds')"
56  character(len=*), parameter :: fmttmb = &
57  &"(1x,'Elapsed run time: ',I2,' Hours, ',I2,' Minutes, ',I2,' Seconds')"
58  character(len=*), parameter :: fmttmc = &
59  &"(1x,'Elapsed run time: ',I2,' Minutes, ',I2,'.',I3.3,' Seconds')"
60  character(len=*), parameter :: fmttmd = &
61  &"(1x,'Elapsed run time: ',I2,'.',I3.3,' Seconds')"
62  !
63  ! -- Get current date and time, assign to IEDT, and write.
64  call date_and_time(values=iedt)
65  !
66  ! -- Write elapsed time to stdout
67  write (line, fmtdt) (iedt(i), i=1, 3), (iedt(i), i=5, 7)
68  call write_message(line, skipbefore=1)
69  !
70  ! -- Write elapsted time to iout
71  if (iprtim > 0) then
72  call write_message(line, iunit=iout, skipbefore=1)
73  end if
74  !
75  ! -- Calculate elapsed time in days and seconds
76  ndays = 0
77  leap = 0
78  if (mod(iedt(1), 4) == 0) leap = 1
79  ibd = ibdt(3) !< Begin Day
80  ied = iedt(3) !< End Day
81  !
82  ! -- Find days
83  if (ibdt(2) /= iedt(2)) then
84  ! -- Months differ
85  mb = ibdt(2) !< Begin month
86  me = iedt(2) !< End month
87  nm = me - mb + 1 !< Number of months to look at
88  if (mb > me) nm = nm + 12
89  mc = mb - 1
90  do m = 1, nm
91  mc = mc + 1 !< mc is current month
92  if (mc == 13) mc = 1
93  if (mc == mb) then
94  ndays = ndays + idpm(mc) - ibd
95  if (mc == 2) ndays = ndays + leap
96  elseif (mc == me) then
97  ndays = ndays + ied
98  else
99  ndays = ndays + idpm(mc)
100  if (mc == 2) ndays = ndays + leap
101  end if
102  end do
103  elseif (ibd < ied) then
104  ! -- Start and end in same month, only account for days
105  ndays = ied - ibd
106  end if
107  elsec = ndays * nspd
108  !
109  ! -- Add or subtract seconds
110  elsec = elsec + (iedt(5) - ibdt(5)) * 3600.0
111  elsec = elsec + (iedt(6) - ibdt(6)) * 60.0
112  elsec = elsec + (iedt(7) - ibdt(7))
113  elsec = elsec + (iedt(8) - ibdt(8)) * 0.001
114  !
115  ! -- Convert seconds to days, hours, minutes, and seconds
116  ndays = int(elsec / nspd)
117  rsecs = mod(elsec, dsecperdy)
118  nhours = int(rsecs / 3600.0)
119  rsecs = mod(rsecs, dsecperhr)
120  nmins = int(rsecs / 60.0)
121  rsecs = mod(rsecs, dsixty)
122  nsecs = int(rsecs)
123  rsecs = mod(rsecs, done)
124  msecs = nint(rsecs * 1000.0)
125  nrsecs = nsecs
126  if (rsecs > 0.5) nrsecs = nrsecs + 1
127  !
128  ! -- Write elapsed time to screen
129  if (ndays > 0) then
130  write (line, fmttma) ndays, nhours, nmins, nrsecs
131  elseif (nhours > 0) then
132  write (line, fmttmb) nhours, nmins, nrsecs
133  elseif (nmins > 0) then
134  write (line, fmttmc) nmins, nsecs, msecs
135  else
136  write (line, fmttmd) nsecs, msecs
137  end if
138  call write_message(line, skipafter=1)
139  !
140  ! -- Write times to file if requested
141  if (iprtim > 0) then
142  IF (ndays > 0) THEN
143  WRITE (iout, fmttma) ndays, nhours, nmins, nrsecs
144  ELSEIF (nhours > 0) THEN
145  WRITE (iout, fmttmb) nhours, nmins, nrsecs
146  ELSEIF (nmins > 0) THEN
147  WRITE (iout, fmttmc) nmins, nsecs, msecs
148  ELSE
149  WRITE (iout, fmttmd) nsecs, msecs
150  END IF
151  END IF
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_start_time()

subroutine, public timermodule::print_start_time

Definition at line 18 of file Timer.f90.

19  ! -- local
20  character(len=LINELENGTH) :: line
21  integer(I4B) :: i
22  ! -- formats
23  character(len=*), parameter :: fmtdt = &
24  "(1X,'Run start date and time (yyyy/mm/dd hh:mm:ss): ', &
25  &I4,'/',I2.2,'/',I2.2,1X,I2,':',I2.2,':',I2.2)"
26  !
27  ! -- Get current date and time, assign to IBDT, and write to screen
28  call date_and_time(values=ibdt)
29  write (line, fmtdt) (ibdt(i), i=1, 3), (ibdt(i), i=5, 7)
30  call write_message(line, skipafter=1)
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ibdt

integer(i4b), dimension(8) timermodule::ibdt
private

Definition at line 12 of file Timer.f90.

12  integer(I4B), dimension(8) :: ibdt