MODFLOW 6  version 6.7.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 851 of file exg-gwegwe.f90.

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

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

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

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

344  ! -- dummy
345  class(GweExchangeType) :: this !< GweExchangeType
346  !
347  ! -- Advance mover
348  !if(this%inmvt > 0) call this%mvt%mvt_ad()
349  !
350  ! -- Push simulated values to preceding time step
351  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 308 of file exg-gwegwe.f90.

309  ! -- dummy
310  class(GweExchangeType) :: this !< GwtExchangeType
311  !
312  ! -- If mover is active, then call ar routine
313  if (this%inmvt > 0) call this%mvt%mvt_ar()
314  !
315  ! -- Observation AR
316  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 374 of file exg-gwegwe.f90.

375  ! -- modules
377  use budgetmodule, only: rate_accumulator
378  ! -- dummy
379  class(GweExchangeType) :: this !< GweExchangeType
380  integer(I4B), intent(inout) :: icnvg
381  integer(I4B), intent(in) :: isuppress_output
382  integer(I4B), intent(in) :: isolnid
383  ! -- local
384  character(len=LENBUDTXT), dimension(1) :: budtxt
385  real(DP), dimension(2, 1) :: budterm
386  real(DP) :: ratin, ratout
387  !
388  ! -- initialize
389  budtxt(1) = ' FLOW-JA-FACE'
390  !
391  ! -- Calculate ratin/ratout and pass to model budgets
392  call rate_accumulator(this%simvals, ratin, ratout)
393  !
394  ! -- Add the budget terms to model 1
395  if (associated(this%gwemodel1)) then
396  budterm(1, 1) = ratin
397  budterm(2, 1) = ratout
398  call this%gwemodel1%model_bdentry(budterm, budtxt, this%name)
399  end if
400  !
401  ! -- Add the budget terms to model 2
402  if (associated(this%gwemodel2)) then
403  budterm(1, 1) = ratout
404  budterm(2, 1) = ratin
405  call this%gwemodel2%model_bdentry(budterm, budtxt, this%name)
406  end if
407  !
408  ! -- Call mvt bd routine
409  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 416 of file exg-gwegwe.f90.

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

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

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

◆ gwe_gwe_da()

subroutine gwegweexchangemodule::gwe_gwe_da ( class(gweexchangetype this)

Deallocate memory associated with this object

Parameters
thisGwtExchangeType

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

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

196  ! -- modules
197  use simvariablesmodule, only: iout
199  use ghostnodemodule, only: gnc_cr
200  ! -- dummy
201  class(GweExchangeType) :: this !< GwtExchangeType
202  !
203  ! -- log the exchange
204  write (iout, '(/a,a)') ' Creating exchange: ', this%name
205  !
206  ! -- Ensure models are in same solution
207  if (associated(this%gwemodel1) .and. associated(this%gwemodel2)) then
208  if (this%gwemodel1%idsoln /= this%gwemodel2%idsoln) then
209  call store_error('Two models are connect in a GWE '// &
210  'exchange but they are in different solutions. '// &
211  'GWE models must be in same solution: '// &
212  trim(this%gwemodel1%name)//' '// &
213  trim(this%gwemodel2%name))
214  call store_error_filename(this%filename)
215  end if
216  end if
217  !
218  ! -- source options
219  call this%source_options(iout)
220  !
221  ! -- source dimensions
222  call this%source_dimensions(iout)
223  !
224  ! -- allocate arrays
225  call this%allocate_arrays()
226  !
227  ! -- source exchange data
228  call this%source_data(iout)
229  !
230  ! -- Read mover information
231  if (this%inmvt > 0) then
232  call this%read_mvt(iout)
233  call this%mvt%mvt_df(this%gwemodel1%dis)
234  end if
235  !
236  ! -- Store obs
237  call this%gwe_gwe_df_obs()
238  if (associated(this%gwemodel1)) then
239  call this%obs%obs_df(iout, this%name, 'GWE-GWE', this%gwemodel1%dis)
240  end if
241  !
242  ! -- validate
243  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 919 of file exg-gwegwe.f90.

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

359  ! -- dummy
360  class(GweExchangeType) :: this !< GwtExchangeType
361  integer(I4B), intent(in) :: kiter
362  class(MatrixBaseType), pointer :: matrix_sln
363  real(DP), dimension(:), intent(inout) :: rhs_sln
364  integer(I4B), optional, intent(in) :: inwtflag
365  !
366  ! -- Call mvt fc routine
367  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 1006 of file exg-gwegwe.f90.

1007  ! -- dummy
1008  class(GweExchangeType) :: this !< GwtExchangeType

◆ gwe_gwe_ot()

subroutine gwegweexchangemodule::gwe_gwe_ot ( class(gweexchangetype this)

Write output

Parameters
thisGweExchangeType

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

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

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

324  ! -- modules
325  use tdismodule, only: readnewdata
326  ! -- dummy
327  class(GweExchangeType) :: this !< GweExchangeType
328  !
329  ! -- Check with TDIS on whether or not it is time to RP
330  if (.not. readnewdata) return
331  !
332  ! -- Read and prepare for mover
333  if (this%inmvt > 0) call this%mvt%mvt_rp()
334  !
335  ! -- Read and prepare for observations
336  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 935 of file exg-gwegwe.f90.

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

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

111  ! -- modules
112  use basemodelmodule, only: basemodeltype
113  use listsmodule, only: baseexchangelist
114  use obsmodule, only: obs_cr
116  ! -- dummy
117  character(len=*), intent(in) :: filename !< filename for reading
118  integer(I4B), intent(in) :: id !< id for the exchange
119  character(len=*) :: name !< the exchange name
120  integer(I4B), intent(in) :: m1_id !< id for model 1
121  integer(I4B), intent(in) :: m2_id !< id for model 2
122  character(len=*), intent(in) :: input_mempath
123  ! -- local
124  type(GweExchangeType), pointer :: exchange
125  class(BaseModelType), pointer :: mb
126  class(BaseExchangeType), pointer :: baseexchange
127  integer(I4B) :: m1_index, m2_index
128  !
129  ! -- Create a new exchange and add it to the baseexchangelist container
130  allocate (exchange)
131  baseexchange => exchange
132  call addbaseexchangetolist(baseexchangelist, baseexchange)
133  !
134  ! -- Assign id and name
135  exchange%id = id
136  exchange%name = name
137  exchange%memoryPath = create_mem_path(exchange%name)
138  exchange%input_mempath = input_mempath
139  !
140  ! -- allocate scalars and set defaults
141  call exchange%allocate_scalars()
142  exchange%filename = filename
143  exchange%typename = 'GWE-GWE'
144  exchange%iAdvScheme = 0
145  exchange%ixt3d = 1
146  !
147  ! -- set gwemodel1
148  m1_index = model_loc_idx(m1_id)
149  mb => getbasemodelfromlist(basemodellist, m1_index)
150  if (m1_index > 0) then
151  select type (mb)
152  type is (gwemodeltype)
153  exchange%model1 => mb
154  exchange%gwemodel1 => mb
155  end select
156  end if
157  exchange%v_model1 => get_virtual_model(m1_id)
158  !
159  ! -- set gwemodel2
160  m2_index = model_loc_idx(m2_id)
161  if (m2_index > 0) then
162  mb => getbasemodelfromlist(basemodellist, m2_index)
163  select type (mb)
164  type is (gwemodeltype)
165  exchange%model2 => mb
166  exchange%gwemodel2 => mb
167  end select
168  end if
169  exchange%v_model2 => get_virtual_model(m2_id)
170  !
171  ! -- Verify that gwt model1 is of the correct type
172  if (.not. associated(exchange%gwemodel1) .and. m1_index > 0) then
173  write (errmsg, '(3a)') 'Problem with GWE-GWE exchange ', &
174  trim(exchange%name), &
175  '. First specified GWE Model does not appear to be of the correct type.'
176  call store_error(errmsg, terminate=.true.)
177  end if
178  !
179  ! -- Verify that gwe model2 is of the correct type
180  if (.not. associated(exchange%gwemodel2) .and. m2_index > 0) then
181  write (errmsg, '(3a)') 'Problem with GWE-GWE exchange ', &
182  trim(exchange%name), &
183  '. Second specified GWE Model does not appear to be of the correct type.'
184  call store_error(errmsg, terminate=.true.)
185  end if
186  !
187  ! -- Create the obs package
188  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 760 of file exg-gwegwe.f90.

761  ! -- modules
762  use tspmvtmodule, only: mvt_cr
763  ! -- dummy
764  class(GweExchangeType) :: this !< GwtExchangeType
765  integer(I4B), intent(in) :: iout
766  !
767  ! -- Create and initialize the mover object Here, fmi is set to the one
768  ! for gwtmodel1 so that a call to save flows has an associated dis
769  ! object.
770  call mvt_cr(this%mvt, this%name, this%inmvt, iout, this%gwemodel1%fmi, &
771  this%gwemodel1%eqnsclfac, this%gwemodel1%depvartype, &
772  gwfmodelname1=this%gwfmodelname1, &
773  gwfmodelname2=this%gwfmodelname2, &
774  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 672 of file exg-gwegwe.f90.

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

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

◆ validate_exchange()

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

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

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