MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
printsavemanagermodule Module Reference

This module contains the PrintSaveManagerModule. More...

Data Types

type  printsavemanagertype
 @ brief PrintSaveManagerType More...
 

Functions/Subroutines

subroutine init (this)
 @ brief Initialize PrintSaveManager More...
 
subroutine rp (this, linein, iout)
 @ brief Read and prepare for PrintSaveManager More...
 
logical function kstp_to_print (this, kstp, endofperiod)
 @ brief Determine if it is time to print the data More...
 
logical function kstp_to_save (this, kstp, endofperiod)
 @ brief Determine if it is time to save the data More...
 

Detailed Description

This module defines the PrintSaveManagerType, which can be used to determine when something should be printed and/or saved. The object should be initiated with the following call: call psm_objinit()

The set method will configure the members based on the following keywords when set is called as follows: call psm_objset(nstp, line) where line may be in the following form: PRINT ALL PRINT STEPS 1 4 5 6 PRINT FIRST PRINT LAST PRINT FREQUENCY 4 SAVE ALL SAVE STEPS 1 4 5 6 SAVE FIRST SAVE LAST SAVE FREQUENCY 4

Based on the keywords, the object can be called with psm_objtime_to_print(kstp, kper) psm_objtime_to_save(kstp, kper) to return a logical flag indicating whether or not it it is time to print or time to save

Function/Subroutine Documentation

◆ init()

