MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
disconnexchangemodule Module Reference

Data Types

type  disconnexchangetype
 Exchange based on connection between discretizations of DisBaseType. The data specifies the connections, similar to the information stored in the connections object: DisBaseTypecon. More...
 
type  disconnexchangefoundtype
 @ brief DisConnExchangeFoundType More...
 

Functions/Subroutines

subroutine source_options (this, iout)
 Source options from input context. More...
 
subroutine source_dimensions (this, iout)
 Source dimension from input context. More...
 
integer(i4b) function noder (this, model, cellid, iout)
 Returns reduced node number from user. More...
 
character(len=20) function cellstr (this, ndim, cellid, iout)
 
subroutine source_data (this, iout)
 Source exchange data from input context. More...
 
subroutine allocate_scalars (this)
 Allocate scalars and initialize to defaults. More...
 
subroutine allocate_arrays (this)
 Allocate array data, using the number of connected nodes. More...
 
logical(lgp) function use_interface_model (this)
 Should interface model be used to handle these exchanges, to be overridden for inheriting types. More...
 
subroutine disconnex_da (this)
 Clean up all scalars and arrays. More...
 
class(disconnexchangetype) function, pointer, public castasdisconnexchangeclass (obj)
 
subroutine, public adddisconnexchangetolist (list, exchange)
 
class(disconnexchangetype) function, pointer, public getdisconnexchangefromlist (list, idx)
 

Function/Subroutine Documentation

◆ adddisconnexchangetolist()

subroutine, public disconnexchangemodule::adddisconnexchangetolist ( type(listtype), intent(inout)  list,
class(disconnexchangetype), intent(in), pointer  exchange 
)

Definition at line 523 of file DisConnExchange.f90.

524  implicit none
525  ! -- dummy
526  type(ListType), intent(inout) :: list
527  class(DisConnExchangeType), pointer, intent(in) :: exchange
528  ! -- local
529  class(*), pointer :: obj
530  !
531  obj => exchange
532  call list%Add(obj)

◆ allocate_arrays()

subroutine disconnexchangemodule::allocate_arrays ( class(disconnexchangetype this)
Parameters
nexg
thisinstance of exchange object

Definition at line 436 of file DisConnExchange.f90.

437  ! -- dummy
438  class(DisConnExchangeType) :: this !< instance of exchange object
439  !
440  call mem_allocate(this%nodem1, this%nexg, 'NODEM1', this%memoryPath)
441  call mem_allocate(this%nodem2, this%nexg, 'NODEM2', this%memoryPath)
442  call mem_allocate(this%ihc, this%nexg, 'IHC', this%memoryPath)
443  call mem_allocate(this%cl1, this%nexg, 'CL1', this%memoryPath)
444  call mem_allocate(this%cl2, this%nexg, 'CL2', this%memoryPath)
445  call mem_allocate(this%hwva, this%nexg, 'HWVA', this%memoryPath)
446  ! NB: auxname array is allocated while parsing
447  call mem_allocate(this%auxvar, this%naux, this%nexg, &
448  'AUXVAR', this%memoryPath)
449  !
450  ! allocate boundname
451  if (this%inamedbound == 1) then
452  allocate (this%boundname(this%nexg))
453  else
454  allocate (this%boundname(1))
455  end if
456  this%boundname(:) = ''

◆ allocate_scalars()

subroutine disconnexchangemodule::allocate_scalars ( class(disconnexchangetype this)
Parameters
thisinstance of exchange object

Definition at line 395 of file DisConnExchange.f90.

396  ! -- modules
398  ! -- dummy
399  class(DisConnExchangeType) :: this !< instance of exchange object
400  !
401  allocate (this%filename)
402  this%filename = ''
403  !
404  call mem_allocate(this%nexg, 'NEXG', this%memoryPath)
405  call mem_allocate(this%naux, 'NAUX', this%memoryPath)
406  call mem_allocate(this%ianglex, 'IANGLEX', this%memoryPath)
407  call mem_allocate(this%icdist, 'ICDIST', this%memoryPath)
408  call mem_allocate(this%ixt3d, 'IXT3D', this%memoryPath)
409  call mem_allocate(this%iprpak, 'IPRPAK', this%memoryPath)
410  call mem_allocate(this%iprflow, 'IPRFLOW', this%memoryPath)
411  call mem_allocate(this%ipakcb, 'IPAKCB', this%memoryPath)
412  call mem_allocate(this%inamedbound, 'INAMEDBOUND', this%memoryPath)
413  call mem_allocate(this%dev_ifmod_on, 'DEV_IFMOD_ON', this%memoryPath)
414 
415  call mem_allocate(this%auxname, lenauxname, 0, &
416  'AUXNAME', this%memoryPath)
417  call mem_allocate(this%auxname_cst, lenauxname, 0, &
418  'AUXNAME_CST', this%memoryPath)
419  !
420  this%nexg = 0
421  this%naux = 0
422  this%ianglex = 0
423  this%icdist = 0
424  this%ixt3d = 0
425  this%iprpak = 0
426  this%iprflow = 0
427  this%ipakcb = 0
428  this%inamedbound = 0
429  !
430  this%dev_ifmod_on = .false.

◆ castasdisconnexchangeclass()

class(disconnexchangetype) function, pointer, public disconnexchangemodule::castasdisconnexchangeclass ( class(*), intent(inout), pointer  obj)

Definition at line 507 of file DisConnExchange.f90.

508  implicit none
509  ! -- dummy
510  class(*), pointer, intent(inout) :: obj
511  ! -- return
512  class(DisConnExchangeType), pointer :: res
513  !
514  res => null()
515  if (.not. associated(obj)) return
516  !
517  select type (obj)
518  class is (disconnexchangetype)
519  res => obj
520  end select
Here is the caller graph for this function:

◆ cellstr()

character(len=20) function disconnexchangemodule::cellstr ( class(disconnexchangetype this,
integer(i4b)  ndim,
integer(i4b), dimension(:), intent(in)  cellid,
integer(i4b), intent(in)  iout 
)
Parameters
thisinstance of exchange object
ndimmodel DIS dimension
[in]ioutthe output file unit

Definition at line 220 of file DisConnExchange.f90.

221  ! -- modules
222  ! -- dummy
223  class(DisConnExchangeType) :: this !< instance of exchange object
224  integer(I4B) :: ndim !< model DIS dimension
225  integer(I4B), dimension(:), intent(in) :: cellid
226  integer(I4B), intent(in) :: iout !< the output file unit
227  character(len=20) :: cellstr
228  character(len=*), parameter :: fmtndim1 = &
229  "('(',i0,')')"
230  character(len=*), parameter :: fmtndim2 = &
231  "('(',i0,',',i0,')')"
232  character(len=*), parameter :: fmtndim3 = &
233  "('(',i0,',',i0,',',i0,')')"
234  !
235  cellstr = ''
236  !
237  select case (ndim)
238  case (1)
239  write (cellstr, fmtndim1) cellid(1)
240  case (2)
241  write (cellstr, fmtndim2) cellid(1), cellid(2)
242  case (3)
243  write (cellstr, fmtndim3) cellid(1), cellid(2), cellid(3)
244  case default
245  end select

◆ disconnex_da()

subroutine disconnexchangemodule::disconnex_da ( class(disconnexchangetype this)
private
Parameters
thisinstance of exchange object

Definition at line 475 of file DisConnExchange.f90.

476  ! -- modules
478  ! -- dummy
479  class(DisConnExchangeType) :: this !< instance of exchange object
480  !
481  ! arrays
482  call mem_deallocate(this%nodem1)
483  call mem_deallocate(this%nodem2)
484  call mem_deallocate(this%ihc)
485  call mem_deallocate(this%cl1)
486  call mem_deallocate(this%cl2)
487  call mem_deallocate(this%hwva)
488  call mem_deallocate(this%auxvar)
489  !
490  deallocate (this%boundname)
491  !
492  ! scalars
493  call mem_deallocate(this%nexg)
494  call mem_deallocate(this%naux)
495  call mem_deallocate(this%auxname, 'AUXNAME', this%memoryPath)
496  call mem_deallocate(this%auxname_cst, 'AUXNAME_CST', this%memoryPath)
497  call mem_deallocate(this%ianglex)
498  call mem_deallocate(this%icdist)
499  call mem_deallocate(this%ixt3d)
500  call mem_deallocate(this%iprpak)
501  call mem_deallocate(this%iprflow)
502  call mem_deallocate(this%ipakcb)
503  call mem_deallocate(this%inamedbound)
504  call mem_deallocate(this%dev_ifmod_on)

◆ getdisconnexchangefromlist()

class(disconnexchangetype) function, pointer, public disconnexchangemodule::getdisconnexchangefromlist ( type(listtype), intent(inout)  list,
integer(i4b), intent(in)  idx 
)

Definition at line 535 of file DisConnExchange.f90.

536  implicit none
537  ! -- dummy
538  type(ListType), intent(inout) :: list
539  integer(I4B), intent(in) :: idx
540  ! -- return
541  class(DisConnExchangeType), pointer :: res
542  ! -- local
543  class(*), pointer :: obj
544  !
545  obj => list%GetItem(idx)
546  res => castasdisconnexchangeclass(obj)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ noder()

integer(i4b) function disconnexchangemodule::noder ( class(disconnexchangetype this,
class(numericalmodeltype), intent(in), pointer  model,
integer(i4b), dimension(:), intent(in)  cellid,
integer(i4b), intent(in)  iout 
)
Parameters
thisinstance of exchange object
[in]ioutthe output file unit

Definition at line 193 of file DisConnExchange.f90.

194  ! -- modules
195  use geomutilmodule, only: get_node
196  ! -- dummy
197  class(DisConnExchangeType) :: this !< instance of exchange object
198  class(NumericalModelType), pointer, intent(in) :: model
199  integer(I4B), dimension(:), intent(in) :: cellid
200  integer(I4B), intent(in) :: iout !< the output file unit
201  integer(I4B) :: noder, node
202  !
203  if (model%dis%ndim == 1) then
204  node = cellid(1)
205  elseif (model%dis%ndim == 2) then
206  node = get_node(cellid(1), 1, cellid(2), &
207  model%dis%mshape(1), 1, &
208  model%dis%mshape(2))
209  else
210  node = get_node(cellid(1), cellid(2), cellid(3), &
211  model%dis%mshape(1), &
212  model%dis%mshape(2), &
213  model%dis%mshape(3))
214  end if
215  noder = model%dis%get_nodenumber(node, 0)
integer(i4b) function, public get_node(ilay, irow, icol, nlay, nrow, ncol)
Get node number, given layer, row, and column indices for a structured grid. If any argument is inval...
Definition: GeomUtil.f90:83
Here is the call graph for this function:

◆ source_data()

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

Definition at line 250 of file DisConnExchange.f90.

251  ! -- modules
253  ! -- dummy
254  class(DisConnExchangeType) :: this !< instance of exchange object
255  integer(I4B), intent(in) :: iout !< the output file unit
256  ! -- local
257  integer(I4B), dimension(:, :), contiguous, pointer :: cellidm1
258  integer(I4B), dimension(:, :), contiguous, pointer :: cellidm2
259  integer(I4B), dimension(:), contiguous, pointer :: ihc
260  real(DP), dimension(:), contiguous, pointer :: cl1
261  real(DP), dimension(:), contiguous, pointer :: cl2
262  real(DP), dimension(:), contiguous, pointer :: hwva
263  real(DP), dimension(:, :), contiguous, pointer :: auxvar
264  type(CharacterStringType), dimension(:), contiguous, pointer :: boundname
265  integer(I4B) :: ndim1, ndim2
266  character(len=20) :: cellstr1, cellstr2
267  character(len=2) :: cnfloat
268  integer(I4B) :: nerr, iaux
269  integer(I4B) :: iexg, nodem1, nodem2
270  ! -- format
271  character(len=*), parameter :: fmtexglabel = "(1x, 3a10, 50(a16))"
272  character(len=*), parameter :: fmtexgdata = &
273  "(5x, a, 1x, a ,I10, 50(1pg16.6))"
274  character(len=40) :: fmtexgdata2
275  !
276  call mem_setptr(cellidm1, 'CELLIDM1', this%input_mempath)
277  call mem_setptr(cellidm2, 'CELLIDM2', this%input_mempath)
278  call mem_setptr(ihc, 'IHC', this%input_mempath)
279  call mem_setptr(cl1, 'CL1', this%input_mempath)
280  call mem_setptr(cl2, 'CL2', this%input_mempath)
281  call mem_setptr(hwva, 'HWVA', this%input_mempath)
282  call mem_setptr(auxvar, 'AUXVAR', this%input_mempath)
283  call mem_setptr(boundname, 'BOUNDNAME', this%input_mempath)
284  ndim1 = size(cellidm1, dim=1)
285  ndim2 = size(cellidm2, dim=1)
286  !
287  write (iout, '(1x,a)') 'PROCESSING EXCHANGEDATA'
288  !
289  if (this%iprpak /= 0) then
290  if (this%inamedbound == 0) then
291  write (iout, fmtexglabel) 'NODEM1', 'NODEM2', 'IHC', &
292  'CL1', 'CL2', 'HWVA', (adjustr(this%auxname(iaux)), &
293  iaux=1, this%naux)
294  else
295  write (iout, fmtexglabel) 'NODEM1', 'NODEM2', 'IHC', 'CL1', 'CL2', &
296  'HWVA', (adjustr(this%auxname(iaux)), iaux=1, this%naux), &
297  ' BOUNDNAME '
298  ! Define format suitable for writing input data,
299  ! any auxiliary variables, and boundname.
300  write (cnfloat, '(i0)') 3 + this%naux
301  fmtexgdata2 = '(5x, a, 1x, a, i10, '//trim(cnfloat)// &
302  '(1pg16.6), 1x, a)'
303  end if
304  end if
305  !
306  do iexg = 1, this%nexg
307  !
308  if (associated(this%model1)) then
309  !
310  ! -- Determine reduced node number
311  nodem1 = this%noder(this%model1, cellidm1(:, iexg), iout)
312  this%nodem1(iexg) = nodem1
313  !
314  else
315  this%nodem1(iexg) = -1
316  end if
317  !
318  if (associated(this%model2)) then
319  !
320  ! -- Determine reduced node number
321  nodem2 = this%noder(this%model2, cellidm2(:, iexg), iout)
322  this%nodem2(iexg) = nodem2
323  !
324  else
325  this%nodem2(iexg) = -1
326  end if
327  !
328  ! -- Read rest of input line
329  this%ihc(iexg) = ihc(iexg)
330  this%cl1(iexg) = cl1(iexg)
331  this%cl2(iexg) = cl2(iexg)
332  this%hwva(iexg) = hwva(iexg)
333  do iaux = 1, this%naux
334  this%auxvar(iaux, iexg) = auxvar(iaux, iexg)
335  end do
336  if (this%inamedbound == 1) then
337  this%boundname(iexg) = boundname(iexg)
338  end if
339  !
340  ! -- Write the data to listing file if requested
341  if (this%iprpak /= 0) then
342  cellstr1 = this%cellstr(ndim1, cellidm1(:, iexg), iout)
343  cellstr2 = this%cellstr(ndim2, cellidm2(:, iexg), iout)
344  if (this%inamedbound == 0) then
345  write (iout, fmtexgdata) trim(cellstr1), trim(cellstr2), &
346  this%ihc(iexg), this%cl1(iexg), this%cl2(iexg), &
347  this%hwva(iexg), &
348  (this%auxvar(iaux, iexg), iaux=1, this%naux)
349  else
350  write (iout, fmtexgdata2) trim(cellstr1), trim(cellstr2), &
351  this%ihc(iexg), this%cl1(iexg), this%cl2(iexg), &
352  this%hwva(iexg), &
353  (this%auxvar(iaux, iexg), iaux=1, this%naux), &
354  trim(this%boundname(iexg))
355  end if
356  end if
357  !
358  ! -- Check to see if nodem1 is outside of active domain
359  if (associated(this%model1)) then
360  if (nodem1 <= 0) then
361  cellstr1 = this%cellstr(ndim1, cellidm1(:, iexg), iout)
362  write (errmsg, *) &
363  trim(adjustl(this%model1%name))// &
364  ' Cell is outside active grid domain ('// &
365  trim(adjustl(cellstr1))//').'
366  call store_error(errmsg)
367  end if
368  end if
369  !
370  ! -- Check to see if nodem2 is outside of active domain
371  if (associated(this%model2)) then
372  if (nodem2 <= 0) then
373  cellstr2 = this%cellstr(ndim2, cellidm2(:, iexg), iout)
374  write (errmsg, *) &
375  trim(adjustl(this%model2%name))// &
376  ' Cell is outside active grid domain ('// &
377  trim(adjustl(cellstr2))//').'
378  call store_error(errmsg)
379  end if
380  end if
381  end do
382  !
383  write (iout, '(1x,a)') 'END OF EXCHANGEDATA'
384  !
385  ! -- Stop if errors
386  nerr = count_errors()
387  if (nerr > 0) then
388  call store_error('Errors encountered in exchange input file.')
389  call store_error_filename(this%filename)
390  end if
Here is the call graph for this function:

◆ source_dimensions()

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

Definition at line 170 of file DisConnExchange.f90.

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

◆ source_options()

subroutine disconnexchangemodule::source_options ( class(disconnexchangetype this,
integer(i4b), intent(in)  iout 
)
private
Parameters
thisinstance of exchange object
[in]ioutfor logging

Definition at line 95 of file DisConnExchange.f90.

96  ! -- modules
98  use arrayhandlersmodule, only: ifind
99  ! -- dummy
100  class(DisConnExchangeType) :: this !< instance of exchange object
101  integer(I4B), intent(in) :: iout !< for logging
102  ! -- local
103  type(DisConnExchangeFoundType) :: found
104  integer(I4B) :: ival, n
105  !
106  ! -- update defaults with idm sourced values
107  call mem_set_value(this%naux, 'NAUX', this%input_mempath, found%naux)
108  call mem_set_value(this%ipakcb, 'IPAKCB', this%input_mempath, found%ipakcb)
109  call mem_set_value(this%iprpak, 'IPRPAK', this%input_mempath, found%iprpak)
110  call mem_set_value(this%iprflow, 'IPRFLOW', this%input_mempath, found%iprflow)
111  call mem_set_value(this%inamedbound, 'BOUNDNAMES', this%input_mempath, &
112  found%boundnames)
113  call mem_set_value(this%dev_ifmod_on, 'DEV_IFMOD_ON', this%input_mempath, &
114  found%dev_ifmod_on)
115  !
116  ! -- reallocate aux arrays if aux variables provided
117  if (found%naux .and. this%naux > 0) then
118  call mem_reallocate(this%auxname, lenauxname, this%naux, &
119  'AUXNAME', this%memoryPath)
120  call mem_reallocate(this%auxname_cst, lenauxname, this%naux, &
121  'AUXNAME_CST', this%memoryPath)
122  call mem_set_value(this%auxname_cst, 'AUXILIARY', this%input_mempath, &
123  found%auxiliary)
124  !
125  do n = 1, this%naux
126  this%auxname(n) = this%auxname_cst(n)
127  end do
128  !
129  ! -- If ANGLDEGX is an auxiliary variable, then anisotropy can be
130  ! used in either model. Store ANGLDEGX position in this%ianglex
131  ival = ifind(this%auxname, 'ANGLDEGX')
132  if (ival > 0) then
133  this%ianglex = ival
134  end if
135  !
136  ival = ifind(this%auxname, 'CDIST')
137  if (ival > 0) then
138  this%icdist = ival
139  end if
140  end if
141  !
142  if (found%ipakcb) then
143  this%ipakcb = -1
144  write (iout, '(4x,a)') &
145  'EXCHANGE FLOWS WILL BE SAVED TO BINARY BUDGET FILES.'
146  end if
147  !
148  if (found%iprpak) then
149  write (iout, '(4x,a)') &
150  'THE LIST OF EXCHANGES WILL BE PRINTED.'
151  end if
152  !
153  if (found%iprflow) then
154  write (iout, '(4x,a)') &
155  'EXCHANGE FLOWS WILL BE PRINTED TO LIST FILES.'
156  end if
157  !
158  if (found%boundnames) then
159  write (iout, '(4x,a)') 'EXCHANGE BOUNDARIES HAVE NAMES IN LAST COLUMN'
160  end if
161  !
162  if (found%dev_ifmod_on) then
163  write (iout, '(4x,2a)') 'Interface model coupling approach manually &
164  &activated for ', trim(this%name)
165  end if

◆ use_interface_model()

logical(lgp) function disconnexchangemodule::use_interface_model ( class(disconnexchangetype this)
private
Parameters
thisinstance of exchange object
Returns
flag whether interface model should be used for this exchange instead

Definition at line 462 of file DisConnExchange.f90.

463  ! -- dummy
464  class(DisConnExchangeType) :: this !< instance of exchange object
465  ! -- return
466  logical(LGP) :: use_im !< flag whether interface model should be used
467  !! for this exchange instead
468  !
469  ! use im when one of the models is not local
470  use_im = .not. (this%v_model1%is_local .and. this%v_model2%is_local)