MODFLOW 6  version 6.7.0.dev2
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 852 of file exg-gwegwe.f90.

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

783  ! -- modules
785  use constantsmodule, only: dzero
786  ! -- dummy
787  class(GweExchangeType) :: this !< GwtExchangeType
788  !
789  call this%DisConnExchangeType%allocate_scalars()
790  !
791  call mem_allocate(this%inewton, 'INEWTON', this%memoryPath)
792  call mem_allocate(this%inobs, 'INOBS', this%memoryPath)
793  call mem_allocate(this%iAdvScheme, 'IADVSCHEME', this%memoryPath)
794  this%inewton = 0
795  this%inobs = 0
796  this%iAdvScheme = 0
797  !
798  call mem_allocate(this%inmvt, 'INMVT', this%memoryPath)
799  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 1141 of file exg-gwegwe.f90.

1142  implicit none
1143  ! -- dummy
1144  class(*), pointer, intent(inout) :: obj
1145  ! -- return
1146  class(GweExchangeType), pointer :: res
1147  !
1148  res => null()
1149  if (.not. associated(obj)) return
1150  !
1151  select type (obj)
1152  class is (gweexchangetype)
1153  res => obj
1154  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 1161 of file exg-gwegwe.f90.

1162  implicit none
1163  ! -- dummy
1164  type(ListType), intent(inout) :: list
1165  integer(I4B), intent(in) :: idx
1166  ! -- return
1167  class(GweExchangeType), pointer :: res
1168  ! -- local
1169  class(*), pointer :: obj
1170  !
1171  obj => list%GetItem(idx)
1172  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 1015 of file exg-gwegwe.f90.

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

◆ gwe_gwe_da()

subroutine gwegweexchangemodule::gwe_gwe_da ( class(gweexchangetype this)

Deallocate memory associated with this object

Parameters
thisGwtExchangeType

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

807  ! -- modules
809  ! -- dummy
810  class(GweExchangeType) :: this !< GwtExchangeType
811  !
812  ! -- objects
813  if (this%inmvt > 0) then
814  call this%mvt%mvt_da()
815  deallocate (this%mvt)
816  end if
817  call this%obs%obs_da()
818  deallocate (this%obs)
819  !
820  ! -- arrays
821  call mem_deallocate(this%cond)
822  call mem_deallocate(this%simvals)
823  call mem_deallocate(this%gwfsimvals, 'GWFSIMVALS', this%memoryPath) ! linked memory
824  !
825  ! -- output table objects
826  if (associated(this%outputtab1)) then
827  call this%outputtab1%table_da()
828  deallocate (this%outputtab1)
829  nullify (this%outputtab1)
830  end if
831  if (associated(this%outputtab2)) then
832  call this%outputtab2%table_da()
833  deallocate (this%outputtab2)
834  nullify (this%outputtab2)
835  end if
836  !
837  ! -- scalars
838  deallocate (this%filename)
839  call mem_deallocate(this%inewton)
840  call mem_deallocate(this%inobs)
841  call mem_deallocate(this%iAdvScheme)
842  call mem_deallocate(this%inmvt)
843  !
844  ! -- deallocate base
845  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 920 of file exg-gwegwe.f90.

921  ! -- dummy
922  class(GweExchangeType) :: this !< GweExchangeType
923  ! -- local
924  integer(I4B) :: indx
925  !
926  ! -- Store obs type and assign procedure pointer
927  ! for gwt-gwt observation type.
928  call this%obs%StoreObsType('flow-ja-face', .true., indx)
929  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 1007 of file exg-gwegwe.f90.

1008  ! -- dummy
1009  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 1102 of file exg-gwegwe.f90.

1103  ! -- modules
1104  use constantsmodule, only: linelength
1105  use inputoutputmodule, only: urword
1106  use observemodule, only: observetype
1107  use basedismodule, only: disbasetype
1108  ! -- dummy
1109  type(ObserveType), intent(inout) :: obsrv
1110  class(DisBaseType), intent(in) :: dis
1111  integer(I4B), intent(in) :: inunitobs
1112  integer(I4B), intent(in) :: iout
1113  ! -- local
1114  integer(I4B) :: n, iexg, istat
1115  integer(I4B) :: icol, istart, istop
1116  real(DP) :: r
1117  character(len=LINELENGTH) :: string
1118  !
1119  string = obsrv%IDstring
1120  icol = 1
1121  ! -- get exchange index
1122  call urword(string, icol, istart, istop, 1, n, r, iout, inunitobs)
1123  read (string(istart:istop), '(i10)', iostat=istat) iexg
1124  if (istat == 0) then
1125  obsrv%intPak1 = iexg
1126  else
1127  ! Integer can't be read from string; it's presumed to be an exchange
1128  ! boundary name (already converted to uppercase)
1129  obsrv%FeatureName = trim(adjustl(string))
1130  ! -- Observation may require summing rates from multiple exchange
1131  ! boundaries, so assign intPak1 as a value that indicates observation
1132  ! is for a named exchange boundary or group of exchange boundaries.
1133  obsrv%intPak1 = namedboundflag
1134  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 936 of file exg-gwegwe.f90.

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

1059  ! -- dummy
1060  use simvariablesmodule, only: errmsg
1061  use constantsmodule, only: dzero
1062  use observemodule, only: observetype
1063  class(GweExchangeType), intent(inout) :: this
1064  ! -- local
1065  integer(I4B) :: i
1066  integer(I4B) :: j
1067  integer(I4B) :: n1
1068  integer(I4B) :: n2
1069  integer(I4B) :: iexg
1070  real(DP) :: v
1071  type(ObserveType), pointer :: obsrv => null()
1072  !
1073  ! -- Write simulated values for all gwt-gwt observations
1074  if (this%obs%npakobs > 0) then
1075  call this%obs%obs_bd_clear()
1076  do i = 1, this%obs%npakobs
1077  obsrv => this%obs%pakobs(i)%obsrv
1078  do j = 1, obsrv%indxbnds_count
1079  iexg = obsrv%indxbnds(j)
1080  v = dzero
1081  select case (obsrv%ObsTypeId)
1082  case ('FLOW-JA-FACE')
1083  n1 = this%nodem1(iexg)
1084  n2 = this%nodem2(iexg)
1085  v = this%simvals(iexg)
1086  case default
1087  errmsg = 'Unrecognized observation type: '// &
1088  trim(obsrv%ObsTypeId)
1089  call store_error(errmsg)
1090  call store_error_filename(this%obs%inputFilename)
1091  end select
1092  call this%obs%SaveOneSimval(obsrv, v)
1093  end do
1094  end do
1095  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 761 of file exg-gwegwe.f90.

762  ! -- modules
763  use tspmvtmodule, only: mvt_cr
764  ! -- dummy
765  class(GweExchangeType) :: this !< GwtExchangeType
766  integer(I4B), intent(in) :: iout
767  !
768  ! -- Create and initialize the mover object Here, fmi is set to the one
769  ! for gwtmodel1 so that a call to save flows has an associated dis
770  ! object.
771  call mvt_cr(this%mvt, this%name, this%inmvt, iout, this%gwemodel1%fmi, &
772  this%gwemodel1%eqnsclfac, this%gwemodel1%depvartype, &
773  gwfmodelname1=this%gwfmodelname1, &
774  gwfmodelname2=this%gwfmodelname2, &
775  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  ! -- count from 0
719  this%iAdvScheme = this%iAdvScheme - 1
720  write (iout, '(4x,a,a)') &
721  'ADVECTION SCHEME METHOD HAS BEEN SET TO: ', &
722  trim(adv_scheme(this%iAdvScheme + 1))
723  end if
724  !
725  if (found%cnd_xt3d_off .and. found%cnd_xt3d_rhs) then
726  errmsg = 'CND_XT3D_OFF and CND_XT3D_RHS cannot both be set as options.'
727  call store_error(errmsg)
728  call store_error_filename(this%filename)
729  else if (found%cnd_xt3d_off) then
730  this%ixt3d = 0
731  write (iout, '(4x,a)') 'XT3D FORMULATION HAS BEEN SHUT OFF.'
732  else if (found%cnd_xt3d_rhs) then
733  this%ixt3d = 2
734  write (iout, '(4x,a)') 'XT3D RIGHT-HAND SIDE FORMULATION IS SELECTED.'
735  end if
736  !
737  ! -- enforce 0 or 1 MVR6_FILENAME entries in option block
738  if (filein_fname(mvt_fname, 'MVE6_FILENAME', this%input_mempath, &
739  this%filename)) then
740  this%inmvt = getunit()
741  call openfile(this%inmvt, iout, mvt_fname, 'MVT')
742  write (iout, '(4x,a)') 'WATER MOVER ENERGY TRANSPORT &
743  &INFORMATION WILL BE READ FROM ', trim(mvt_fname)
744  end if
745  !
746  ! -- enforce 0 or 1 OBS6_FILENAME entries in option block
747  if (filein_fname(this%obs%inputFilename, 'OBS6_FILENAME', &
748  this%input_mempath, this%filename)) then
749  this%obs%active = .true.
750  this%obs%inUnitObs = getunit()
751  call openfile(this%obs%inUnitObs, iout, this%obs%inputFilename, 'OBS')
752  end if
753  !
754  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 1043 of file exg-gwegwe.f90.

1044  ! -- dummy
1045  class(GweExchangeType) :: this !< GweExchangeType
1046  ! -- return
1047  logical(LGP) :: use_im !< true when interface model should be used
1048  !
1049  ! For now set use_im to .true. since the interface model approach
1050  ! must currently be used for any GWT-GWT exchange.
1051  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: