MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
chfgwfexchangemodule Module Reference

This module contains the ChfGwfExchangeModule Module. More...

Data Types

type  chfgwfexchangetype
 

Functions/Subroutines

subroutine, public chfgwf_cr (filename, name, id, m1_id, m2_id, input_mempath)
 @ brief Create CHF GWF exchange More...
 
subroutine chf_gwf_df (this)
 @ brief Define CHF GWF exchange More...
 
subroutine source_options (this, iout)
 @ brief Source options More...
 
subroutine source_dimensions (this, iout)
 Source dimension from input context. More...
 
subroutine source_data (this, iout)
 Source exchange data from input context. More...
 

Detailed Description

This module contains a lightweight CHF-GWF exchange class which is primarily based on the underlying and generic SWF-GWF code for connecting

Function/Subroutine Documentation

◆ chf_gwf_df()

subroutine chfgwfexchangemodule::chf_gwf_df ( class(chfgwfexchangetype this)
private
Parameters
thisSwfGwfExchangeType

Definition at line 65 of file exg-chfgwf.f90.

66  ! modules
67  ! dummy
68  class(ChfGwfExchangeType) :: this !< SwfGwfExchangeType
69  ! local
70 
71  ! log the exchange
72  write (iout, '(/a,a)') ' Creating exchange: ', this%name
73  !
74  ! Ensure models are in same solution
75  if (associated(this%swfmodel) .and. associated(this%gwfmodel)) then
76  if (this%swfmodel%idsoln /= this%gwfmodel%idsoln) then
77  call store_error('Two models are connected in a SWF-GWF '// &
78  'exchange but they are in different solutions. '// &
79  'Models must be in same solution: '// &
80  trim(this%swfmodel%name)//' '// &
81  trim(this%gwfmodel%name))
82  call store_error_filename(this%filename)
83  end if
84  end if
85 
86  ! source options
87  call this%source_options(iout)
88 
89  ! source dimensions
90  call this%source_dimensions(iout)
91 
92  ! allocate arrays
93  call this%allocate_arrays()
94 
95  ! source exchange data
96  call this%source_data(iout)
97 
98  ! Store obs
99  ! call this%swf_gwf_df_obs()
100  ! if (associated(this%swfmodel1)) then
101  ! call this%obs%obs_df(iout, this%name, 'SWF-GWF', this%swfmodel1%dis)
102  ! end if
103 
104  ! ! validate
105  ! call this%validate_exchange()
106 
Here is the call graph for this function:

◆ chfgwf_cr()

subroutine, public chfgwfexchangemodule::chfgwf_cr ( character(len=*), intent(in)  filename,
character(len=*)  name,
integer(i4b), intent(in)  id,
integer(i4b), intent(in)  m1_id,
integer(i4b), intent(in)  m2_id,
character(len=*), intent(in)  input_mempath 
)

High level wrapper over the SWF-GWF exchange, which is generic in that it can be used to couple either a CHF or OLF surface water model to a GWF model.

Parameters
[in]filenamefilename for reading
nameexchange name
[in]idid for the exchange
[in]m1_idid for model 1
[in]m2_idid for model 2

Definition at line 40 of file exg-chfgwf.f90.

41  ! modules
42  ! dummy
43  character(len=*), intent(in) :: filename !< filename for reading
44  character(len=*) :: name !< exchange name
45  integer(I4B), intent(in) :: id !< id for the exchange
46  integer(I4B), intent(in) :: m1_id !< id for model 1
47  integer(I4B), intent(in) :: m2_id !< id for model 2
48  character(len=*), intent(in) :: input_mempath
49  ! local
50  type(ChfGwfExchangeType), pointer :: exchange
51  class(BaseExchangeType), pointer :: baseexchange
52 
53  ! Create a new exchange and add it to the baseexchangelist container
54  allocate (exchange)
55  baseexchange => exchange
56  call addbaseexchangetolist(baseexchangelist, baseexchange)
57 
58  call exchange%initialize(filename, name, 'CHF', id, m1_id, m2_id, &
59  input_mempath)
60 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ source_data()

subroutine chfgwfexchangemodule::source_data ( class(chfgwfexchangetype this,
integer(i4b), intent(in)  iout 
)
Parameters
thisinstance of exchange object
[in]ioutthe output file unit

Definition at line 191 of file exg-chfgwf.f90.

192  ! modules
194  ! dummy
195  class(ChfGwfExchangeType) :: this !< instance of exchange object
196  integer(I4B), intent(in) :: iout !< the output file unit
197  ! local
198  integer(I4B), dimension(:, :), contiguous, pointer :: cellidm1
199  integer(I4B), dimension(:, :), contiguous, pointer :: cellidm2
200  real(DP), dimension(:), contiguous, pointer :: bedleak
201  real(DP), dimension(:), contiguous, pointer :: cfact
202  character(len=20) :: cellstr1, cellstr2
203  integer(I4B) :: nerr
204  integer(I4B) :: iexg, nodeswf, nodegwf
205  ! format
206  character(len=*), parameter :: fmtexglabel = "(1x, 3a10, 50(a16))"
207  character(len=*), parameter :: fmtexgdata = &
208  "(5x, a, 1x, a ,50(1pg16.6))"
209 
210  call mem_setptr(cellidm1, 'CELLIDM1', this%input_mempath)
211  call mem_setptr(cellidm2, 'CELLIDM2', this%input_mempath)
212  call mem_setptr(bedleak, 'BEDLEAK', this%input_mempath)
213  call mem_setptr(cfact, 'CFACT', this%input_mempath)
214 
215  write (iout, '(1x,a)') 'PROCESSING EXCHANGEDATA'
216 
217  if (this%ipr_input /= 0) then
218  write (iout, fmtexglabel) 'NODEM1', 'NODEM2', 'BEDLEAK', 'CFACT'
219  end if
220 
221  do iexg = 1, this%nexg
222 
223  if (associated(this%model1)) then
224  ! Determine user node number
225  nodeswf = this%noder(this%model1, cellidm1(:, iexg), iout)
226  this%nodeswf(iexg) = nodeswf
227  else
228  this%nodeswf(iexg) = -1
229  end if
230 
231  if (associated(this%model2)) then
232  ! Determine user node number
233  nodegwf = this%noder(this%model2, cellidm2(:, iexg), iout)
234  this%nodegwf(iexg) = nodegwf
235  else
236  this%nodegwf(iexg) = -1
237  end if
238 
239  ! Read rest of input line
240  this%bedleak(iexg) = bedleak(iexg)
241  this%cfact(iexg) = cfact(iexg)
242 
243  ! Write the data to listing file if requested
244  if (this%ipr_input /= 0) then
245  cellstr1 = this%cellstr(this%model1, cellidm1(:, iexg), iout)
246  cellstr2 = this%cellstr(this%model2, cellidm2(:, iexg), iout)
247  write (iout, fmtexgdata) trim(cellstr1), trim(cellstr2), &
248  this%bedleak(iexg), this%cfact(iexg)
249  end if
250 
251  ! Check to see if nodeswf is outside of active domain
252  if (associated(this%model1)) then
253  if (nodeswf <= 0) then
254  cellstr1 = this%cellstr(this%model1, cellidm1(:, iexg), iout)
255  write (errmsg, *) &
256  trim(adjustl(this%model1%name))// &
257  ' Cell is outside active grid domain ('// &
258  trim(adjustl(cellstr1))//').'
259  call store_error(errmsg)
260  end if
261  end if
262 
263  ! Check to see if nodegwf is outside of active domain
264  if (associated(this%model2)) then
265  if (nodegwf <= 0) then
266  cellstr2 = this%cellstr(this%model2, cellidm2(:, iexg), iout)
267  write (errmsg, *) &
268  trim(adjustl(this%model2%name))// &
269  ' Cell is outside active grid domain ('// &
270  trim(adjustl(cellstr2))//').'
271  call store_error(errmsg)
272  end if
273  end if
274  end do
275 
276  write (iout, '(1x,a)') 'END OF EXCHANGEDATA'
277 
278  ! Stop if errors
279  nerr = count_errors()
280  if (nerr > 0) then
281  call store_error('Errors encountered in exchange input file.')
282  call store_error_filename(this%filename)
283  end if
284 
Here is the call graph for this function:

◆ source_dimensions()

subroutine chfgwfexchangemodule::source_dimensions ( class(chfgwfexchangetype this,
integer(i4b), intent(in)  iout 
)
Parameters
thisinstance of exchange object
[in]ioutfor logging

Definition at line 166 of file exg-chfgwf.f90.

167  ! modules
170  ! dummy
171  class(ChfGwfExchangeType) :: this !< instance of exchange object
172  integer(I4B), intent(in) :: iout !< for logging
173  ! local
174  type(ExgChfgwfParamFoundType) :: found
175 
176  ! update defaults with idm sourced values
177  call mem_set_value(this%nexg, 'NEXG', this%input_mempath, found%nexg)
178 
179  write (iout, '(1x,a)') 'PROCESSING EXCHANGE DIMENSIONS'
180 
181  if (found%nexg) then
182  write (iout, '(4x,a,i0)') 'NEXG = ', this%nexg
183  end if
184 
185  write (iout, '(1x,a)') 'END OF EXCHANGE DIMENSIONS'
186 

◆ source_options()

subroutine chfgwfexchangemodule::source_options ( class(chfgwfexchangetype this,
integer(i4b), intent(in)  iout 
)
private
Parameters
thisGwfExchangeType

Definition at line 111 of file exg-chfgwf.f90.

112  ! modules
113  use constantsmodule, only: lenvarname, dem6
119  ! dummy
120  class(ChfGwfExchangeType) :: this !< GwfExchangeType
121  integer(I4B), intent(in) :: iout
122  ! local
123  type(ExgChfgwfParamFoundType) :: found
124 
125  ! update defaults with idm sourced values
126  call mem_set_value(this%ipr_input, 'IPR_INPUT', &
127  this%input_mempath, found%ipr_input)
128  call mem_set_value(this%ipr_flow, 'IPR_FLOW', &
129  this%input_mempath, found%ipr_flow)
130  call mem_set_value(this%ifixedcond, 'IFIXEDCOND', &
131  this%input_mempath, found%ifixedcond)
132 
133  write (iout, '(1x,a)') 'Processing CHF-GWF exchange options'
134 
135  if (found%ipr_input) then
136  write (iout, '(4x,a)') &
137  'The list of exchanges will be printed.'
138  end if
139 
140  if (found%ipr_flow) then
141  write (iout, '(4x,a)') &
142  'Exchange flows will be printed to list files.'
143  end if
144 
145  if (found%ifixedcond) then
146  write (iout, '(4x,a)') &
147  'Conductance is fixed as product of BEDLEAK and CFACT.'
148  end if
149 
150  ! enforce 0 or 1 OBS6_FILENAME entries in option block
151  ! if (.not. this%is_datacopy) then
152  ! if (filein_fname(this%obs%inputFilename, 'OBS6_FILENAME', &
153  ! this%input_mempath, this%filename)) then
154  ! this%obs%active = .true.
155  ! this%obs%inUnitObs = GetUnit()
156  ! call openfile(this%obs%inUnitObs, iout, this%obs%inputFilename, 'OBS')
157  ! end if
158  ! end if
159 
160  write (iout, '(1x,a)') 'End of CHF-GWF exchange options'
161 
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition: Constants.f90:17
real(dp), parameter dem6
real constant 1e-6
Definition: Constants.f90:109
integer(i4b) function, public getunit()
Get a free unit number.
subroutine, public openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, filstat_opt, mode_opt)
Open a file.
Definition: InputOutput.f90:30
This module contains the SourceCommonModule.
Definition: SourceCommon.f90:7
logical(lgp) function, public filein_fname(filename, tagname, input_mempath, input_fname)
enforce and set a single input filename provided via FILEIN keyword
This class is used to store a single deferred-length character string. It was designed to work in an ...
Definition: CharString.f90:23
Here is the call graph for this function: