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

This module contains the GwtGwtExchangeModule Module. More...

Data Types

type  gwtexchangetype
 Derived type for GwtExchangeType. More...
 

Functions/Subroutines

subroutine, public gwtexchange_create (filename, name, id, m1_id, m2_id, input_mempath)
 @ brief Create GWT GWT exchange More...
 
subroutine gwt_gwt_df (this)
 @ brief Define GWT GWT exchange More...
 
subroutine validate_exchange (this)
 validate exchange data after reading More...
 
subroutine gwt_gwt_ar (this)
 @ brief Allocate and read More...
 
subroutine gwt_gwt_rp (this)
 @ brief Read and prepare More...
 
subroutine gwt_gwt_ad (this)
 @ brief Advance More...
 
subroutine gwt_gwt_fc (this, kiter, matrix_sln, rhs_sln, inwtflag)
 @ brief Fill coefficients More...
 
subroutine gwt_gwt_bd (this, icnvg, isuppress_output, isolnid)
 @ brief Budget More...
 
subroutine gwt_gwt_bdsav (this)
 @ brief Budget save More...
 
subroutine gwt_gwt_bdsav_model (this, model)
 @ brief Budget save More...
 
subroutine gwt_gwt_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 gwt_gwt_da (this)
 @ brief Deallocate More...
 
subroutine allocate_arrays (this)
 @ brief Allocate arrays More...
 
subroutine gwt_gwt_df_obs (this)
 @ brief Define observations More...
 
subroutine gwt_gwt_rp_obs (this)
 @ brief Read and prepare observations More...
 
subroutine gwt_gwt_fp (this)
 @ brief Final processing More...
 
logical(lgp) function gwt_gwt_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 gwt_gwt_save_simvals (this)
 @ brief Save simulated flow observations More...
 
subroutine gwt_gwt_process_obsid (obsrv, dis, inunitobs, iout)
 @ brief Obs ID processor More...
 
class(gwtexchangetype) function, pointer, public castasgwtexchange (obj)
 @ brief Cast polymorphic object as exchange More...
 
class(gwtexchangetype) function, pointer, public getgwtexchangefromlist (list, idx)
 @ brief Get exchange from list More...
 

Detailed Description

This module contains the code for connecting two GWT 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 GwtGwtConnection with the more sophisticated interface model coupling approach when XT3D is needed.

Function/Subroutine Documentation

◆ allocate_arrays()

subroutine gwtgwtexchangemodule::allocate_arrays ( class(gwtexchangetype this)

Allocate arrays

Parameters
thisGwtExchangeType

Definition at line 848 of file exg-gwtgwt.f90.

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

◆ allocate_scalars()

subroutine gwtgwtexchangemodule::allocate_scalars ( class(gwtexchangetype this)

Allocate scalar variables

Parameters
thisGwtExchangeType

Definition at line 778 of file exg-gwtgwt.f90.

779  ! -- modules
781  use constantsmodule, only: dzero
782  ! -- dummy
783  class(GwtExchangeType) :: this !< GwtExchangeType
784  !
785  call this%DisConnExchangeType%allocate_scalars()
786  !
787  call mem_allocate(this%inewton, 'INEWTON', this%memoryPath)
788  call mem_allocate(this%inobs, 'INOBS', this%memoryPath)
789  call mem_allocate(this%iAdvScheme, 'IADVSCHEME', this%memoryPath)
790  this%inewton = 0
791  this%inobs = 0
792  this%iAdvScheme = 0
793  !
794  call mem_allocate(this%inmvt, 'INMVT', this%memoryPath)
795  this%inmvt = 0
This module contains simulation constants.
Definition: Constants.f90:9
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:65

◆ castasgwtexchange()

class(gwtexchangetype) function, pointer, public gwtgwtexchangemodule::castasgwtexchange ( class(*), intent(inout), pointer  obj)

Cast polymorphic object as exchange

Definition at line 1137 of file exg-gwtgwt.f90.

1138  implicit none
1139  ! -- dummy
1140  class(*), pointer, intent(inout) :: obj
1141  ! -- return
1142  class(GwtExchangeType), pointer :: res
1143  !
1144  res => null()
1145  if (.not. associated(obj)) return
1146  !
1147  select type (obj)
1148  class is (gwtexchangetype)
1149  res => obj
1150  end select
Here is the caller graph for this function:

◆ getgwtexchangefromlist()

class(gwtexchangetype) function, pointer, public gwtgwtexchangemodule::getgwtexchangefromlist ( type(listtype), intent(inout)  list,
integer(i4b), intent(in)  idx 
)

Return an exchange from the list for specified index

Definition at line 1157 of file exg-gwtgwt.f90.

1158  implicit none
1159  ! -- dummy
1160  type(ListType), intent(inout) :: list
1161  integer(I4B), intent(in) :: idx
1162  ! -- return
1163  class(GwtExchangeType), pointer :: res
1164  ! -- local
1165  class(*), pointer :: obj
1166  !
1167  obj => list%GetItem(idx)
1168  res => castasgwtexchange(obj)
Here is the call graph for this function:

◆ gwt_gwt_ad()

subroutine gwtgwtexchangemodule::gwt_gwt_ad ( class(gwtexchangetype this)

Advance mover and obs

Parameters
thisGwtExchangeType

Definition at line 340 of file exg-gwtgwt.f90.

341  ! -- dummy
342  class(GwtExchangeType) :: this !< GwtExchangeType
343  !
344  ! -- Advance mover
345  !if(this%inmvt > 0) call this%mvt%mvt_ad()
346  !
347  ! -- Push simulated values to preceding time step
348  call this%obs%obs_ad()

◆ gwt_gwt_ar()

subroutine gwtgwtexchangemodule::gwt_gwt_ar ( class(gwtexchangetype this)
private

Allocated and read and calculate saturated conductance

Parameters
thisGwtExchangeType

Definition at line 305 of file exg-gwtgwt.f90.

306  ! -- dummy
307  class(GwtExchangeType) :: this !< GwtExchangeType
308  !
309  ! -- If mover is active, then call ar routine
310  if (this%inmvt > 0) call this%mvt%mvt_ar()
311  !
312  ! -- Observation AR
313  call this%obs%obs_ar()

◆ gwt_gwt_bd()

subroutine gwtgwtexchangemodule::gwt_gwt_bd ( class(gwtexchangetype this,
integer(i4b), intent(inout)  icnvg,
integer(i4b), intent(in)  isuppress_output,
integer(i4b), intent(in)  isolnid 
)
private

Accumulate budget terms

Parameters
thisGwtExchangeType

Definition at line 371 of file exg-gwtgwt.f90.

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

◆ gwt_gwt_bdsav()

subroutine gwtgwtexchangemodule::gwt_gwt_bdsav ( class(gwtexchangetype this)

Output individual flows to listing file and binary budget files

Parameters
thisGwtExchangeType

Definition at line 413 of file exg-gwtgwt.f90.

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

◆ gwt_gwt_bdsav_model()

subroutine gwtgwtexchangemodule::gwt_gwt_bdsav_model ( class(gwtexchangetype this,
class(gwtmodeltype), pointer  model 
)
private

Output individual flows to listing file and binary budget files

Parameters
thisGwtExchangeType

Definition at line 447 of file exg-gwtgwt.f90.

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

◆ gwt_gwt_connects_model()

logical(lgp) function gwtgwtexchangemodule::gwt_gwt_connects_model ( class(gwtexchangetype this,
class(basemodeltype), intent(in), pointer  model 
)
private
Parameters
model
thisGwtExchangeType
[in]modelthe model to which the exchange might hold a connection
Returns
true, when connected

Definition at line 1011 of file exg-gwtgwt.f90.

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

◆ gwt_gwt_da()

subroutine gwtgwtexchangemodule::gwt_gwt_da ( class(gwtexchangetype this)

Deallocate memory associated with this object

Parameters
thisGwtExchangeType

Definition at line 802 of file exg-gwtgwt.f90.

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

◆ gwt_gwt_df()

subroutine gwtgwtexchangemodule::gwt_gwt_df ( class(gwtexchangetype this)

Define GWT to GWT exchange object.

Parameters
thisGwtExchangeType

Definition at line 194 of file exg-gwtgwt.f90.

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

◆ gwt_gwt_df_obs()

subroutine gwtgwtexchangemodule::gwt_gwt_df_obs ( class(gwtexchangetype this)

Define the observations associated with this object

Parameters
thisGwtExchangeType

Definition at line 916 of file exg-gwtgwt.f90.

917  ! -- dummy
918  class(GwtExchangeType) :: this !< GwtExchangeType
919  ! -- local
920  integer(I4B) :: indx
921  !
922  ! -- Store obs type and assign procedure pointer
923  ! for gwt-gwt observation type.
924  call this%obs%StoreObsType('flow-ja-face', .true., indx)
925  this%obs%obsData(indx)%ProcessIdPtr => gwt_gwt_process_obsid
Here is the call graph for this function:

◆ gwt_gwt_fc()

subroutine gwtgwtexchangemodule::gwt_gwt_fc ( class(gwtexchangetype 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 355 of file exg-gwtgwt.f90.

356  ! -- dummy
357  class(GwtExchangeType) :: this !< GwtExchangeType
358  integer(I4B), intent(in) :: kiter
359  class(MatrixBaseType), pointer :: matrix_sln
360  real(DP), dimension(:), intent(inout) :: rhs_sln
361  integer(I4B), optional, intent(in) :: inwtflag
362  !
363  ! -- Call mvt fc routine
364  if (this%inmvt > 0) call this%mvt%mvt_fc(this%gwtmodel1%x, this%gwtmodel2%x)

◆ gwt_gwt_fp()

subroutine gwtgwtexchangemodule::gwt_gwt_fp ( class(gwtexchangetype this)

Conduct any final processing

Parameters
thisGwtExchangeType

Definition at line 1003 of file exg-gwtgwt.f90.

1004  ! -- dummy
1005  class(GwtExchangeType) :: this !< GwtExchangeType

◆ gwt_gwt_ot()

subroutine gwtgwtexchangemodule::gwt_gwt_ot ( class(gwtexchangetype this)

Write output

Parameters
thisGwtExchangeType

Definition at line 615 of file exg-gwtgwt.f90.

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

◆ gwt_gwt_process_obsid()

subroutine gwtgwtexchangemodule::gwt_gwt_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 1098 of file exg-gwtgwt.f90.

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

◆ gwt_gwt_rp()

subroutine gwtgwtexchangemodule::gwt_gwt_rp ( class(gwtexchangetype this)
private

Read new data for mover and obs

Parameters
thisGwtExchangeType

Definition at line 320 of file exg-gwtgwt.f90.

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

◆ gwt_gwt_rp_obs()

subroutine gwtgwtexchangemodule::gwt_gwt_rp_obs ( class(gwtexchangetype this)
private

Handle observation exchanges exchange-boundary names.

Parameters
thisGwtExchangeType

Definition at line 932 of file exg-gwtgwt.f90.

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

◆ gwt_gwt_save_simvals()

subroutine gwtgwtexchangemodule::gwt_gwt_save_simvals ( class(gwtexchangetype), intent(inout)  this)
private

Save the simulated flows for each exchange

Definition at line 1054 of file exg-gwtgwt.f90.

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

◆ gwtexchange_create()

subroutine, public gwtgwtexchangemodule::gwtexchange_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 109 of file exg-gwtgwt.f90.

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

Read and process movers

Parameters
thisGwtExchangeType

Definition at line 757 of file exg-gwtgwt.f90.

758  ! -- modules
759  use tspmvtmodule, only: mvt_cr
760  ! -- dummy
761  class(GwtExchangeType) :: this !< GwtExchangeType
762  integer(I4B), intent(in) :: iout
763  !
764  ! -- Create and initialize the mover object Here, fmi is set to the one
765  ! for gwtmodel1 so that a call to save flows has an associated dis
766  ! object.
767  call mvt_cr(this%mvt, this%name, this%inmvt, iout, this%gwtmodel1%fmi, &
768  this%gwtmodel1%eqnsclfac, this%gwtmodel1%depvartype, &
769  gwfmodelname1=this%gwfmodelname1, &
770  gwfmodelname2=this%gwfmodelname2, &
771  fmi2=this%gwtmodel2%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 gwtgwtexchangemodule::source_options ( class(gwtexchangetype this,
integer(i4b), intent(in)  iout 
)

Source the options block

Parameters
thisGwtExchangeType

Definition at line 669 of file exg-gwtgwt.f90.

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

Definition at line 1039 of file exg-gwtgwt.f90.

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

◆ validate_exchange()

subroutine gwtgwtexchangemodule::validate_exchange ( class(gwtexchangetype this)
Parameters
thisGwtExchangeType

Definition at line 246 of file exg-gwtgwt.f90.

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