MODFLOW 6  version 6.8.0.dev0
USGS Modular Hydrologic Model
gwegweexchangemodule Module Reference

This module contains the GweGweExchangeModule Module. More...

Data Types

type  gweexchangetype
 Derived type for GwtExchangeType. More...
 

Functions/Subroutines

subroutine, public gweexchange_create (filename, name, id, m1_id, m2_id, input_mempath)
 @ brief Create GWT GWT exchange More...
 
subroutine gwe_gwe_df (this)
 @ brief Define GWE GWE exchange More...
 
subroutine validate_exchange (this)
 validate exchange data after reading More...
 
subroutine gwe_gwe_ar (this)
 @ brief Allocate and read More...
 
subroutine gwe_gwe_rp (this)
 @ brief Read and prepare More...
 
subroutine gwe_gwe_ad (this)
 @ brief Advance More...
 
subroutine gwe_gwe_fc (this, kiter, matrix_sln, rhs_sln, inwtflag)
 @ brief Fill coefficients More...
 
subroutine gwe_gwe_bd (this, icnvg, isuppress_output, isolnid)
 @ brief Budget More...
 
subroutine gwe_gwe_bdsav (this)
 @ brief Budget save More...
 
subroutine gwe_gwe_bdsav_model (this, model)
 @ brief Budget save More...
 
subroutine gwe_gwe_ot (this)
 @ brief Output More...
 
subroutine source_options (this, iout)
 @ brief Source options More...
 
subroutine read_mvt (this, iout)
 @ brief Read mover More...
 
subroutine allocate_scalars (this)
 @ brief Allocate scalars More...
 
subroutine gwe_gwe_da (this)
 @ brief Deallocate More...
 
subroutine allocate_arrays (this)
 @ brief Allocate arrays More...
 
subroutine gwe_gwe_df_obs (this)
 @ brief Define observations More...
 
subroutine gwe_gwe_rp_obs (this)
 @ brief Read and prepare observations More...
 
subroutine gwe_gwe_fp (this)
 @ brief Final processing More...
 
logical(lgp) function gwe_gwe_connects_model (this, model)
 Return true when this exchange provides matrix coefficients for solving. More...
 
logical(lgp) function use_interface_model (this)
 Should interface model be used for this exchange. More...
 
subroutine gwe_gwe_save_simvals (this)
 @ brief Save simulated flow observations More...
 
subroutine gwe_gwe_process_obsid (obsrv, dis, inunitobs, iout)
 @ brief Obs ID processor More...
 
class(gweexchangetype) function, pointer, public castasgweexchange (obj)
 @ brief Cast polymorphic object as exchange More...
 
class(gweexchangetype) function, pointer, public getgweexchangefromlist (list, idx)
 @ brief Get exchange from list More...
 

Detailed Description

This module contains the code for connecting two GWE Models. The methods are based on the simple two point flux approximation with the option to use ghost nodes to improve accuracy. This exchange is used by GweGweConnection with the more sophisticated interface model coupling approach when XT3D is needed.

Function/Subroutine Documentation

◆ allocate_arrays()

