MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
outputcontrolmodule Module Reference

Model output control.

Data Types

type  outputcontroltype
 Controls model output. Overridden for each model type. More...

Functions/Subroutines

subroutine, public oc_cr (oc, name_model, input_mempath, inunit, iout)
 Create a new output control object.
subroutine oc_df (this)
 Define the output control type. Placeholder routine.
subroutine oc_rp (this)
 Read period block options and prepare the output control type.
subroutine oc_ot (this, ipflg)
 Write output.
subroutine oc_da (this)
 Deallocate method for OutputControlType.
subroutine allocate (this, name_model, input_mempath)
 Allocate variables for the output control object.
subroutine source_options (this)
 Read the output control options block.
subroutine set_ocfile (this, cname, ocfile, iout)
logical function oc_save (this, cname)
 Determine if it is time to save.
logical function oc_print (this, cname)
 Determine if it is time to print.
integer(i4b) function oc_save_unit (this, cname)
 Determine unit number for saving.
integer(i4b) function set_print_flag (this, cname, icnvg, endofperiod)
 Set the print flag based on convergence and other parameters.

Function/Subroutine Documentation

◆ allocate()

subroutine outputcontrolmodule::allocate ( class(outputcontroltype) this,
character(len=*), intent(in) name_model,
character(len=*), intent(in) input_mempath )
private
Parameters
thisthis instance
[in]name_modelname of model
[in]input_mempathinput mempath of the package

Definition at line 191 of file OutputControl.f90.

192 ! modules
196 ! dummy
197 class(OutputControlType) :: this !< this instance
198 character(len=*), intent(in) :: name_model !< name of model
199 character(len=*), intent(in) :: input_mempath !< input mempath of the package
200 logical(LGP) :: found
201
202 this%memoryPath = create_mem_path(name_model, 'OC')
203
204 allocate (this%name_model)
205 allocate (this%input_fname)
206 call mem_allocate(this%inunit, 'INUNIT', this%memoryPath)
207 call mem_allocate(this%iout, 'IOUT', this%memoryPath)
208 call mem_allocate(this%ibudcsv, 'IBUDCSV', this%memoryPath)
209 call mem_allocate(this%iperoc, 'IPEROC', this%memoryPath)
210 call mem_allocate(this%iocrep, 'IOCREP', this%memoryPath)
211
212 this%name_model = name_model
213 this%input_mempath = input_mempath
214 this%input_fname = ''
215 this%inunit = 0
216 this%iout = 0
217 this%ibudcsv = 0
218 this%iperoc = 0
219 this%iocrep = 0
220
221 if (this%input_mempath /= '') then
222 call mem_set_value(this%input_fname, 'INPUT_FNAME', &
223 this%input_mempath, found)
224 end if
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
Here is the call graph for this function:

◆ oc_cr()

subroutine, public outputcontrolmodule::oc_cr ( type(outputcontroltype), pointer oc,
character(len=*), intent(in) name_model,
character(len=*), intent(in) input_mempath,
integer(i4b), intent(in) inunit,
integer(i4b), intent(in) iout )
Parameters
ocOutputControlType object
[in]name_modelname of the model
[in]input_mempathinput mempath of the package
[in]inunitunit number for input
[in]ioutunit number for output

Definition at line 43 of file OutputControl.f90.

44 type(OutputControlType), pointer :: oc !< OutputControlType object
45 character(len=*), intent(in) :: name_model !< name of the model
46 character(len=*), intent(in) :: input_mempath !< input mempath of the package
47 integer(I4B), intent(in) :: inunit !< unit number for input
48 integer(I4B), intent(in) :: iout !< unit number for output
49
50 allocate (oc)
51 call oc%allocate_scalars(name_model, input_mempath)
52 oc%inunit = inunit
53 oc%iout = iout

◆ oc_da()

subroutine outputcontrolmodule::oc_da ( class(outputcontroltype) this)
private

Deallocate member variables.

Parameters
thisOutputControlType object

Definition at line 168 of file OutputControl.f90.

169 ! modules
171 ! dummy
172 class(OutputControlType) :: this !< OutputControlType object
173 ! local
174 integer(I4B) :: i
175
176 do i = 1, size(this%ocds)
177 call this%ocds(i)%ocd_da()
178 end do
179 deallocate (this%ocds)
180
181 deallocate (this%name_model)
182 deallocate (this%input_fname)
183 call mem_deallocate(this%inunit)
184 call mem_deallocate(this%iout)
185 call mem_deallocate(this%ibudcsv)
186 call mem_deallocate(this%iperoc)
187 call mem_deallocate(this%iocrep)

◆ oc_df()

subroutine outputcontrolmodule::oc_df ( class(outputcontroltype) this)
private
Parameters
thisthis instance

Definition at line 57 of file OutputControl.f90.

58 class(OutputControlType) :: this !< this instance

◆ oc_ot()

subroutine outputcontrolmodule::oc_ot ( class(outputcontroltype) this,
integer(i4b), intent(inout) ipflg )
private

Go through each output control data type and print and/or save data based on user-specified controls.

Parameters
thisOutputControlType object
[in,out]ipflgflag indicating if data was printed

Definition at line 143 of file OutputControl.f90.

144 ! modules
145 use tdismodule, only: kstp, endofperiod
146 ! dummy
147 class(OutputControlType) :: this !< OutputControlType object
148 integer(I4B), intent(inout) :: ipflg !< flag indicating if data was printed
149 ! local
150 integer(I4B) :: ipos
151 type(OutputControlDataType), pointer :: ocdobjptr
152
153 ! Clear printout flag(ipflg). This flag indicates that an array was
154 ! printed to the listing file.
155 ipflg = 0
156
157 do ipos = 1, size(this%ocds)
158 ocdobjptr => this%ocds(ipos)
159 call ocdobjptr%ocd_ot(ipflg, kstp, endofperiod, this%iout)
160 end do
logical(lgp), pointer, public endofperiod
flag indicating end of stress period
Definition tdis.f90:30
integer(i4b), pointer, public kstp
current time step number
Definition tdis.f90:27

◆ oc_print()

logical function outputcontrolmodule::oc_print ( class(outputcontroltype) this,
character(len=*), intent(in) cname )
private
Parameters
thisOutputControlType object
[in]cnamecharacter string for data name

Definition at line 346 of file OutputControl.f90.

347 ! modules
348 use tdismodule, only: kstp, endofperiod
349 ! dummy
350 class(OutputControlType) :: this !< OutputControlType object
351 character(len=*), intent(in) :: cname !< character string for data name
352 ! local
353 integer(I4B) :: ipos
354 logical(LGP) :: found
355 class(OutputControlDataType), pointer :: ocdobjptr
356
357 oc_print = .false.
358 found = .false.
359 do ipos = 1, size(this%ocds)
360 ocdobjptr => this%ocds(ipos)
361 if (cname == trim(ocdobjptr%cname)) then
362 found = .true.
363 exit
364 end if
365 end do
366 if (found) then
367 oc_print = ocdobjptr%psm%should_print(kstp, endofperiod)
368 end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ oc_rp()

subroutine outputcontrolmodule::oc_rp ( class(outputcontroltype) this)
private
Parameters
thisthis instance

Definition at line 62 of file OutputControl.f90.

63 ! modules
64 use tdismodule, only: kper
68 ! dummy
69 class(OutputControlType) :: this !< this instance
70 ! local
71 class(OutputControlDataType), pointer :: ocdobjptr
72 integer(I4B), pointer :: iper
73 type(CharacterStringType), dimension(:), &
74 pointer, contiguous :: ocactions
75 type(CharacterStringType), dimension(:), &
76 pointer, contiguous :: rtypes
77 type(CharacterStringType), dimension(:), &
78 pointer, contiguous :: ocsettings
79 integer(I4B), pointer :: nlist
80 integer(I4B) :: n, ipos
81 character(len=LINELENGTH) :: ocaction, rtype, ocsetting
82 logical(LGP) :: found_rtype
83 ! formats
84 character(len=*), parameter :: fmtboc = &
85 &"(1X,/1X,'BEGIN READING OUTPUT CONTROL FOR STRESS PERIOD ',I0)"
86 character(len=*), parameter :: fmteoc = &
87 &"(/,1X,'END READING OUTPUT CONTROL FOR STRESS PERIOD ',I0)"
88 character(len=*), parameter :: fmtroc = &
89 "(1X,/1X,'OUTPUT CONTROL FOR STRESS PERIOD ',I0, &
90 &' IS REPEATED USING SETTINGS FROM A PREVIOUS STRESS PERIOD.')"
91
92 if (this%input_mempath == '') return
93 call mem_setptr(iper, 'IPER', this%input_mempath)
94 if (iper /= kper) then
95 ! previous output control settings are still active
96 write (this%iout, fmtroc) kper
97 return
98 else
99 this%iperoc = iper
100 write (this%iout, fmtboc) this%iperoc
101 end if
102
103 ! Clear io flags
104 do ipos = 1, size(this%ocds)
105 ocdobjptr => this%ocds(ipos)
106 call ocdobjptr%psm%init()
107 end do
108
109 call mem_setptr(nlist, 'NBOUND', this%input_mempath)
110 call mem_setptr(ocactions, 'OCACTION', this%input_mempath)
111 call mem_setptr(rtypes, 'RTYPE', this%input_mempath)
112 call mem_setptr(ocsettings, 'SETTING', this%input_mempath)
113
114 do n = 1, nlist
115 ocaction = ocactions(n)
116 rtype = rtypes(n)
117 ocsetting = ocsettings(n)
118
119 found_rtype = .false.
120 do ipos = 1, size(this%ocds)
121 ocdobjptr => this%ocds(ipos)
122 if (rtype == trim(ocdobjptr%cname)) then
123 found_rtype = .true.
124 call ocdobjptr%psm%set(ocaction, ocsetting, this%iout)
125 call ocdobjptr%ocd_rp_check(this%input_fname)
126 end if
127 end do
128 if (.not. found_rtype) then
129 call store_error('Input OC period block rtype not found: "'// &
130 trim(rtype)//'".')
131 call store_error_filename(this%input_fname)
132 end if
133 end do
134
135 write (this%iout, fmteoc) this%iperoc
This module contains simulation methods.
Definition Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition Sim.f90:208
integer(i4b), pointer, public kper
current stress period number
Definition tdis.f90:26
This class is used to store a single deferred-length character string. It was designed to work in an ...
Here is the call graph for this function:

◆ oc_save()

logical function outputcontrolmodule::oc_save ( class(outputcontroltype) this,
character(len=*), intent(in) cname )
private
Parameters
thisOutputControlType object
[in]cnamecharacter string for data name

Definition at line 320 of file OutputControl.f90.

321 ! modules
322 use tdismodule, only: kstp, endofperiod
323 ! dummy
324 class(OutputControlType) :: this !< OutputControlType object
325 character(len=*), intent(in) :: cname !< character string for data name
326 ! local
327 integer(I4B) :: ipos
328 logical(LGP) :: found
329 class(OutputControlDataType), pointer :: ocdobjptr
330 !
331 oc_save = .false.
332 found = .false.
333 do ipos = 1, size(this%ocds)
334 ocdobjptr => this%ocds(ipos)
335 if (cname == trim(ocdobjptr%cname)) then
336 found = .true.
337 exit
338 end if
339 end do
340 if (found) then
341 oc_save = ocdobjptr%psm%should_save(kstp, endofperiod)
342 end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ oc_save_unit()

integer(i4b) function outputcontrolmodule::oc_save_unit ( class(outputcontroltype) this,
character(len=*), intent(in) cname )
private
Parameters
thisOutputControlType object
[in]cnamecharacter string for data name

Definition at line 372 of file OutputControl.f90.

373 ! -- modules
374 ! -- return
375 integer(I4B) :: oc_save_unit
376 ! -- dummy
377 class(OutputControlType) :: this !< OutputControlType object
378 character(len=*), intent(in) :: cname !< character string for data name
379 ! -- local
380 integer(I4B) :: ipos
381 logical(LGP) :: found
382 class(OutputControlDataType), pointer :: ocdobjptr
383 !
384 oc_save_unit = 0
385 found = .false.
386 do ipos = 1, size(this%ocds)
387 ocdobjptr => this%ocds(ipos)
388 if (cname == trim(ocdobjptr%cname)) then
389 found = .true.
390 exit
391 end if
392 end do
393 if (found) then
394 oc_save_unit = ocdobjptr%idataun
395 end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_ocfile()

subroutine outputcontrolmodule::set_ocfile ( class(outputcontroltype) this,
character(len=*), intent(in) cname,
character(len=*), intent(in) ocfile,
integer(i4b), intent(in) iout )
private
Parameters
thisOutputControlDataType object
[in]cnamedata object cname
[in]ocfileOC output filename
[in]ioutUnit number for output

Definition at line 293 of file OutputControl.f90.

294 ! modules
296 ! dummy
297 class(OutputControlType) :: this !< OutputControlDataType object
298 character(len=*), intent(in) :: cname !< data object cname
299 character(len=*), intent(in) :: ocfile !< OC output filename
300 integer(I4B), intent(in) :: iout !< Unit number for output
301 type(OutputControlDataType), pointer :: ocdobjptr
302 integer(I4B) :: ipos
303 logical(LGP) :: found
304 found = .false.
305 do ipos = 1, size(this%ocds)
306 ocdobjptr => this%ocds(ipos)
307 if (cname == trim(ocdobjptr%cname)) then
308 found = .true.
309 call ocdobjptr%set_ocfile(ocfile, iout)
310 end if
311 end do
312 if (.not. found) then
313 call store_error('OC internal error: oc data type not found for name "'// &
314 trim(cname)//'".')
315 call store_error_filename(this%input_fname)
316 end if
Here is the call graph for this function:

◆ set_print_flag()

integer(i4b) function outputcontrolmodule::set_print_flag ( class(outputcontroltype) this,
character(len=*), intent(in) cname,
integer(i4b), intent(in) icnvg,
logical, intent(in) endofperiod )
private
Parameters
thisOutputControlType object
[in]cnamecharacter string for data name
[in]icnvgconvergence flag
[in]endofperiodend of period logical flag

Definition at line 399 of file OutputControl.f90.

400 ! -- modules
402 ! -- return
403 integer(I4B) :: iprint_flag
404 ! -- dummy
405 class(OutputControlType) :: this !< OutputControlType object
406 character(len=*), intent(in) :: cname !< character string for data name
407 integer(I4B), intent(in) :: icnvg !< convergence flag
408 logical, intent(in) :: endofperiod !< end of period logical flag
409 ! -- local
410 !
411 ! -- default is to not print
412 iprint_flag = 0
413 !
414 ! -- if the output control file indicates that cname should be printed
415 if (this%oc_print(cname)) iprint_flag = 1
416 !
417 ! -- if it is not a CONTINUE run, then set to print if not converged
418 if (isimcontinue == 0) then
419 if (icnvg == 0) iprint_flag = 1
420 end if
421 !
422 ! -- if it's the end of the period, then set flag to print
423 if (endofperiod) iprint_flag = 1
This module contains simulation variables.
integer(i4b) isimcontinue
simulation continue flag (1) to continue if isimcnvg = 0, (0) to terminate

◆ source_options()

subroutine outputcontrolmodule::source_options ( class(outputcontroltype) this)
private
Parameters
thisthis instance

Definition at line 228 of file OutputControl.f90.

229 ! modules
232 ! dummy
233 class(OutputControlType) :: this !< this instance
234 type(OutputControlDataType), pointer :: ocdobjptr
235 character(len=LINELENGTH) :: budgetfn, budgetcsv
236 character(len=LINELENGTH) :: prnfmt, print_format
237 logical(LGP) :: found_budcsv, found_budget
238 logical(LGP), dimension(4) :: found_format
239 integer(I4B), pointer :: columns, width, ndigits
240 integer(I4B) :: ipos
241
242 found_format = .false.
243 allocate (columns)
244 allocate (width)
245 allocate (ndigits)
246
247 call mem_set_value(columns, 'COLUMNS', this%input_mempath, &
248 found_format(1))
249 call mem_set_value(width, 'WIDTH', this%input_mempath, &
250 found_format(2))
251 call mem_set_value(ndigits, 'DIGITS', this%input_mempath, &
252 found_format(3))
253 call mem_set_value(prnfmt, 'FORMAT', this%input_mempath, &
254 found_format(4))
255 call mem_set_value(budgetcsv, 'BUDGETCSVFILE', this%input_mempath, &
256 found_budcsv)
257 call mem_set_value(budgetfn, 'BUDGETFILE', this%input_mempath, &
258 found_budget)
259
260 if (found_budcsv) then
261 this%ibudcsv = getunit()
262 call openfile(this%ibudcsv, this%iout, budgetcsv, 'CSV', &
263 filstat_opt='REPLACE')
264 end if
265
266 if (found_budget) then
267 call this%set_ocfile('BUDGET', budgetfn, this%iout)
268 end if
269
270 if (any(found_format(1:3)) .and. .not. all(found_format(1:3))) then
271 call store_error('PRINT_FORMAT must include COLUMNS, WIDTH and DIGITS. &
272 &Syntax is: COLUMNS <columns> WIDTH <width> &
273 &DIGITS <digits> [<format>].')
274 call store_error_filename(this%input_fname)
275 end if
276
277 if (all(found_format)) then
278 write (print_format, '(a,i0,a,i0,a,i0,a)') 'COLUMNS ', columns, &
279 ' WIDTH ', width, ' DIGITS ', ndigits, ' '//trim(prnfmt)//' '
280 do ipos = 1, size(this%ocds)
281 ocdobjptr => this%ocds(ipos)
282 if (ocdobjptr%cname /= 'BUDGET') then
283 call ocdobjptr%set_prnfmt(print_format, 0)
284 end if
285 end do
286 end if
287
288 deallocate (columns)
289 deallocate (width)
290 deallocate (ndigits)
Here is the call graph for this function: