MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
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 164 of file Timer.f90.

165  ! -- dummy
166  integer(I4B), intent(in) :: it
167  real(DP), intent(inout) :: t1
168  real(DP), intent(inout) :: ts
169  ! -- local
170  real(DP) :: dt
171  !
172  if (it == 0) then
173  call cpu_time(t1)
174  else
175  call cpu_time(dt)
176  ts = ts + dt - t1
177  end if
178  !
179  ! -- Return
180  return
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 38 of file Timer.f90.

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