subroutine gwegweexchangemodule::allocate_arrays ( class(gweexchangetype this)

Allocate arrays

Parameters
thisGweExchangeType

Definition at line 857 of file exg-gwegwe.f90.

858  ! -- modules
860  ! -- dummy
861  class(GweExchangeType) :: this !< GweExchangeType
862  ! -- local
863  character(len=LINELENGTH) :: text
864  integer(I4B) :: ntabcol, i
865  !
866  call this%DisConnExchangeType%allocate_arrays()
867  !
868  call mem_allocate(this%cond, this%nexg, 'COND', this%memoryPath)
869  call mem_allocate(this%simvals, this%nexg, 'SIMVALS', this%memoryPath)
870  !
871  ! -- Initialize
872  do i = 1, this%nexg
873  this%cond(i) = dnodata
874  end do
875  !
876  ! -- allocate and initialize the output table
877  if (this%iprflow /= 0) then
878  !
879  ! -- dimension table
880  ntabcol = 3
881  if (this%inamedbound > 0) then
882  ntabcol = ntabcol + 1
883  end if
884  !
885  ! -- initialize the output table objects
886  ! outouttab1
887  if (this%v_model1%is_local) then
888  call table_cr(this%outputtab1, this%name, ' ')
889  call this%outputtab1%table_df(this%nexg, ntabcol, this%gwemodel1%iout, &
890  transient=.true.)
891  text = 'NUMBER'
892  call this%outputtab1%initialize_column(text, 10, alignment=tabcenter)
893  text = 'CELLID'
894  call this%outputtab1%initialize_column(text, 20, alignment=tableft)
895  text = 'RATE'
896  call this%outputtab1%initialize_column(text, 15, alignment=tabcenter)
897  if (this%inamedbound > 0) then
898  text = 'NAME'
899  call this%outputtab1%initialize_column(text, 20, alignment=tableft)
900  end if
901  end if
902  ! outouttab2
903  if (this%v_model2%is_local) then
904  call table_cr(this%outputtab2, this%name, ' ')
905  call this%outputtab2%table_df(this%nexg, ntabcol, this%gwemodel2%iout, &
906  transient=.true.)
907  text = 'NUMBER'
908  call this%outputtab2%initialize_column(text, 10, alignment=tabcenter)
909  text = 'CELLID'
910  call this%outputtab2%initialize_column(text, 20, alignment=tableft)
911  text = 'RATE'
912  call this%outputtab2%initialize_column(text, 15, alignment=tabcenter)
913  if (this%inamedbound > 0) then
914  text = 'NAME'
915  call this%outputtab2%initialize_column(text, 20, alignment=tableft)
916  end if
917  end if
918  end if
Here is the call graph for this function:

◆ allocate_scalars()

subroutine gwegweexchangemodule::allocate_scalars ( class(gweexchangetype this)

Allocate scalar variables

Parameters
thisGwtExchangeType

Definition at line 787 of file exg-gwegwe.f90.

788  ! -- modules
790  use constantsmodule, only: dzero
791  ! -- dummy
792  class(GweExchangeType) :: this !< GwtExchangeType
793  !
794  call this%DisConnExchangeType%allocate_scalars()
795  !
796  call mem_allocate(this%inewton, 'INEWTON', this%memoryPath)
797  call mem_allocate(this%inobs, 'INOBS', this%memoryPath)
798  call mem_allocate(this%iAdvScheme, 'IADVSCHEME', this%memoryPath)
799  this%inewton = 0
800  this%inobs = 0
801  this%iAdvScheme = 0
802  !
803  call mem_allocate(this%inmvt, 'INMVT', this%memoryPath)
804  this%inmvt = 0
This module contains simulation constants.
Definition: Constants.f90:9
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:65

◆ castasgweexchange()

class(gweexchangetype) function, pointer, public gwegweexchangemodule::castasgweexchange ( class(*), intent(inout), pointer  obj)

Cast polymorphic object as exchange

Definition at line 1146 of file exg-gwegwe.f90.

1147  implicit none
1148  ! -- dummy
1149  class(*), pointer, intent(inout) :: obj
1150  ! -- return
1151  class(GweExchangeType), pointer :: res
1152  !
1153  res => null()
1154  if (.not. associated(obj)) return
1155  !
1156  select type (obj)
1157  class is (gweexchangetype)
1158  res => obj
1159  end select
Here is the caller graph for this function:

◆ getgweexchangefromlist()

class(gweexchangetype) function, pointer, public gwegweexchangemodule::getgweexchangefromlist ( type(listtype), intent(inout)  list,
integer(i4b), intent(in)  idx 
)

Return an exchange from the list for specified index

Definition at line 1166 of file exg-gwegwe.f90.

1167  implicit none
1168  ! -- dummy
1169  type(ListType), intent(inout) :: list
1170  integer(I4B), intent(in) :: idx
1171  ! -- return
1172  class(GweExchangeType), pointer :: res
1173  ! -- local
1174  class(*), pointer :: obj
1175  !
1176  obj => list%GetItem(idx)
1177  res => castasgweexchange(obj)
Here is the call graph for this function:

◆ gwe_gwe_ad()

subroutine gwegweexchangemodule::gwe_gwe_ad ( class(gweexchangetype this)

Advance mover and obs

Parameters
thisGweExchangeType

Definition at line 344 of file exg-gwegwe.f90.

345  ! -- dummy
346  class(GweExchangeType) :: this !< GweExchangeType
347  !
348  ! -- Advance mover
349  !if(this%inmvt > 0) call this%mvt%mvt_ad()
350  !
351  ! -- Push simulated values to preceding time step
352  call this%obs%obs_ad()

◆ gwe_gwe_ar()

subroutine gwegweexchangemodule::gwe_gwe_ar ( class(gweexchangetype this)
private

Allocated and read and calculate saturated conductance

Parameters
thisGwtExchangeType

Definition at line 309 of file exg-gwegwe.f90.

310  ! -- dummy
311  class(GweExchangeType) :: this !< GwtExchangeType
312  !
313  ! -- If mover is active, then call ar routine
314  if (this%inmvt > 0) call this%mvt%mvt_ar()
315  !
316  ! -- Observation AR
317  call this%obs%obs_ar()

◆ gwe_gwe_bd()

subroutine gwegweexchangemodule::gwe_gwe_bd ( class(gweexchangetype this,
integer(i4b), intent(inout)  icnvg,
integer(i4b), intent(in)  isuppress_output,
integer(i4b), intent(in)  isolnid 
)
private

Accumulate budget terms

Parameters
thisGweExchangeType

Definition at line 375 of file exg-gwegwe.f90.

376  ! -- modules
378  use budgetmodule, only: rate_accumulator
379  ! -- dummy
380  class(GweExchangeType) :: this !< GweExchangeType
381  integer(I4B), intent(inout) :: icnvg
382  integer(I4B), intent(in) :: isuppress_output
383  integer(I4B), intent(in) :: isolnid
384  ! -- local
385  character(len=LENBUDTXT), dimension(1) :: budtxt
386  real(DP), dimension(2, 1) :: budterm
387  real(DP) :: ratin, ratout
388  !
389  ! -- initialize
390  budtxt(1) = ' FLOW-JA-FACE'
391  !
392  ! -- Calculate ratin/ratout and pass to model budgets
393  call rate_accumulator(this%simvals, ratin, ratout)
394  !
395  ! -- Add the budget terms to model 1
396  if (associated(this%gwemodel1)) then
397  budterm(1, 1) = ratin
398  budterm(2, 1) = ratout
399  call this%gwemodel1%model_bdentry(budterm, budtxt, this%name)
400  end if
401  !
402  ! -- Add the budget terms to model 2
403  if (associated(this%gwemodel2)) then
404  budterm(1, 1) = ratout
405  budterm(2, 1) = ratin
406  call this%gwemodel2%model_bdentry(budterm, budtxt, this%name)
407  end if
408  !
409  ! -- Call mvt bd routine
410  if (this%inmvt > 0) call this%mvt%mvt_bd(this%gwemodel1%x, this%gwemodel2%x)
This module contains the BudgetModule.
Definition: Budget.f90:20
subroutine, public rate_accumulator(flow, rin, rout)
@ brief Rate accumulator subroutine
Definition: Budget.f90:632
integer(i4b), parameter lenpackagename
maximum length of the package name
Definition: Constants.f90:23
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
Definition: Constants.f90:37
Here is the call graph for this function:

◆ gwe_gwe_bdsav()

subroutine gwegweexchangemodule::gwe_gwe_bdsav ( class(gweexchangetype this)

Output individual flows to listing file and binary budget files

Parameters
thisGweExchangeType

Definition at line 417 of file exg-gwegwe.f90.

418  ! -- dummy
419  class(GweExchangeType) :: this !< GweExchangeType
420  ! -- local
421  integer(I4B) :: icbcfl, ibudfl
422  !
423  ! -- budget for model1
424  if (associated(this%gwemodel1)) then
425  call this%gwe_gwe_bdsav_model(this%gwemodel1)
426  end if
427  !
428  ! -- budget for model2
429  if (associated(this%gwemodel2)) then
430  call this%gwe_gwe_bdsav_model(this%gwemodel2)
431  end if
432  !
433  ! -- Set icbcfl, ibudfl to zero so that flows will be printed and
434  ! saved, if the options were set in the MVT package
435  icbcfl = 1
436  ibudfl = 1
437  !
438  ! -- Call mvt bd routine
439  !cdl todo: if(this%inmvt > 0) call this%mvt%mvt_bdsav(icbcfl, ibudfl, isuppress_output)
440  !
441  ! -- Calculate and write simulated values for observations
442  if (this%inobs /= 0) then
443  call this%gwe_gwe_save_simvals()
444  end if

◆ gwe_gwe_bdsav_model()

subroutine gwegweexchangemodule::gwe_gwe_bdsav_model ( class(gweexchangetype this,
class(gwemodeltype), pointer  model 
)
private

Output individual flows to listing file and binary budget files

Parameters
thisGwtExchangeType

Definition at line 451 of file exg-gwegwe.f90.

452  ! -- modules
454  use tdismodule, only: kstp, kper
455  ! -- dummy
456  class(GweExchangeType) :: this !< GwtExchangeType
457  class(GweModelType), pointer :: model
458  ! -- local
459  character(len=LENBOUNDNAME) :: bname
460  character(len=LENPACKAGENAME + 4) :: packname
461  character(len=LENBUDTXT), dimension(1) :: budtxt
462  type(TableType), pointer :: output_tab
463  class(VirtualModelType), pointer :: nbr_model
464  character(len=20) :: nodestr
465  integer(I4B) :: ntabrows
466  integer(I4B) :: nodeu
467  integer(I4B) :: i, n1, n2, n1u, n2u
468  integer(I4B) :: ibinun
469  real(DP) :: ratin, ratout, rrate
470  logical(LGP) :: is_for_model1
471  integer(I4B) :: isuppress_output
472  real(DP), dimension(this%naux) :: auxrow
473  !
474  ! -- initialize local variables
475  isuppress_output = 0
476  budtxt(1) = ' FLOW-JA-FACE'
477  packname = 'EXG '//this%name
478  packname = adjustr(packname)
479  if (associated(model, this%gwemodel1)) then
480  output_tab => this%outputtab1
481  nbr_model => this%v_model2
482  is_for_model1 = .true.
483  else
484  output_tab => this%outputtab2
485  nbr_model => this%v_model1
486  is_for_model1 = .false.
487  end if
488  !
489  ! -- update output tables
490  if (this%iprflow /= 0) then
491  !
492  ! -- update titles
493  if (model%oc%oc_save('BUDGET')) then
494  call output_tab%set_title(packname)
495  end if
496  !
497  ! -- set table kstp and kper
498  call output_tab%set_kstpkper(kstp, kper)
499  !
500  ! -- update maxbound of tables
501  ntabrows = 0
502  do i = 1, this%nexg
503  n1 = this%nodem1(i)
504  n2 = this%nodem2(i)
505  !
506  ! -- If both cells are active then calculate flow rate
507  if (this%v_model1%ibound%get(n1) /= 0 .and. &
508  this%v_model2%ibound%get(n2) /= 0) then
509  ntabrows = ntabrows + 1
510  end if
511  end do
512  if (ntabrows > 0) then
513  call output_tab%set_maxbound(ntabrows)
514  end if
515  end if
516  !
517  ! -- Print and write budget terms for model 1
518  !
519  ! -- Set binary unit numbers for saving flows
520  if (this%ipakcb /= 0) then
521  ibinun = model%oc%oc_save_unit('BUDGET')
522  else
523  ibinun = 0
524  end if
525  !
526  ! -- If save budget flag is zero for this stress period, then
527  ! shut off saving
528  if (.not. model%oc%oc_save('BUDGET')) ibinun = 0
529  if (isuppress_output /= 0) then
530  ibinun = 0
531  end if
532  !
533  ! -- If cell-by-cell flows will be saved as a list, write header.
534  if (ibinun /= 0) then
535  call model%dis%record_srcdst_list_header(budtxt(1), &
536  model%name, &
537  this%name, &
538  nbr_model%name, &
539  this%name, &
540  this%naux, this%auxname, &
541  ibinun, this%nexg, &
542  model%iout)
543  end if
544  !
545  ! Initialize accumulators
546  ratin = dzero
547  ratout = dzero
548  !
549  ! -- Loop through all exchanges
550  do i = 1, this%nexg
551  !
552  ! -- Assign boundary name
553  if (this%inamedbound > 0) then
554  bname = this%boundname(i)
555  else
556  bname = ''
557  end if
558  !
559  ! -- Calculate the flow rate between n1 and n2
560  rrate = dzero
561  n1 = this%nodem1(i)
562  n2 = this%nodem2(i)
563  !
564  ! -- If both cells are active then calculate flow rate
565  if (this%v_model1%ibound%get(n1) /= 0 .and. &
566  this%v_model2%ibound%get(n2) /= 0) then
567  rrate = this%simvals(i)
568  !
569  ! -- Print the individual rates to model list files if requested
570  if (this%iprflow /= 0) then
571  if (model%oc%oc_save('BUDGET')) then
572  !
573  ! -- set nodestr and write outputtab table
574  if (is_for_model1) then
575  nodeu = model%dis%get_nodeuser(n1)
576  call model%dis%nodeu_to_string(nodeu, nodestr)
577  call output_tab%print_list_entry(i, trim(adjustl(nodestr)), &
578  rrate, bname)
579  else
580  nodeu = model%dis%get_nodeuser(n2)
581  call model%dis%nodeu_to_string(nodeu, nodestr)
582  call output_tab%print_list_entry(i, trim(adjustl(nodestr)), &
583  -rrate, bname)
584  end if
585  end if
586  end if
587  if (rrate < dzero) then
588  ratout = ratout - rrate
589  else
590  ratin = ratin + rrate
591  end if
592  end if
593  !
594  ! -- If saving cell-by-cell flows in list, write flow
595  n1u = this%v_model1%dis_get_nodeuser(n1)
596  n2u = this%v_model2%dis_get_nodeuser(n2)
597  if (ibinun /= 0) then
598  if (this%naux > 0) then
599  auxrow(:) = this%auxvar(:, i)
600  end if
601  if (is_for_model1) then
602  call model%dis%record_mf6_list_entry( &
603  ibinun, n1u, n2u, rrate, this%naux, auxrow, &
604  .false., .false.)
605  else
606  call model%dis%record_mf6_list_entry( &
607  ibinun, n2u, n1u, -rrate, this%naux, auxrow, &
608  .false., .false.)
609  end if
610  end if
611  !
612  end do
integer(i4b), pointer, public kstp
current time step number
Definition: tdis.f90:24
integer(i4b), pointer, public kper
current stress period number
Definition: tdis.f90:23

◆ gwe_gwe_connects_model()

logical(lgp) function gwegweexchangemodule::gwe_gwe_connects_model ( class(gweexchangetype this,
class(basemodeltype), intent(in), pointer  model 
)
private
Parameters
model
thisGweExchangeType
[in]modelthe model to which the exchange might hold a connection
Returns
true, when connected

Definition at line 1020 of file exg-gwegwe.f90.

1021  ! -- dummy
1022  class(GweExchangeType) :: this !< GweExchangeType
1023  class(BaseModelType), pointer, intent(in) :: model !< the model to which the exchange might hold a connection
1024  ! -- return
1025  logical(LGP) :: is_connected !< true, when connected
1026  !
1027  is_connected = .false.
1028  !
1029  ! only connected when model is GwtModelType of course
1030  select type (model)
1031  class is (gwemodeltype)
1032  if (associated(this%gwemodel1, model)) then
1033  is_connected = .true.
1034  else if (associated(this%gwemodel2, model)) then
1035  is_connected = .true.
1036  end if
1037  end select

◆ gwe_gwe_da()

subroutine gwegweexchangemodule::gwe_gwe_da ( class(gweexchangetype this)

Deallocate memory associated with this object

Parameters
thisGwtExchangeType

Definition at line 811 of file exg-gwegwe.f90.

812  ! -- modules
814  ! -- dummy
815  class(GweExchangeType) :: this !< GwtExchangeType
816  !
817  ! -- objects
818  if (this%inmvt > 0) then
819  call this%mvt%mvt_da()
820  deallocate (this%mvt)
821  end if
822  call this%obs%obs_da()
823  deallocate (this%obs)
824  !
825  ! -- arrays
826  call mem_deallocate(this%cond)
827  call mem_deallocate(this%simvals)
828  call mem_deallocate(this%gwfsimvals, 'GWFSIMVALS', this%memoryPath) ! linked memory
829  !
830  ! -- output table objects
831  if (associated(this%outputtab1)) then
832  call this%outputtab1%table_da()
833  deallocate (this%outputtab1)
834  nullify (this%outputtab1)
835  end if
836  if (associated(this%outputtab2)) then
837  call this%outputtab2%table_da()
838  deallocate (this%outputtab2)
839  nullify (this%outputtab2)
840  end if
841  !
842  ! -- scalars
843  deallocate (this%filename)
844  call mem_deallocate(this%inewton)
845  call mem_deallocate(this%inobs)
846  call mem_deallocate(this%iAdvScheme)
847  call mem_deallocate(this%inmvt)
848  !
849  ! -- deallocate base
850  call this%DisConnExchangeType%disconnex_da()

◆ gwe_gwe_df()

subroutine gwegweexchangemodule::gwe_gwe_df ( class(gweexchangetype this)

Define GWE to GWE exchange object.

Parameters
thisGwtExchangeType

Definition at line 196 of file exg-gwegwe.f90.

197  ! -- modules
198  use simvariablesmodule, only: iout
200  use ghostnodemodule, only: gnc_cr
201  ! -- dummy
202  class(GweExchangeType) :: this !< GwtExchangeType
203  !
204  ! -- log the exchange
205  write (iout, '(/a,a)') ' Creating exchange: ', this%name
206  !
207  ! -- Ensure models are in same solution
208  if (associated(this%gwemodel1) .and. associated(this%gwemodel2)) then
209  if (this%gwemodel1%idsoln /= this%gwemodel2%idsoln) then
210  call store_error('Two models are connect in a GWE '// &
211  'exchange but they are in different solutions. '// &
212  'GWE models must be in same solution: '// &
213  trim(this%gwemodel1%name)//' '// &
214  trim(this%gwemodel2%name))
215  call store_error_filename(this%filename)
216  end if
217  end if
218  !
219  ! -- source options
220  call this%source_options(iout)
221  !
222  ! -- source dimensions
223  call this%source_dimensions(iout)
224  !
225  ! -- allocate arrays
226  call this%allocate_arrays()
227  !
228  ! -- source exchange data
229  call this%source_data(iout)
230  !
231  ! -- Read mover information
232  if (this%inmvt > 0) then
233  call this%read_mvt(iout)
234  call this%mvt%mvt_df(this%gwemodel1%dis)
235  end if
236  !
237  ! -- Store obs
238  call this%gwe_gwe_df_obs()
239  if (associated(this%gwemodel1)) then
240  call this%obs%obs_df(iout, this%name, 'GWE-GWE', this%gwemodel1%dis)
241  end if
242  !
243  ! -- validate
244  call this%validate_exchange()
subroutine, public gnc_cr(gncobj, name_parent, inunit, iout)
Create new GNC exchange object.
Definition: GhostNode.f90:61
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 simulation variables.
Definition: SimVariables.f90:9
integer(i4b) iout
file unit number for simulation output
Here is the call graph for this function:

◆ gwe_gwe_df_obs()

subroutine gwegweexchangemodule::gwe_gwe_df_obs ( class(gweexchangetype this)

Define the observations associated with this object

Parameters
thisGweExchangeType

Definition at line 925 of file exg-gwegwe.f90.

926  ! -- dummy
927  class(GweExchangeType) :: this !< GweExchangeType
928  ! -- local
929  integer(I4B) :: indx
930  !
931  ! -- Store obs type and assign procedure pointer
932  ! for gwt-gwt observation type.
933  call this%obs%StoreObsType('flow-ja-face', .true., indx)
934  this%obs%obsData(indx)%ProcessIdPtr => gwe_gwe_process_obsid
Here is the call graph for this function:

◆ gwe_gwe_fc()

subroutine gwegweexchangemodule::gwe_gwe_fc ( class(gweexchangetype this,
integer(i4b), intent(in)  kiter,
class(matrixbasetype), pointer  matrix_sln,
real(dp), dimension(:), intent(inout)  rhs_sln,
integer(i4b), intent(in), optional  inwtflag 
)
private

Calculate conductance and fill coefficient matrix

Parameters
thisGwtExchangeType

Definition at line 359 of file exg-gwegwe.f90.

360  ! -- dummy
361  class(GweExchangeType) :: this !< GwtExchangeType
362  integer(I4B), intent(in) :: kiter
363  class(MatrixBaseType), pointer :: matrix_sln
364  real(DP), dimension(:), intent(inout) :: rhs_sln
365  integer(I4B), optional, intent(in) :: inwtflag
366  !
367  ! -- Call mvt fc routine
368  if (this%inmvt > 0) call this%mvt%mvt_fc(this%gwemodel1%x, this%gwemodel2%x)

◆ gwe_gwe_fp()

subroutine gwegweexchangemodule::gwe_gwe_fp ( class(gweexchangetype this)

Conduct any final processing

Parameters
thisGwtExchangeType

Definition at line 1012 of file exg-gwegwe.f90.

1013  ! -- dummy
1014  class(GweExchangeType) :: this !< GwtExchangeType

◆ gwe_gwe_ot()

subroutine gwegweexchangemodule::gwe_gwe_ot ( class(gweexchangetype this)

Write output

Parameters
thisGweExchangeType

Definition at line 619 of file exg-gwegwe.f90.

620  ! -- modules
621  use simvariablesmodule, only: iout
622  use constantsmodule, only: dzero
623  ! -- dummy
624  class(GweExchangeType) :: this !< GweExchangeType
625  ! -- local
626  integer(I4B) :: iexg, n1, n2
627  integer(I4B) :: ibudfl
628  real(DP) :: flow
629  character(len=LINELENGTH) :: node1str, node2str
630  ! -- format
631  character(len=*), parameter :: fmtheader = &
632  "(/1x, 'SUMMARY OF EXCHANGE RATES FOR EXCHANGE ', a, ' WITH ID ', i0, /, &
633  &2a16, 5a16, /, 112('-'))"
634  character(len=*), parameter :: fmtheader2 = &
635  "(/1x, 'SUMMARY OF EXCHANGE RATES FOR EXCHANGE ', a, ' WITH ID ', i0, /, &
636  &2a16, 4a16, /, 96('-'))"
637  character(len=*), parameter :: fmtdata = &
638  "(2a16, 5(1pg16.6))"
639  !
640  ! -- Call bdsave
641  call this%gwe_gwe_bdsav()
642  !
643  ! -- Write a table of exchanges
644  if (this%iprflow /= 0) then
645  write (iout, fmtheader2) trim(adjustl(this%name)), this%id, 'NODEM1', &
646  'NODEM2', 'COND', 'X_M1', 'X_M2', 'FLOW'
647  do iexg = 1, this%nexg
648  n1 = this%nodem1(iexg)
649  n2 = this%nodem2(iexg)
650  flow = this%simvals(iexg)
651  call this%v_model1%dis_noder_to_string(n1, node1str)
652  call this%v_model2%dis_noder_to_string(n2, node2str)
653  write (iout, fmtdata) trim(adjustl(node1str)), &
654  trim(adjustl(node2str)), &
655  this%cond(iexg), this%v_model1%x%get(n1), &
656  this%v_model2%x%get(n2), flow
657  end do
658  end if
659  !
660  !cdl Implement when MVT is ready
661  ! -- Mover budget output
662  ibudfl = 1
663  if (this%inmvt > 0) call this%mvt%mvt_ot_bdsummary(ibudfl)
664  !
665  ! -- OBS output
666  call this%obs%obs_ot()

◆ gwe_gwe_process_obsid()

subroutine gwegweexchangemodule::gwe_gwe_process_obsid ( type(observetype), intent(inout)  obsrv,
class(disbasetype), intent(in)  dis,
integer(i4b), intent(in)  inunitobs,
integer(i4b), intent(in)  iout 
)

Process observations for this exchange

Definition at line 1107 of file exg-gwegwe.f90.

1108  ! -- modules
1109  use constantsmodule, only: linelength
1110  use inputoutputmodule, only: urword
1111  use observemodule, only: observetype
1112  use basedismodule, only: disbasetype
1113  ! -- dummy
1114  type(ObserveType), intent(inout) :: obsrv
1115  class(DisBaseType), intent(in) :: dis
1116  integer(I4B), intent(in) :: inunitobs
1117  integer(I4B), intent(in) :: iout
1118  ! -- local
1119  integer(I4B) :: n, iexg, istat
1120  integer(I4B) :: icol, istart, istop
1121  real(DP) :: r
1122  character(len=LINELENGTH) :: string
1123  !
1124  string = obsrv%IDstring
1125  icol = 1
1126  ! -- get exchange index
1127  call urword(string, icol, istart, istop, 1, n, r, iout, inunitobs)
1128  read (string(istart:istop), '(i10)', iostat=istat) iexg
1129  if (istat == 0) then
1130  obsrv%intPak1 = iexg
1131  else
1132  ! Integer can't be read from string; it's presumed to be an exchange
1133  ! boundary name (already converted to uppercase)
1134  obsrv%FeatureName = trim(adjustl(string))
1135  ! -- Observation may require summing rates from multiple exchange
1136  ! boundaries, so assign intPak1 as a value that indicates observation
1137  ! is for a named exchange boundary or group of exchange boundaries.
1138  obsrv%intPak1 = namedboundflag
1139  end if
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:45
subroutine, public urword(line, icol, istart, istop, ncode, n, r, iout, in)
Extract a word from a string.
This module contains the derived types ObserveType and ObsDataType.
Definition: Observe.f90:15
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gwe_gwe_rp()

subroutine gwegweexchangemodule::gwe_gwe_rp ( class(gweexchangetype this)
private

Read new data for mover and obs

Parameters
thisGweExchangeType

Definition at line 324 of file exg-gwegwe.f90.

325  ! -- modules
326  use tdismodule, only: readnewdata
327  ! -- dummy
328  class(GweExchangeType) :: this !< GweExchangeType
329  !
330  ! -- Check with TDIS on whether or not it is time to RP
331  if (.not. readnewdata) return
332  !
333  ! -- Read and prepare for mover
334  if (this%inmvt > 0) call this%mvt%mvt_rp()
335  !
336  ! -- Read and prepare for observations
337  call this%gwe_gwe_rp_obs()
logical(lgp), pointer, public readnewdata
flag indicating time to read new data
Definition: tdis.f90:26

◆ gwe_gwe_rp_obs()

subroutine gwegweexchangemodule::gwe_gwe_rp_obs ( class(gweexchangetype this)
private

Handle observation exchanges exchange-boundary names.

Parameters
thisGwtExchangeType

Definition at line 941 of file exg-gwegwe.f90.

942  ! -- modules
943  use constantsmodule, only: dzero
944  ! -- dummy
945  class(GweExchangeType) :: this !< GwtExchangeType
946  ! -- local
947  integer(I4B) :: i
948  integer(I4B) :: j
949  class(ObserveType), pointer :: obsrv => null()
950  character(len=LENBOUNDNAME) :: bname
951  logical :: jfound
952  ! -- formats
953 10 format('Exchange "', a, '" for observation "', a, &
954  '" is invalid in package "', a, '"')
955 20 format('Exchange id "', i0, '" for observation "', a, &
956  '" is invalid in package "', a, '"')
957  !
958  do i = 1, this%obs%npakobs
959  obsrv => this%obs%pakobs(i)%obsrv
960  !
961  ! -- indxbnds needs to be reset each stress period because
962  ! list of boundaries can change each stress period.
963  ! -- Not true for exchanges, but leave this in for now anyway.
964  call obsrv%ResetObsIndex()
965  obsrv%BndFound = .false.
966  !
967  bname = obsrv%FeatureName
968  if (bname /= '') then
969  ! -- Observation location(s) is(are) based on a boundary name.
970  ! Iterate through all boundaries to identify and store
971  ! corresponding index(indices) in bound array.
972  jfound = .false.
973  do j = 1, this%nexg
974  if (this%boundname(j) == bname) then
975  jfound = .true.
976  obsrv%BndFound = .true.
977  obsrv%CurrentTimeStepEndValue = dzero
978  call obsrv%AddObsIndex(j)
979  end if
980  end do
981  if (.not. jfound) then
982  write (errmsg, 10) trim(bname), trim(obsrv%ObsTypeId), trim(this%name)
983  call store_error(errmsg)
984  end if
985  else
986  ! -- Observation location is a single exchange number
987  if (obsrv%intPak1 <= this%nexg .and. obsrv%intPak1 > 0) then
988  jfound = .true.
989  obsrv%BndFound = .true.
990  obsrv%CurrentTimeStepEndValue = dzero
991  call obsrv%AddObsIndex(obsrv%intPak1)
992  else
993  jfound = .false.
994  end if
995  if (.not. jfound) then
996  write (errmsg, 20) obsrv%intPak1, trim(obsrv%ObsTypeId), trim(this%name)
997  call store_error(errmsg)
998  end if
999  end if
1000  end do
1001  !
1002  ! -- write summary of error messages
1003  if (count_errors() > 0) then
1004  call store_error_filename(this%obs%inputFilename)
1005  end if
Here is the call graph for this function:

◆ gwe_gwe_save_simvals()

subroutine gwegweexchangemodule::gwe_gwe_save_simvals ( class(gweexchangetype), intent(inout)  this)
private

Save the simulated flows for each exchange

Definition at line 1063 of file exg-gwegwe.f90.

1064  ! -- dummy
1065  use simvariablesmodule, only: errmsg
1066  use constantsmodule, only: dzero
1067  use observemodule, only: observetype
1068  class(GweExchangeType), intent(inout) :: this
1069  ! -- local
1070  integer(I4B) :: i
1071  integer(I4B) :: j
1072  integer(I4B) :: n1
1073  integer(I4B) :: n2
1074  integer(I4B) :: iexg
1075  real(DP) :: v
1076  type(ObserveType), pointer :: obsrv => null()
1077  !
1078  ! -- Write simulated values for all gwt-gwt observations
1079  if (this%obs%npakobs > 0) then
1080  call this%obs%obs_bd_clear()
1081  do i = 1, this%obs%npakobs
1082  obsrv => this%obs%pakobs(i)%obsrv
1083  do j = 1, obsrv%indxbnds_count
1084  iexg = obsrv%indxbnds(j)
1085  v = dzero
1086  select case (obsrv%ObsTypeId)
1087  case ('FLOW-JA-FACE')
1088  n1 = this%nodem1(iexg)
1089  n2 = this%nodem2(iexg)
1090  v = this%simvals(iexg)
1091  case default
1092  errmsg = 'Unrecognized observation type: '// &
1093  trim(obsrv%ObsTypeId)
1094  call store_error(errmsg)
1095  call store_error_filename(this%obs%inputFilename)
1096  end select
1097  call this%obs%SaveOneSimval(obsrv, v)
1098  end do
1099  end do
1100  end if
character(len=maxcharlen) errmsg
error message string
Here is the call graph for this function:

◆ gweexchange_create()

subroutine, public gwegweexchangemodule::gweexchange_create ( 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 
)

Create a new GWT to GWT exchange object.

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

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

112  ! -- modules
113  use basemodelmodule, only: basemodeltype
114  use listsmodule, only: baseexchangelist
115  use obsmodule, only: obs_cr
117  ! -- dummy
118  character(len=*), intent(in) :: filename !< filename for reading
119  integer(I4B), intent(in) :: id !< id for the exchange
120  character(len=*) :: name !< the exchange name
121  integer(I4B), intent(in) :: m1_id !< id for model 1
122  integer(I4B), intent(in) :: m2_id !< id for model 2
123  character(len=*), intent(in) :: input_mempath
124  ! -- local
125  type(GweExchangeType), pointer :: exchange
126  class(BaseModelType), pointer :: mb
127  class(BaseExchangeType), pointer :: baseexchange
128  integer(I4B) :: m1_index, m2_index
129  !
130  ! -- Create a new exchange and add it to the baseexchangelist container
131  allocate (exchange)
132  baseexchange => exchange
133  call addbaseexchangetolist(baseexchangelist, baseexchange)
134  !
135  ! -- Assign id and name
136  exchange%id = id
137  exchange%name = name
138  exchange%memoryPath = create_mem_path(exchange%name)
139  exchange%input_mempath = input_mempath
140  !
141  ! -- allocate scalars and set defaults
142  call exchange%allocate_scalars()
143  exchange%filename = filename
144  exchange%typename = 'GWE-GWE'
145  exchange%iAdvScheme = adv_scheme_upstream
146  exchange%ixt3d = 1
147  !
148  ! -- set gwemodel1
149  m1_index = model_loc_idx(m1_id)
150  mb => getbasemodelfromlist(basemodellist, m1_index)
151  if (m1_index > 0) then
152  select type (mb)
153  type is (gwemodeltype)
154  exchange%model1 => mb
155  exchange%gwemodel1 => mb
156  end select
157  end if
158  exchange%v_model1 => get_virtual_model(m1_id)
159  !
160  ! -- set gwemodel2
161  m2_index = model_loc_idx(m2_id)
162  if (m2_index > 0) then
163  mb => getbasemodelfromlist(basemodellist, m2_index)
164  select type (mb)
165  type is (gwemodeltype)
166  exchange%model2 => mb
167  exchange%gwemodel2 => mb
168  end select
169  end if
170  exchange%v_model2 => get_virtual_model(m2_id)
171  !
172  ! -- Verify that gwt model1 is of the correct type
173  if (.not. associated(exchange%gwemodel1) .and. m1_index > 0) then
174  write (errmsg, '(3a)') 'Problem with GWE-GWE exchange ', &
175  trim(exchange%name), &
176  '. First specified GWE Model does not appear to be of the correct type.'
177  call store_error(errmsg, terminate=.true.)
178  end if
179  !
180  ! -- Verify that gwe model2 is of the correct type
181  if (.not. associated(exchange%gwemodel2) .and. m2_index > 0) then
182  write (errmsg, '(3a)') 'Problem with GWE-GWE exchange ', &
183  trim(exchange%name), &
184  '. Second specified GWE Model does not appear to be of the correct type.'
185  call store_error(errmsg, terminate=.true.)
186  end if
187  !
188  ! -- Create the obs package
189  call obs_cr(exchange%obs, exchange%inobs)
type(listtype), public baseexchangelist
Definition: mf6lists.f90:25
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains the derived type ObsType.
Definition: Obs.f90:127
subroutine, public obs_cr(obs, inobs)
@ brief Create a new ObsType object
Definition: Obs.f90:225
Highest level model type. All models extend this parent type.
Definition: BaseModel.f90:13
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_mvt()

subroutine gwegweexchangemodule::read_mvt ( class(gweexchangetype this,
integer(i4b), intent(in)  iout 
)

Read and process movers

Parameters
thisGwtExchangeType

Definition at line 766 of file exg-gwegwe.f90.

767  ! -- modules
768  use tspmvtmodule, only: mvt_cr
769  ! -- dummy
770  class(GweExchangeType) :: this !< GwtExchangeType
771  integer(I4B), intent(in) :: iout
772  !
773  ! -- Create and initialize the mover object Here, fmi is set to the one
774  ! for gwtmodel1 so that a call to save flows has an associated dis
775  ! object.
776  call mvt_cr(this%mvt, this%name, this%inmvt, iout, this%gwemodel1%fmi, &
777  this%gwemodel1%eqnsclfac, this%gwemodel1%depvartype, &
778  gwfmodelname1=this%gwfmodelname1, &
779  gwfmodelname2=this%gwfmodelname2, &
780  fmi2=this%gwemodel2%fmi)
subroutine, public mvt_cr(mvt, name_model, inunit, iout, fmi1, eqnsclfac, depvartype, gwfmodelname1, gwfmodelname2, fmi2)
Create a new mover transport object.
Definition: tsp-mvt.f90:75
Here is the call graph for this function:

◆ source_options()

subroutine gwegweexchangemodule::source_options ( class(gweexchangetype this,
integer(i4b), intent(in)  iout 
)

Source the options block

Parameters
thisGweExchangeType

Definition at line 673 of file exg-gwegwe.f90.

674  ! -- modules
675  use constantsmodule, only: lenvarname
681  ! -- dummy
682  class(GweExchangeType) :: this !< GweExchangeType
683  integer(I4B), intent(in) :: iout
684  ! -- local
685  type(ExgGwegweParamFoundType) :: found
686  character(len=LENVARNAME), dimension(4) :: adv_scheme = &
687  &[character(len=LENVARNAME) :: 'UPSTREAM', 'CENTRAL', 'TVD', 'UTVD']
688  character(len=linelength) :: mvt_fname
689  !
690  ! -- update defaults with values sourced from input context
691  call mem_set_value(this%gwfmodelname1, 'GWFMODELNAME1', this%input_mempath, &
692  found%gwfmodelname1)
693  call mem_set_value(this%gwfmodelname2, 'GWFMODELNAME2', this%input_mempath, &
694  found%gwfmodelname2)
695  call mem_set_value(this%iAdvScheme, 'ADV_SCHEME', this%input_mempath, &
696  adv_scheme, found%adv_scheme)
697  call mem_set_value(this%ixt3d, 'CND_XT3D_OFF', this%input_mempath, &
698  found%cnd_xt3d_off)
699  call mem_set_value(this%ixt3d, 'CND_XT3D_RHS', this%input_mempath, &
700  found%cnd_xt3d_rhs)
701  !
702  write (iout, '(1x,a)') 'PROCESSING GWE-GWE EXCHANGE OPTIONS'
703  !
704  ! -- source base class options
705  call this%DisConnExchangeType%source_options(iout)
706  !
707  if (found%gwfmodelname1) then
708  write (iout, '(4x,a,a)') &
709  'GWFMODELNAME1 IS SET TO: ', trim(this%gwfmodelname1)
710  end if
711  !
712  if (found%gwfmodelname2) then
713  write (iout, '(4x,a,a)') &
714  'GWFMODELNAME2 IS SET TO: ', trim(this%gwfmodelname2)
715  end if
716  !
717  if (found%adv_scheme) then
718  if (this%iAdvScheme == 0) then
719  call store_error('Unrecognized input value for ADV_SCHEME option.')
720  call store_error_filename(this%filename)
721  else
722  ! -- count from 0
723  this%iAdvScheme = this%iAdvScheme - 1
724  write (iout, '(4x,a,a)') &
725  'ADVECTION SCHEME METHOD HAS BEEN SET TO: ', &
726  trim(adv_scheme(this%iAdvScheme + 1))
727  end if
728  end if
729  !
730  if (found%cnd_xt3d_off .and. found%cnd_xt3d_rhs) then
731  errmsg = 'CND_XT3D_OFF and CND_XT3D_RHS cannot both be set as options.'
732  call store_error(errmsg)
733  call store_error_filename(this%filename)
734  else if (found%cnd_xt3d_off) then
735  this%ixt3d = 0
736  write (iout, '(4x,a)') 'XT3D FORMULATION HAS BEEN SHUT OFF.'
737  else if (found%cnd_xt3d_rhs) then
738  this%ixt3d = 2
739  write (iout, '(4x,a)') 'XT3D RIGHT-HAND SIDE FORMULATION IS SELECTED.'
740  end if
741  !
742  ! -- enforce 0 or 1 MVR6_FILENAME entries in option block
743  if (filein_fname(mvt_fname, 'MVE6_FILENAME', this%input_mempath, &
744  this%filename)) then
745  this%inmvt = getunit()
746  call openfile(this%inmvt, iout, mvt_fname, 'MVT')
747  write (iout, '(4x,a)') 'WATER MOVER ENERGY TRANSPORT &
748  &INFORMATION WILL BE READ FROM ', trim(mvt_fname)
749  end if
750  !
751  ! -- enforce 0 or 1 OBS6_FILENAME entries in option block
752  if (filein_fname(this%obs%inputFilename, 'OBS6_FILENAME', &
753  this%input_mempath, this%filename)) then
754  this%obs%active = .true.
755  this%obs%inUnitObs = getunit()
756  call openfile(this%obs%inUnitObs, iout, this%obs%inputFilename, 'OBS')
757  end if
758  !
759  write (iout, '(1x,a)') 'END OF GWE-GWE EXCHANGE OPTIONS'
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition: Constants.f90:17
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:

◆ use_interface_model()

logical(lgp) function gwegweexchangemodule::use_interface_model ( class(gweexchangetype this)
private

For now this always returns true, since we do not support a classic-style two-point flux approximation for GWT-GWT. If we ever add logic to support a simpler non-interface model flux calculation, then logic should be added here to set the return accordingly.

Parameters
thisGweExchangeType
Returns
true when interface model should be used

Definition at line 1048 of file exg-gwegwe.f90.

1049  ! -- dummy
1050  class(GweExchangeType) :: this !< GweExchangeType
1051  ! -- return
1052  logical(LGP) :: use_im !< true when interface model should be used
1053  !
1054  ! For now set use_im to .true. since the interface model approach
1055  ! must currently be used for any GWT-GWT exchange.
1056  use_im = .true.

◆ validate_exchange()

subroutine gwegweexchangemodule::validate_exchange ( class(gweexchangetype this)
Parameters
thisGweExchangeType

Definition at line 249 of file exg-gwegwe.f90.

250  ! -- dummy
251  class(GweExchangeType) :: this !< GweExchangeType
252  !
253 
254  ! Ensure gwfmodel names were entered
255  if (this%gwfmodelname1 == '') then
256  write (errmsg, '(3a)') 'GWE-GWE exchange ', trim(this%name), &
257  ' requires that GWFMODELNAME1 be entered in the &
258  &OPTIONS block.'
259  call store_error(errmsg)
260  end if
261  if (this%gwfmodelname2 == '') then
262  write (errmsg, '(3a)') 'GWE-GWE exchange ', trim(this%name), &
263  ' requires that GWFMODELNAME2 be entered in the &
264  &OPTIONS block.'
265  call store_error(errmsg)
266  end if
267  !
268  ! Periodic boundary condition in exchange don't allow XT3D (=interface model)
269  if (associated(this%model1, this%model2)) then
270  if (this%ixt3d > 0) then
271  write (errmsg, '(3a)') 'GWE-GWE exchange ', trim(this%name), &
272  ' is a periodic boundary condition which cannot'// &
273  ' be configured with XT3D'
274  call store_error(errmsg)
275  end if
276  end if
277  !
278  ! Check to see if dispersion is on in either model1 or model2.
279  ! If so, then ANGLDEGX must be provided as an auxiliary variable for this
280  ! GWE-GWE exchange (this%ianglex > 0).
281  if (associated(this%gwemodel1) .and. associated(this%gwemodel2)) then
282  if (this%gwemodel1%incnd /= 0 .or. this%gwemodel2%incnd /= 0) then
283  if (this%ianglex == 0) then
284  write (errmsg, '(3a)') 'GWE-GWE exchange ', trim(this%name), &
285  ' requires that ANGLDEGX be specified as an'// &
286  ' auxiliary variable because dispersion was '// &
287  'specified in one or both transport models.'
288  call store_error(errmsg)
289  end if
290  end if
291  end if
292  !
293  if (this%ixt3d > 0 .and. this%ianglex == 0) then
294  write (errmsg, '(3a)') 'GWE-GWE exchange ', trim(this%name), &
295  ' requires that ANGLDEGX be specified as an'// &
296  ' auxiliary variable because XT3D is enabled'
297  call store_error(errmsg)
298  end if
299  !
300  if (count_errors() > 0) then
301  call ustop()
302  end if
Here is the call graph for this function: