MODFLOW 6  version 6.7.0.dev2
USGS Modular Hydrologic Model
Mf6FileSetting.f90
Go to the documentation of this file.
1 !> @brief This module contains the Mf6FileSettingLoadModule
2 !!
3 !! This module contains the routines for reading a dfn setting
4 !! with multiple tokens into a single CharacterStringType array
5 !! using the StructArrayType.
6 !!
7 !! Preceding param columns can be configured per package (e.g. OC)
8 !!
9 !<
11 
12  use kindmodule, only: i4b, dp, lgp
13  use constantsmodule, only: linelength
21 
22  implicit none
23  private
24  public :: settingloadtype
25 
26  !> @brief Pointer type for read state variable
27  !<
29  type(inputparamdefinitiontype), pointer :: idt
30  end type idtptrtype
31 
32  !> @brief Setting package loader
33  !!
34  !<
36  type(structarraytype), pointer :: structarray => null() !< struct array list based load type
37  type(idtptrtype), dimension(:), allocatable :: idts !< idts for struct array input cols
38  type(loadcontexttype) :: ctx !< input load context
39  contains
40  procedure :: ainit => oc_init
41  procedure :: df
42  procedure :: rp
43  procedure :: reset
44  procedure :: destroy
45  end type settingloadtype
46 
47 contains
48 
49  subroutine oc_init(this, mf6_input, component_name, component_input_name, &
50  input_name, iperblock, parser, iout)
53  class(settingloadtype), intent(inout) :: this
54  type(modflowinputtype), intent(in) :: mf6_input
55  character(len=*), intent(in) :: component_name
56  character(len=*), intent(in) :: component_input_name
57  character(len=*), intent(in) :: input_name
58  integer(I4B), intent(in) :: iperblock
59  type(blockparsertype), pointer, intent(inout) :: parser
60  integer(I4B), intent(in) :: iout
61  type(loadmf6filetype) :: loader
62  integer(I4B) :: nparam, icol
63 
64  ! init loader
65  call this%DynamicPkgLoadType%init(mf6_input, component_name, &
66  component_input_name, input_name, &
67  iperblock, iout)
68  ! initialize static loader
69  call loader%load(parser, mf6_input, this%nc_vars, this%input_name, iout)
70 
71  ! create and allocate load context
72  call this%ctx%init(mf6_input)
73  call this%ctx%allocate_arrays()
74 
75  ! set nparam
76  nparam = 1
77  select case (mf6_input%subcomponent_type)
78  case ('OC')
79  nparam = nparam + 2
80  case default
81  end select
82 
83  ! allocate idts
84  allocate (this%idts(nparam))
85 
86  ! set leading idts
87  select case (mf6_input%subcomponent_type)
88  case ('OC')
89  this%idts(1)%idt => &
90  idt_default(mf6_input%component_type, mf6_input%subcomponent_type, &
91  'PERIOD', 'OCACTION', 'OCACTION', 'STRING')
92  this%idts(2)%idt => &
93  idt_default(mf6_input%component_type, mf6_input%subcomponent_type, &
94  'PERIOD', 'RTYPE', 'RTYPE', 'STRING')
95  icol = 3
96  case default
97  icol = 1
98  end select
99 
100  ! set setting idt
101  this%idts(icol)%idt => &
102  idt_default(mf6_input%component_type, mf6_input%subcomponent_type, &
103  'PERIOD', 'SETTING', 'SETTING', 'STRING')
104  ! force all setting tokens to be read
105  this%idts(icol)%idt%shape = 'LINELENGTH'
106  end subroutine oc_init
107 
108  subroutine df(this)
109  class(settingloadtype), intent(inout) :: this
110  end subroutine df
111 
112  subroutine rp(this, parser)
113  class(settingloadtype), intent(inout) :: this
114  type(blockparsertype), pointer, intent(inout) :: parser
115 
116  ! recreate structarray for period load
117  call this%reset()
118 
119  ! read from ascii
120  this%ctx%nbound = &
121  this%structarray%read_from_parser(parser, .false., this%iout)
122  end subroutine rp
123 
124  subroutine reset(this)
125  class(settingloadtype), intent(inout) :: this
126  integer(I4B) :: icol
127 
128  if (associated(this%structarray)) then
129  ! destroy the structured array reader
130  call destructstructarray(this%structarray)
131  end if
132 
133  ! construct and set up the struct array object
134  this%structarray => constructstructarray(this%mf6_input, size(this%idts), &
135  -1, 0, this%mf6_input%mempath, &
136  this%mf6_input%component_mempath)
137  ! set up struct array
138  do icol = 1, size(this%idts)
139  ! allocate variable in memory manager
140  call this%structarray%mem_create_vector(icol, this%idts(icol)%idt)
141  end do
142  end subroutine reset
143 
144  subroutine destroy(this)
146  class(settingloadtype), intent(inout) :: this
147  integer(I4B) :: icol
148 
149  if (associated(this%structarray)) then
150  ! destroy the structured array reader
151  call destructstructarray(this%structarray)
152  end if
153 
154  do icol = 1, size(this%idts)
155  ! allocate variable in memory manager
156  deallocate (this%idts(icol)%idt)
157  nullify (this%idts(icol)%idt)
158  end do
159 
160  call this%DynamicPkgLoadType%destroy()
161  end subroutine destroy
162 
163 end module mf6filesettingloadmodule
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 idt_default(component_type, subcomponent_type, blockname, tagname, mf6varname, datatype)
return allocated input definition type
This module contains the InputDefinitionModule.
This module defines variable data types.
Definition: kind.f90:8
This module contains the LoadContextModule.
Definition: LoadContext.f90:10
This module contains the LoadMf6FileModule.
Definition: LoadMf6File.f90:8
This module contains the Mf6FileSettingLoadModule.
subroutine oc_init(this, mf6_input, component_name, component_input_name, input_name, iperblock, parser, iout)
subroutine rp(this, parser)
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:73
subroutine, public destructstructarray(struct_array)
destructor for a struct_array
base abstract type for ascii source dynamic load
derived type for boundary package input context
Definition: LoadContext.f90:61
Static parser based input loader.
Definition: LoadMf6File.f90:47
Pointer type for read state variable.
derived type for storing input definition for a file
type for structured array
Definition: StructArray.f90:36