subroutine printsavemanagermodule::init ( class(printsavemanagertype this)
private

Initializes variables of a PrintSaveManagerType

Parameters
thispsm object to initialize

Definition at line 74 of file PrintSaveManager.f90.

75  ! -- dummy
76  class(PrintSaveManagerType) :: this !< psm object to initialize
77  !
78  ! -- Initialize members to their defaults
79  if (allocated(this%kstp_list_print)) deallocate (this%kstp_list_print)
80  if (allocated(this%kstp_list_save)) deallocate (this%kstp_list_save)
81  allocate (this%kstp_list_print(0))
82  allocate (this%kstp_list_save(0))
83  this%ifreq_print = 0
84  this%ifreq_save = 0
85  this%save_first = .false.
86  this%save_last = .false.
87  this%save_all = .false.
88  this%print_first = .false.
89  this%print_last = .false.
90  this%print_all = .false.
91  this%save_detected = .false.
92  this%print_detected = .false.
93  !
94  ! -- return
95  return

◆ kstp_to_print()

logical function printsavemanagermodule::kstp_to_print ( class(printsavemanagertype this,
integer(i4b), intent(in)  kstp,
logical(lgp), intent(in)  endofperiod 
)
private

Determine if data should be printed based on kstp and endofperiod

Parameters
thispsm object
[in]kstpcurrent time step
[in]endofperiodflag indicating end of stress period

Definition at line 221 of file PrintSaveManager.f90.

222  ! -- dummy
223  class(PrintSaveManagerType) :: this !< psm object
224  integer(I4B), intent(in) :: kstp !< current time step
225  logical(LGP), intent(in) :: endofperiod !< flag indicating end of stress period
226  ! -- local
227  integer(I4B) :: i, n
228  !
229  kstp_to_print = .false.
230  if (this%print_all) kstp_to_print = .true.
231  if (kstp == 1 .and. this%print_first) kstp_to_print = .true.
232  if (endofperiod .and. this%print_last) kstp_to_print = .true.
233  if (this%ifreq_print > 0) then
234  if (mod(kstp, this%ifreq_print) == 0) kstp_to_print = .true.
235  end if
236  n = size(this%kstp_list_print)
237  if (n > 0) then
238  do i = 1, n
239  if (kstp == this%kstp_list_print(i)) then
240  kstp_to_print = .true.
241  exit
242  end if
243  end do
244  end if
245  !
246  ! -- Return
247  return

◆ kstp_to_save()

logical function printsavemanagermodule::kstp_to_save ( class(printsavemanagertype this,
integer(i4b), intent(in)  kstp,
logical(lgp), intent(in)  endofperiod 
)
private

Determine if data should be saved based on kstp and endofperiod

Parameters
thispsm object
[in]kstpcurrent time step
[in]endofperiodflag indicating end of stress period

Definition at line 255 of file PrintSaveManager.f90.

256  ! -- dummy
257  class(PrintSaveManagerType) :: this !< psm object
258  integer(I4B), intent(in) :: kstp !< current time step
259  logical(LGP), intent(in) :: endofperiod !< flag indicating end of stress period
260  ! -- local
261  integer(I4B) :: i, n
262  !
263  kstp_to_save = .false.
264  if (this%save_all) kstp_to_save = .true.
265  if (kstp == 1 .and. this%save_first) kstp_to_save = .true.
266  if (endofperiod .and. this%save_last) kstp_to_save = .true.
267  if (this%ifreq_save > 0) then
268  if (mod(kstp, this%ifreq_save) == 0) kstp_to_save = .true.
269  end if
270  n = size(this%kstp_list_save)
271  if (n > 0) then
272  do i = 1, n
273  if (kstp == this%kstp_list_save(i)) then
274  kstp_to_save = .true.
275  exit
276  end if
277  end do
278  end if
279  !
280  ! -- Return
281  return

◆ rp()

subroutine printsavemanagermodule::rp ( class(printsavemanagertype this,
character(len=*), intent(in)  linein,
integer(i4b), intent(in)  iout 
)
private

Parse information in the line and assign settings for the PrintSaveManagerType.

Parameters
thispsm object
[in]lineincharacter line of information
[in]ioutunit number of output file

Definition at line 104 of file PrintSaveManager.f90.

105  ! -- dummy
106  class(PrintSaveManagerType) :: this !< psm object
107  character(len=*), intent(in) :: linein !< character line of information
108  integer(I4B), intent(in) :: iout !< unit number of output file
109  ! -- local
110  character(len=len(linein)) :: line
111  logical lp, ls
112  integer(I4B) :: n
113  integer(I4B) :: lloc, istart, istop, ival
114  real(DP) :: rval
115  ! -- formats
116  character(len=*), parameter :: fmt_steps = &
117  &"(6x,'THE FOLLOWING STEPS WILL BE ',A,': ',50(I0,' '))"
118  character(len=*), parameter :: fmt_freq = &
119  &"(6x,'THE FOLLOWING FREQUENCY WILL BE ',A,': ',I0)"
120  !
121  ! -- Set the values based on line
122  ! -- Get keyword to use in assignment
123  line(:) = linein(:)
124  lloc = 1
125  call urword(line, lloc, istart, istop, 1, ival, rval, 0, 0)
126  !
127  ! -- set dimension for print or save
128  lp = .false.
129  ls = .false.
130  select case (line(istart:istop))
131  case ('PRINT')
132  lp = .true.
133  case ('SAVE')
134  ls = .true.
135  case default
136  write (errmsg, '(2a)') &
137  'Looking for PRINT or SAVE. Found:', trim(adjustl(line))
138  call store_error(errmsg, terminate=.true.)
139  end select
140  !
141  ! -- set member variables
142  this%save_detected = ls
143  this%print_detected = lp
144  !
145  ! -- set the steps to print or save
146  call urword(line, lloc, istart, istop, 1, ival, rval, 0, 0)
147  select case (line(istart:istop))
148  case ('ALL')
149  if (lp) then
150  this%print_all = .true.
151  if (iout > 0) write (iout, "(6x,a)") 'ALL TIME STEPS WILL BE PRINTED'
152  end if
153  if (ls) then
154  this%save_all = .true.
155  if (iout > 0) write (iout, "(6x,a)") 'ALL TIME STEPS WILL BE SAVED'
156  end if
157  case ('STEPS')
158  listsearch: do
159  call urword(line, lloc, istart, istop, 2, ival, rval, -1, 0)
160  if (ival > 0) then
161  if (lp) then
162  n = size(this%kstp_list_print)
163  call expandarray(this%kstp_list_print)
164  this%kstp_list_print(n + 1) = ival
165  end if
166  if (ls) then
167  n = size(this%kstp_list_save)
168  call expandarray(this%kstp_list_save)
169  this%kstp_list_save(n + 1) = ival
170  end if
171  cycle listsearch
172  end if
173  exit listsearch
174  end do listsearch
175  if (iout > 0) then
176  if (lp) write (iout, fmt_steps) 'PRINTED', this%kstp_list_print
177  if (ls) write (iout, fmt_steps) 'SAVED', this%kstp_list_save
178  end if
179  case ('FREQUENCY')
180  call urword(line, lloc, istart, istop, 2, ival, rval, -1, 0)
181  if (lp) this%ifreq_print = ival
182  if (ls) this%ifreq_save = ival
183  if (iout > 0) then
184  if (lp) write (iout, fmt_freq) 'PRINTED', this%ifreq_print
185  if (ls) write (iout, fmt_freq) 'SAVED', this%ifreq_save
186  end if
187  case ('FIRST')
188  if (lp) then
189  this%print_first = .true.
190  if (iout > 0) write (iout, "(6x,a)") 'THE FIRST TIME STEP WILL BE PRINTED'
191  end if
192  if (ls) then
193  this%save_first = .true.
194  if (iout > 0) write (iout, "(6x,a)") 'THE FIRST TIME STEP WILL BE SAVED'
195  end if
196  case ('LAST')
197  if (lp) then
198  this%print_last = .true.
199  if (iout > 0) write (iout, "(6x,a)") 'THE LAST TIME STEP WILL BE PRINTED'
200  end if
201  if (ls) then
202  this%save_last = .true.
203  if (iout > 0) write (iout, "(6x,a)") 'THE LAST TIME STEP WILL BE SAVED'
204  end if
205  case default
206  write (errmsg, '(2a)') &
207  'Looking for ALL, STEPS, FIRST, LAST, OR FREQUENCY. Found: ', &
208  trim(adjustl(line))
209  call store_error(errmsg, terminate=.true.)
210  end select
211  !
212  ! -- return
213  return
Here is the call graph for this function: