MODFLOW 6  version 6.8.0.dev0
USGS Modular Hydrologic Model
Mf6FileList.f90
Go to the documentation of this file.
1 !> @brief This module contains the ListLoadModule
2 !!
3 !! This module contains the routines for reading period block
4 !! list based input.
5 !!
6 !<
8 
9  use kindmodule, only: i4b, lgp
10  use constantsmodule, only: linelength
21 
22  implicit none
23  private
24  public :: listloadtype
25 
26  !> @brief list input loader for dynamic packages.
27  !!
28  !! Create and update input context for list based period blocks.
29  !!
30  !<
32  type(timeseriesmanagertype), pointer :: tsmanager => null()
33  type(structarraytype), pointer :: structarray => null()
34  type(loadcontexttype) :: ctx
35  type(loadmf6filetype) :: static_loader ! persistent static loader
36  logical(LGP) :: ts_active !< .true. if TS files are loaded
37  contains
38  procedure :: ainit
39  procedure :: df
40  procedure :: ad
41  procedure :: reset
42  procedure :: rp
43  procedure :: destroy
44  procedure :: create_structarray
45  end type listloadtype
46 
47 contains
48 
49  subroutine ainit(this, mf6_input, component_name, component_input_name, &
50  input_name, iperblock, parser, iout)
51  use inputoutputmodule, only: getunit
55  class(listloadtype), intent(inout) :: this
56  type(modflowinputtype), intent(in) :: mf6_input
57  character(len=*), intent(in) :: component_name
58  character(len=*), intent(in) :: component_input_name
59  character(len=*), intent(in) :: input_name
60  integer(I4B), intent(in) :: iperblock
61  type(blockparsertype), pointer, intent(inout) :: parser
62  integer(I4B), intent(in) :: iout
63  type(characterstringtype), dimension(:), pointer, contiguous :: ts_fnames
64  character(len=LINELENGTH) :: fname
65  integer(I4B) :: ts6_size, n
66 
67  ! init loader
68  call this%DynamicPkgLoadType%init(mf6_input, component_name, &
69  component_input_name, input_name, &
70  iperblock, iout)
71  ! initialize scalars
72  this%ts_active = .false.
73 
74  ! create tsmanager
75  allocate (this%tsmanager)
76  call tsmanager_cr(this%tsmanager, iout)
77 
78  ! load static input (TS6_FILENAME tag sets static_loader%ts_active)
79  call this%static_loader%load(parser, mf6_input, this%nc_vars, &
80  this%input_name, iout)
81 
82  ! if TS files were declared, add them to our tsmanager now
83  if (this%static_loader%ts_active) then
84  this%ts_active = .true.
85  call get_isize('TS6_FILENAME', mf6_input%mempath, ts6_size)
86  if (ts6_size > 0) then
87  call mem_setptr(ts_fnames, 'TS6_FILENAME', mf6_input%mempath)
88  do n = 1, size(ts_fnames)
89  fname = ts_fnames(n)
90  call this%tsmanager%add_tsfile(fname, getunit())
91  end do
92  end if
93  end if
94 
95  ! initialize package input context
96  call this%ctx%init(mf6_input)
97 
98  ! store in scope SA cols for list input
99  call this%ctx%tags(this%param_names, this%nparam, this%input_name)
100 
101  ! construct and set up the struct array object
102  call this%create_structarray()
103 
104  ! finalize input context setup
105  call this%ctx%allocate_arrays()
106  end subroutine ainit
107 
108  subroutine df(this)
110  class(listloadtype), intent(inout) :: this
111  type(structarraytype), pointer :: sa
112  integer(I4B) :: n
113  ! define tsmanager (TDIS is now available)
114  call this%tsmanager%tsmanager_df()
115  ! link static TS strlocs; preserve for re-registration after reset()
116  do n = 1, this%static_loader%ts_sa_count()
117  sa => this%static_loader%get_ts_sa(n)
118  if (associated(sa)) then
119  call sa%ts_update(this%tsmanager, &
120  this%mf6_input%subcomponent_name, &
121  this%ctx%iprpak, this%input_name, &
122  this%ctx%auxname_cst, &
123  clear_strlocs=.false.)
124  end if
125  end do
126  end subroutine df
127 
128  subroutine ad(this)
129  class(listloadtype), intent(inout) :: this
130  ! advance timeseries
131  call this%tsmanager%ad()
132  end subroutine ad
133 
134  subroutine reset(this)
136  class(listloadtype), intent(inout) :: this
137  type(structarraytype), pointer :: sa
138  integer(I4B) :: n
139  ! clear TS links
140  call this%tsmanager%reset(this%mf6_input%subcomponent_name)
141  ! re-register static TS links (strlocs preserved in df)
142  if (this%ts_active) then
143  do n = 1, this%static_loader%ts_sa_count()
144  sa => this%static_loader%get_ts_sa(n)
145  if (associated(sa)) then
146  call sa%ts_update(this%tsmanager, &
147  this%mf6_input%subcomponent_name, &
148  this%ctx%iprpak, this%input_name, &
149  this%ctx%auxname_cst, &
150  clear_strlocs=.false.)
151  end if
152  end do
153  end if
154  end subroutine reset
155 
156  subroutine rp(this, parser)
161  class(listloadtype), intent(inout) :: this
162  type(blockparsertype), pointer, intent(inout) :: parser
163  integer(I4B) :: ibinary
164  integer(I4B) :: oc_inunit
165 
166  call this%reset()
167  ibinary = read_control_record(parser, oc_inunit, this%iout)
168 
169  ! log lst file header
170  call idm_log_header(this%mf6_input%component_name, &
171  this%mf6_input%subcomponent_name, this%iout)
172 
173  if (ibinary == 1) then
174  this%ctx%nbound = &
175  this%structarray%read_from_binary(oc_inunit, this%iout)
176  call parser%terminateblock()
177  close (oc_inunit)
178  else
179  this%ctx%nbound = &
180  this%structarray%read_from_parser(parser, this%ts_active, this%iout, &
181  this%input_name)
182  end if
183 
184  ! update ts links
185  if (this%ts_active) then
186  call this%structarray%ts_update(this%tsmanager, &
187  this%mf6_input%subcomponent_name, &
188  this%ctx%iprpak, this%input_name, &
189  this%ctx%auxname_cst)
190  end if
191 
192  ! close logging statement
193  call idm_log_close(this%mf6_input%component_name, &
194  this%mf6_input%subcomponent_name, this%iout)
195  end subroutine rp
196 
197  subroutine destroy(this)
198  class(listloadtype), intent(inout) :: this
199  !
200  ! clean up saved static structarrays
201  call this%static_loader%cleanup()
202  !
203  ! deallocate tsmanager
204  call this%tsmanager%da()
205  deallocate (this%tsmanager)
206  nullify (this%tsmanager)
207  !
208  ! deallocate StructArray
209  call destructstructarray(this%structarray)
210  call this%ctx%destroy()
211  end subroutine destroy
212 
213  subroutine create_structarray(this)
216  class(listloadtype), intent(inout) :: this
217  type(inputparamdefinitiontype), pointer :: idt
218  integer(I4B) :: icol
219 
220  ! construct and set up the struct array object
221  this%structarray => constructstructarray(this%mf6_input, this%nparam, &
222  this%ctx%maxbound, 0, &
223  this%mf6_input%mempath, &
224  this%mf6_input%component_mempath)
225  ! set up struct array
226  do icol = 1, this%nparam
227  idt => get_param_definition_type(this%mf6_input%param_dfns, &
228  this%mf6_input%component_type, &
229  this%mf6_input%subcomponent_type, &
230  'PERIOD', &
231  this%param_names(icol), this%input_name)
232  ! allocate variable in memory manager
233  call this%structarray%mem_create_vector(icol, idt)
234  end do
235  end subroutine create_structarray
236 
237 end module listloadmodule
This module contains the AsciiInputLoadTypeModule.
This module contains block parser methods.
Definition: BlockParser.f90:7
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:45
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename, found)
Return parameter definition.
This module contains the Input Data Model Logger Module.
Definition: IdmLogger.f90:7
subroutine, public idm_log_close(component, subcomponent, iout)
@ brief log the closing message
Definition: IdmLogger.f90:56
subroutine, public idm_log_header(component, subcomponent, iout)
@ brief log a header message
Definition: IdmLogger.f90:44
Input definition module.
integer(i4b) function, public getunit()
Get a free unit number.
This module defines variable data types.
Definition: kind.f90:8
This module contains the ListLoadModule.
Definition: Mf6FileList.f90:7
subroutine ainit(this, mf6_input, component_name, component_input_name, input_name, iperblock, parser, iout)
Definition: Mf6FileList.f90:51
subroutine ad(this)
subroutine rp(this, parser)
subroutine destroy(this)
subroutine df(this)
subroutine reset(this)
subroutine create_structarray(this)
This module contains the LoadContextModule.
Definition: LoadContext.f90:10
This module contains the LoadMf6FileModule.
Definition: LoadMf6File.f90:8
integer(i4b) function, public read_control_record(parser, oc_inunit, iout)
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
This module contains the ModflowInputModule.
Definition: ModflowInput.f90:9
This module contains the StructArrayModule.
Definition: StructArray.f90:8
type(structarraytype) function, pointer, public constructstructarray(mf6_input, ncol, nrow, blocknum, mempath, component_mempath)
constructor for a struct_array
Definition: StructArray.f90:80
subroutine, public destructstructarray(struct_array)
destructor for a struct_array
This module contains the StructVectorModule.
Definition: StructVector.f90:7
subroutine, public tsmanager_cr(this, iout, removeTsLinksOnCompletion, extendTsToEndOfSimulation)
Create the tsmanager.
base abstract type for ascii source dynamic load
This class is used to store a single deferred-length character string. It was designed to work in an ...
Definition: CharString.f90:23
Input parameter definition. Describes an input parameter.
list input loader for dynamic packages.
Definition: Mf6FileList.f90:31
derived type for boundary package input context
Definition: LoadContext.f90:65
Static parser based input loader.
Definition: LoadMf6File.f90:54
derived type for storing input definition for a file
type for structured array
Definition: StructArray.f90:41
derived type for generic vector