MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
swf.f90
Go to the documentation of this file.
1 
2 !> @brief Stream Network Flow (SWF) Module
3 !!
4 !! This module contains the SWF Model
5 !!
6 !! Status and remaining tasks
7 !! ONGOING -- Implement SWF infrastructure
8 !! DONE -- Implement Explicit Model Solution (EMS6) to handle explicit models
9 !! DONE -- Implement DISV1D Package
10 !! DONE -- Implement FLW Package to handle lateral and point inflows
11 !! DONE -- Transfer results into the flowja vector
12 !! DONE -- Implement strategy for storing outflow terms and getting them into budget
13 !! DONE -- Implement SWF and FLW advance routines to handle transient problems
14 !! DONE -- Implement storage terms and getting them into budget
15 !! DONE -- Observations
16 !! DONE -- Initial conditions?
17 !! DONE -- Rework the Iterative Model Solution (IMS6) to handle both implicit and explicit models
18 !! DONE -- Implement output control
19 !! DONE -- Add outflow as a dependent variable that can be written and printed (qoutflow)
20 !! DONE -- Revaluate explicit model solution and consider implementing ExplicitModelType?
21 !! DONE -- Add test of the binary outflow
22 !! DONE -- Rename Stream Network Flow (SWF) to Surface Water Flow (SWF) Model
23 !! DONE -- Rename segment to reach
24 !! Look into mass conservative MC method (https://hess.copernicus.org/articles/11/1645/2007/hess-11-1645-2007.pdf)
25 !! Implement IDOMAIN support
26 !! Use dag_module to calculate iseg_order (if iseg_order not specified by user)
27 !! We may need subcells and subtiming to improve accuracy
28 !! Add support for nonlinear Muskingum Cunge
29 !! Deal with the timestep and subtiming issues
30 !! Flopy support for DISV1D and DISV1D binary grid file
31 !! Flopy support for .output() method for SWF
32 !! Mover support?
33 !! SWF-SWF Exchange
34 !! SWF-SWF Exchange in parallel
35 !! Create QGW package for leakage into or out of groundwater
36 !!
37 !<
38 module swfmodule
39 
40  use kindmodule, only: dp, i4b
44  use simvariablesmodule, only: errmsg
49  use swficmodule, only: swfictype
50  use swfdfwmodule, only: swfdfwtype
51  use swfcxsmodule, only: swfcxstype
52  use swfstomodule, only: swfstotype
54  use swfocmodule, only: swfoctype
55  use budgetmodule, only: budgettype
57 
58  implicit none
59 
60  private
61  public :: swf_cr
62  public :: swfmodeltype
63  public :: swf_nbasepkg, swf_nmultipkg
64  public :: swf_basepkg, swf_multipkg
65 
66  type, extends(numericalmodeltype) :: swfmodeltype
67  type(swfictype), pointer :: ic => null() ! initial conditions package
68  type(swfdfwtype), pointer :: dfw => null() !< diffusive wave package
69  type(swfcxstype), pointer :: cxs => null() !< cross section package
70  type(swfstotype), pointer :: sto => null() !< storage package
71  type(swfobstype), pointer :: obs => null() ! observation package
72  type(swfoctype), pointer :: oc => null() !< output control package
73  type(budgettype), pointer :: budget => null() !< budget object
74  integer(I4B), pointer :: inic => null() ! unit number IC
75  integer(I4B), pointer :: indfw => null() !< unit number DFW
76  integer(I4B), pointer :: incxs => null() !< unit number CXS
77  integer(I4B), pointer :: insto => null() !< unit number STO
78  integer(I4B), pointer :: inobs => null() ! unit number OBS
79  integer(I4B), pointer :: inoc => null() !< unit number OC
80  integer(I4B), pointer :: iss => null() ! steady state flag
81  integer(I4B), pointer :: inewtonur => null() ! newton under relaxation flag
82  contains
83  procedure :: allocate_scalars
84  procedure :: allocate_arrays
85  procedure :: model_df => swf_df
86  procedure :: model_ac => swf_ac
87  procedure :: model_mc => swf_mc
88  procedure :: model_ar => swf_ar
89  procedure :: model_rp => swf_rp
90  procedure :: model_ad => swf_ad
91  procedure :: model_nur => swf_nur
92  procedure :: model_cf => swf_cf
93  procedure :: model_fc => swf_fc
94  procedure :: model_cq => swf_cq
95  procedure :: model_bd => swf_bd
96  procedure :: model_ot => swf_ot
97  procedure :: model_da => swf_da
98  procedure :: model_bdentry => swf_bdentry
99  procedure :: swf_ot_obs
100  procedure :: swf_ot_flow
101  procedure :: swf_ot_dv
102  procedure :: swf_ot_bdsummary
103  procedure :: package_create
104  procedure :: ftype_check
105  procedure :: get_iasym => swf_get_iasym
106  procedure, private :: create_packages
107  procedure, private :: create_bndpkgs
108  procedure, private :: log_namfile_options
109  procedure, private :: steady_period_check
110  end type swfmodeltype
111 
112  !> @brief SWF base package array descriptors
113  !!
114  !! SWF model base package types. Only listed packages are candidates
115  !! for input and these will be loaded in the order specified.
116  !<
117  integer(I4B), parameter :: swf_nbasepkg = 9
118  character(len=LENPACKAGETYPE), dimension(SWF_NBASEPKG) :: &
119  swf_basepkg = ['DISV1D6', 'DIS2D6 ', 'DISV2D6', &
120  'DFW6 ', 'CXS6 ', 'OC6 ', &
121  'IC6 ', 'OBS6 ', 'STO6 ']
122 
123  !> @brief SWF multi package array descriptors
124  !!
125  !! SWF model multi-instance package types. Only listed packages are
126  !! candidates for input and these will be loaded in the order specified.
127  !<
128  integer(I4B), parameter :: swf_nmultipkg = 50
129  character(len=LENPACKAGETYPE), dimension(SWF_NMULTIPKG) :: swf_multipkg
130  data swf_multipkg/'FLW6 ', 'CHD6 ', 'CDB6 ', 'ZDG6 ', ' ', & ! 5
131  &45*' '/ ! 50
132 
133  ! -- size of supported model package arrays
134  integer(I4B), parameter :: niunit_swf = swf_nbasepkg + swf_nmultipkg
135 
136 contains
137 
138  !> @brief Create a new stream network flow model object
139  !!
140  !! (1) creates model object and add to modellist
141  !! (2) assign values
142  !!
143  !<
144  subroutine swf_cr(filename, id, modelname)
145  ! -- modules
146  use listsmodule, only: basemodellist
152  use budgetmodule, only: budget_cr
153  ! -- dummy
154  character(len=*), intent(in) :: filename !< input file
155  integer(I4B), intent(in) :: id !< consecutive model number listed in mfsim.nam
156  character(len=*), intent(in) :: modelname !< name of the model
157  ! -- local
158  type(swfmodeltype), pointer :: this
159  class(basemodeltype), pointer :: model
160  character(len=LENMEMPATH) :: input_mempath
161  character(len=LINELENGTH) :: lst_fname
162  type(swfnamparamfoundtype) :: found
163  ! -- format
164  !
165  ! -- Allocate a new model (this) and add it to basemodellist
166  allocate (this)
167  !
168  ! -- Set memory path before allocation in memory manager can be done
169  this%memoryPath = create_mem_path(modelname)
170  !
171  call this%allocate_scalars(modelname)
172  model => this
173  call addbasemodeltolist(basemodellist, model)
174  !
175  ! -- Assign values
176  this%filename = filename
177  this%name = modelname
178  this%macronym = 'SWF'
179  this%id = id
180  !
181  ! -- set input model namfile memory path
182  input_mempath = create_mem_path(modelname, 'NAM', idm_context)
183  !
184  ! -- copy option params from input context
185  call mem_set_value(lst_fname, 'LIST', input_mempath, found%list)
186  call mem_set_value(this%inewton, 'NEWTON', input_mempath, found%newton)
187  call mem_set_value(this%inewtonur, 'UNDER_RELAXATION', input_mempath, &
188  found%under_relaxation)
189  call mem_set_value(this%iprpak, 'PRINT_INPUT', input_mempath, &
190  found%print_input)
191  call mem_set_value(this%iprflow, 'PRINT_FLOWS', input_mempath, &
192  found%print_flows)
193  call mem_set_value(this%ipakcb, 'SAVE_FLOWS', input_mempath, found%save_flows)
194  !
195  ! -- create the list file
196  call this%create_lstfile(lst_fname, filename, found%list, &
197  'SURFACE WATER FLOW MODEL (SWF)')
198  !
199  ! -- activate save_flows if found
200  if (found%save_flows) then
201  this%ipakcb = -1
202  end if
203  !
204  ! -- log set options
205  if (this%iout > 0) then
206  call this%log_namfile_options(found)
207  end if
208  !
209  ! -- Create utility objects
210  call budget_cr(this%budget, this%name)
211  !
212  ! -- create model packages
213  call this%create_packages()
214  !
215  ! -- return
216  return
217  end subroutine swf_cr
218 
219  !> @brief Allocate memory for scalar members
220  subroutine allocate_scalars(this, modelname)
221  ! -- modules
222  ! -- dummy
223  class(swfmodeltype) :: this
224  character(len=*), intent(in) :: modelname
225  !
226  ! -- allocate members from parent class
227  !call this%ExplicitModelType%allocate_scalars(modelname)
228  call this%NumericalModelType%allocate_scalars(modelname)
229  !
230  ! -- allocate members that are part of model class
231  call mem_allocate(this%inic, 'INIC', this%memoryPath)
232  call mem_allocate(this%indfw, 'INDFW', this%memoryPath)
233  call mem_allocate(this%incxs, 'INCXS', this%memoryPath)
234  call mem_allocate(this%insto, 'INSTO', this%memoryPath)
235  call mem_allocate(this%inobs, 'INOBS', this%memoryPath)
236  call mem_allocate(this%inoc, 'INOC', this%memoryPath)
237  call mem_allocate(this%iss, 'ISS', this%memoryPath)
238  call mem_allocate(this%inewtonur, 'INEWTONUR', this%memoryPath)
239  !
240  this%inic = 0
241  this%indfw = 0
242  this%incxs = 0
243  this%insto = 0
244  this%inobs = 0
245  this%inoc = 0
246  this%iss = 1 !default is steady-state (i.e., no STO package)
247  this%inewtonur = 0
248  !
249  ! -- return
250  return
251  end subroutine allocate_scalars
252 
253  !> @brief Allocate memory for scalar members
254  subroutine allocate_arrays(this)
255  ! -- modules
256  ! -- dummy
257  class(swfmodeltype) :: this
258  integer(I4B) :: i
259  !
260  ! -- allocate members from parent class
261  call this%NumericalModelType%allocate_arrays()
262  !
263  ! -- This is not a numerical solution, so x, rhs, and active
264  ! are allocated by a numerical solution, so need to do it
265  ! here.
266  if (this%indfw == 0) then
267  ! -- explicit model, so these must be manually allocated
268  call mem_allocate(this%x, this%dis%nodes, 'X', this%memoryPath)
269  call mem_allocate(this%rhs, this%dis%nodes, 'RHS', this%memoryPath)
270  call mem_allocate(this%ibound, this%dis%nodes, 'IBOUND', this%memoryPath)
271  do i = 1, this%dis%nodes
272  this%x(i) = dzero
273  this%rhs(i) = dzero
274  this%ibound(i) = 1
275  end do
276  end if
277  !
278  ! -- return
279  return
280  end subroutine allocate_arrays
281 
282  !> @brief Define packages of the model
283  !<
284  subroutine swf_df(this)
285  ! -- modules
286  ! -- dummy
287  class(swfmodeltype) :: this
288  ! -- local
289  integer(I4B) :: ip
290  class(bndtype), pointer :: packobj
291  !
292  !
293  call this%dis%dis_df()
294  call this%dfw%dfw_df(this%dis)
295  call this%oc%oc_df()
296  call this%budget%budget_df(niunit_swf, 'VOLUME', 'L**3')
297  !
298  ! -- set model sizes
299  this%neq = this%dis%nodes
300  this%nja = this%dis%nja
301  this%ia => this%dis%con%ia
302  this%ja => this%dis%con%ja
303  !
304  ! -- Allocate model arrays, now that neq and nja are known
305  call this%allocate_arrays()
306  !
307  ! -- Define packages and assign iout for time series managers
308  do ip = 1, this%bndlist%Count()
309  packobj => getbndfromlist(this%bndlist, ip)
310  call packobj%bnd_df(this%dis%nodes, this%dis)
311  end do
312  !
313  ! -- Store information needed for observations
314  call this%obs%obs_df(this%iout, this%name, 'SWF', this%dis)
315  !
316  ! -- return
317  return
318  end subroutine swf_df
319 
320  !> @brief Add the internal connections of this model to the sparse matrix
321  subroutine swf_ac(this, sparse)
322  ! -- modules
323  use sparsemodule, only: sparsematrix
324  ! -- dummy
325  class(swfmodeltype) :: this
326  type(sparsematrix), intent(inout) :: sparse
327  ! -- local
328  class(bndtype), pointer :: packobj
329  integer(I4B) :: ip
330  !
331  ! -- Add the primary grid connections of this model to sparse
332  call this%dis%dis_ac(this%moffset, sparse)
333  !
334  ! -- Add any additional connections
335  ! none
336  !
337  ! -- Add any package connections
338  do ip = 1, this%bndlist%Count()
339  packobj => getbndfromlist(this%bndlist, ip)
340  call packobj%bnd_ac(this%moffset, sparse)
341  end do
342  !
343  ! -- return
344  return
345  end subroutine swf_ac
346 
347  !> @brief Map the positions of this models connections in the
348  !! numerical solution coefficient matrix.
349  !<
350  subroutine swf_mc(this, matrix_sln)
351  ! -- dummy
352  class(swfmodeltype) :: this
353  class(matrixbasetype), pointer :: matrix_sln
354  ! -- local
355  class(bndtype), pointer :: packobj
356  integer(I4B) :: ip
357  !
358  ! -- Find the position of each connection in the global ia, ja structure
359  ! and store them in idxglo.
360  call this%dis%dis_mc(this%moffset, this%idxglo, matrix_sln)
361  !
362  ! -- Map any additional connections
363  ! none
364  !
365  ! -- Map any package connections
366  do ip = 1, this%bndlist%Count()
367  packobj => getbndfromlist(this%bndlist, ip)
368  call packobj%bnd_mc(this%moffset, matrix_sln)
369  end do
370  !
371  ! -- return
372  return
373  end subroutine swf_mc
374 
375  !> @brief SWF Allocate and Read
376  !<
377  subroutine swf_ar(this)
378  ! -- dummy
379  class(swfmodeltype) :: this
380  ! -- locals
381  integer(I4B), dimension(:), allocatable :: itemp
382  integer(I4B) :: ip
383  class(bndtype), pointer :: packobj
384  !
385  ! -- Allocate and read modules attached to model
386  if (this%inic > 0) call this%ic%ic_ar(this%x)
387 
388  ! -- need temporary integer variable to pass to dis_ar
389  ! -- TODO: this should be generalized so dis_ar doesn't have to have it
390  allocate (itemp(this%dis%nodes))
391  !
392  ! -- Call dis_ar to write binary grid file
393  call this%dis%dis_ar(itemp)
394  if (this%indfw > 0) call this%dfw%dfw_ar(this%ibound, this%x)
395  if (this%insto > 0) call this%sto%sto_ar(this%dis, this%ibound)
396  if (this%inobs > 0) call this%obs%swf_obs_ar(this%ic, this%x, this%flowja)
397  deallocate (itemp)
398  !
399  ! -- set up output control
400  if (this%indfw > 0) then
401  call this%oc%oc_ar('STAGE', this%x, this%dis, dnodata)
402  end if
403  call this%budget%set_ibudcsv(this%oc%ibudcsv)
404  !
405  ! -- Package input files now open, so allocate and read
406  do ip = 1, this%bndlist%Count()
407  packobj => getbndfromlist(this%bndlist, ip)
408  call packobj%set_pointers(this%dis%nodes, this%ibound, this%x, &
409  this%xold, this%flowja)
410  ! -- Read and allocate package
411  call packobj%bnd_ar()
412  end do
413  !
414  ! -- return
415  return
416  end subroutine swf_ar
417 
418  !> @brief Stream Network Flow Model Read and Prepare
419  !!
420  !! (1) calls package read and prepare routines
421  !!
422  !<
423  subroutine swf_rp(this)
424  ! -- modules
425  use tdismodule, only: readnewdata
426  ! -- dummy
427  class(swfmodeltype) :: this
428  ! -- local
429  class(bndtype), pointer :: packobj
430  integer(I4B) :: ip
431  !
432  ! -- Check with TDIS on whether or not it is time to RP
433  if (.not. readnewdata) return
434  !
435  ! -- Read and prepare
436  if (this%indfw > 0) call this%dfw%dfw_rp()
437  if (this%inoc > 0) call this%oc%oc_rp()
438  if (this%insto > 0) call this%sto%sto_rp()
439  !if (this%inmvr > 0) call this%mvr%mvr_rp()
440  do ip = 1, this%bndlist%Count()
441  packobj => getbndfromlist(this%bndlist, ip)
442  call packobj%bnd_rp()
443  call packobj%bnd_rp_obs()
444  end do
445  !
446  ! -- Check for steady state period
447  call this%steady_period_check()
448  !
449  ! -- Return
450  return
451  end subroutine swf_rp
452 
453  !> @brief Stream Network Flow Model Time Step Advance
454  !!
455  !! (1) calls package advance subroutines
456  !!
457  !<
458  subroutine swf_ad(this)
459  ! -- modules
461  ! -- dummy
462  class(swfmodeltype) :: this
463  class(bndtype), pointer :: packobj
464  ! -- local
465  integer(I4B) :: irestore
466  integer(I4B) :: ip, n
467  !
468  ! -- Reset state variable
469  irestore = 0
470  if (ifailedstepretry > 0) irestore = 1
471  if (irestore == 0) then
472  !
473  ! -- copy x into xold
474  do n = 1, this%dis%nodes
475  this%xold(n) = this%x(n)
476  end do
477  else
478  !
479  ! -- copy xold into x if this time step is a redo
480  do n = 1, this%dis%nodes
481  this%x(n) = this%xold(n)
482  end do
483  end if
484  !
485  ! -- Advance
486  if (this%indfw > 0) call this%dfw%dfw_ad(irestore)
487  if (this%insto > 0) call this%sto%sto_ad()
488  !if (this%inmvr > 0) call this%mvr%mvr_ad()
489  do ip = 1, this%bndlist%Count()
490  packobj => getbndfromlist(this%bndlist, ip)
491  call packobj%bnd_ad()
492  if (isimcheck > 0) then
493  call packobj%bnd_ck()
494  end if
495  end do
496  !
497  ! -- Push simulated values to preceding time/subtime step
498  call this%obs%obs_ad()
499  !
500  ! -- return
501  return
502  end subroutine swf_ad
503 
504  !> @brief Calculate coefficients
505  subroutine swf_cf(this, kiter)
506  ! -- dummy
507  class(swfmodeltype) :: this
508  integer(I4B), intent(in) :: kiter
509  ! -- local
510  class(bndtype), pointer :: packobj
511  integer(I4B) :: ip
512  !
513  ! -- Call package cf routines
514  !if (this%indfw > 0) call this%dfw%dfw_cf(kiter, this%dis%nodes, this%x)
515  do ip = 1, this%bndlist%Count()
516  packobj => getbndfromlist(this%bndlist, ip)
517  call packobj%bnd_cf()
518  end do
519  !
520  ! -- return
521  return
522  end subroutine swf_cf
523 
524  !> @brief Fill coefficients
525  subroutine swf_fc(this, kiter, matrix_sln, inwtflag)
526  ! -- dummy
527  class(swfmodeltype) :: this
528  integer(I4B), intent(in) :: kiter
529  class(matrixbasetype), pointer :: matrix_sln
530  integer(I4B), intent(in) :: inwtflag
531  ! -- local
532  class(bndtype), pointer :: packobj
533  integer(I4B) :: ip
534  integer(I4B) :: inwt, inwtpak
535  !
536  ! -- newton flags
537  inwt = inwtflag
538  ! if (inwtflag == 1) inwt = this%dfw%inewton
539  ! inwtsto = inwtflag
540  ! if (this%insto > 0) then
541  ! if (inwtflag == 1) inwtsto = this%sto%inewton
542  ! end if
543  ! inwtcsub = inwtflag
544  ! if (this%incsub > 0) then
545  ! if (inwtflag == 1) inwtcsub = this%csub%inewton
546  ! end if
547  !
548  ! -- Fill standard conductance terms
549  if (this%indfw > 0) call this%dfw%dfw_fc(kiter, matrix_sln, this%idxglo, &
550  this%rhs, this%x, this%xold)
551  ! -- storage
552  if (this%insto > 0) then
553  call this%sto%sto_fc(kiter, this%xold, this%x, matrix_sln, &
554  this%idxglo, this%rhs)
555  end if
556  ! if (this%inmvr > 0) call this%mvr%mvr_fc()
557  do ip = 1, this%bndlist%Count()
558  packobj => getbndfromlist(this%bndlist, ip)
559  call packobj%bnd_fc(this%rhs, this%ia, this%idxglo, matrix_sln)
560  end do
561  !
562  !--Fill newton terms
563  if (this%indfw > 0) then
564  if (inwt /= 0) then
565  call this%dfw%dfw_fn(kiter, matrix_sln, this%idxglo, this%rhs, this%x)
566  end if
567  end if
568  !
569  ! -- Fill newton terms for storage
570  ! if (this%insto > 0) then
571  ! if (inwtsto /= 0) then
572  ! call this%sto%sto_fn(kiter, this%xold, this%x, matrix_sln, &
573  ! this%idxglo, this%rhs)
574  ! end if
575  ! end if
576  !
577  ! -- Fill Newton terms for packages
578  do ip = 1, this%bndlist%Count()
579  packobj => getbndfromlist(this%bndlist, ip)
580  inwtpak = inwtflag
581  if (inwtflag == 1) inwtpak = packobj%inewton
582  if (inwtpak /= 0) then
583  call packobj%bnd_fn(this%rhs, this%ia, this%idxglo, matrix_sln)
584  end if
585  end do
586  !
587  ! -- return
588  return
589  end subroutine swf_fc
590 
591  !> @brief under-relaxation
592  !!
593  !! (1) Under-relaxation of Surface water Flow Model stages for current
594  !! outer iteration using the reach bottoms
595  !!
596  !<
597  subroutine swf_nur(this, neqmod, x, xtemp, dx, inewtonur, dxmax, locmax)
598  ! modules
599  use constantsmodule, only: done, dp9
600  ! -- dummy
601  class(swfmodeltype) :: this
602  integer(I4B), intent(in) :: neqmod
603  real(DP), dimension(neqmod), intent(inout) :: x
604  real(DP), dimension(neqmod), intent(in) :: xtemp
605  real(DP), dimension(neqmod), intent(inout) :: dx
606  integer(I4B), intent(inout) :: inewtonur
607  real(DP), intent(inout) :: dxmax
608  integer(I4B), intent(inout) :: locmax
609  ! -- local
610  integer(I4B) :: i0
611  integer(I4B) :: i1
612  class(bndtype), pointer :: packobj
613  integer(I4B) :: ip
614  !
615  ! -- apply Newton-Raphson under-relaxation if model is using
616  ! the Newton-Raphson formulation and this Newton-Raphson
617  ! under-relaxation is turned on.
618  if (this%inewton /= 0 .and. this%inewtonur /= 0) then
619  if (this%indfw > 0) then
620  call this%dfw%dfw_nur(neqmod, x, xtemp, dx, inewtonur, dxmax, locmax)
621  end if
622  !
623  ! -- Call package nur routines
624  i0 = this%dis%nodes + 1
625  do ip = 1, this%bndlist%Count()
626  packobj => getbndfromlist(this%bndlist, ip)
627  if (packobj%npakeq > 0) then
628  i1 = i0 + packobj%npakeq - 1
629  call packobj%bnd_nur(packobj%npakeq, x(i0:i1), xtemp(i0:i1), &
630  dx(i0:i1), inewtonur, dxmax, locmax)
631  i0 = i1 + 1
632  end if
633  end do
634  end if
635  !
636  ! -- return
637  return
638  end subroutine swf_nur
639 
640  !> @brief Calculate flow
641  !<
642  subroutine swf_cq(this, icnvg, isuppress_output)
643  ! -- modules
644  ! -- dummy
645  class(swfmodeltype) :: this
646  integer(I4B), intent(in) :: icnvg
647  integer(I4B), intent(in) :: isuppress_output
648  ! -- local
649  integer(I4B) :: i
650  integer(I4B) :: ip
651  class(bndtype), pointer :: packobj
652  !
653  ! -- Construct the flowja array. Flowja is calculated each time, even if
654  ! output is suppressed. (flowja is positive into a cell.) The diagonal
655  ! position of the flowja array will contain the flow residual after
656  ! these routines are called, so each package is responsible for adding
657  ! its flow to this diagonal position.
658  do i = 1, this%dis%nja
659  this%flowja(i) = dzero
660  end do
661  if (this%indfw > 0) call this%dfw%dfw_cq(this%x, this%xold, this%flowja)
662  if (this%insto > 0) call this%sto%sto_cq(this%flowja, this%x, this%xold)
663  !
664  ! -- Go through packages and call cq routines. cf() routines are called
665  ! first to regenerate non-linear terms to be consistent with the final
666  ! head solution.
667  do ip = 1, this%bndlist%Count()
668  packobj => getbndfromlist(this%bndlist, ip)
669  call packobj%bnd_cf()
670  call packobj%bnd_cq(this%x, this%flowja)
671  end do
672  !
673  ! -- Return
674  return
675  end subroutine swf_cq
676 
677  !> @brief Model Budget
678  !<
679  subroutine swf_bd(this, icnvg, isuppress_output)
680  ! -- modules
681  use sparsemodule, only: csr_diagsum
682  ! -- dummy
683  class(swfmodeltype) :: this
684  integer(I4B), intent(in) :: icnvg
685  integer(I4B), intent(in) :: isuppress_output
686  ! -- local
687  integer(I4B) :: ip
688  class(bndtype), pointer :: packobj
689  !
690  ! -- Finalize calculation of flowja by adding face flows to the diagonal.
691  ! This results in the flow residual being stored in the diagonal
692  ! position for each cell.
693  call csr_diagsum(this%dis%con%ia, this%flowja)
694  !
695  ! -- Budget routines (start by resetting). Sole purpose of this section
696  ! is to add in and outs to model budget. All ins and out for a model
697  ! should be added here to this%budget. In a subsequent exchange call,
698  ! exchange flows might also be added.
699  call this%budget%reset()
700  if (this%insto > 0) call this%sto%sto_bd(isuppress_output, this%budget)
701  if (this%indfw > 0) call this%dfw%dfw_bd(isuppress_output, this%budget)
702  do ip = 1, this%bndlist%Count()
703  packobj => getbndfromlist(this%bndlist, ip)
704  call packobj%bnd_bd(this%budget)
705  end do
706  !
707  ! -- dfw velocities have to be calculated here, after swf-swf exchanges
708  ! have passed in their contributions from exg_cq()
709  if (this%indfw > 0) then
710  if (this%dfw%icalcvelocity /= 0) then
711  call this%dfw%calc_velocity(this%flowja)
712  end if
713  end if
714  !
715  ! -- Return
716  return
717  end subroutine swf_bd
718 
719  !> @brief Stream Network Flow Model Output
720  subroutine swf_ot(this)
721  ! -- modules
722  use tdismodule, only: tdis_ot, endofperiod
723  ! -- dummy
724  class(swfmodeltype) :: this
725  ! -- local
726  integer(I4B) :: idvsave
727  integer(I4B) :: idvprint
728  integer(I4B) :: icbcfl
729  integer(I4B) :: icbcun
730  integer(I4B) :: ibudfl
731  integer(I4B) :: ipflag
732  integer(I4B) :: icnvg = 1
733  ! -- formats
734  !
735  ! -- Set write and print flags
736  idvsave = 0
737  idvprint = 0
738  icbcfl = 0
739  ibudfl = 0
740  if (this%oc%oc_save('QOUTFLOW')) idvsave = 1
741  if (this%oc%oc_print('QOUTFLOW')) idvprint = 1
742  if (this%oc%oc_save('BUDGET')) icbcfl = 1
743  if (this%oc%oc_print('BUDGET')) ibudfl = 1
744  icbcun = this%oc%oc_save_unit('BUDGET')
745  !
746  ! -- Override ibudfl and idvprint flags for nonconvergence
747  ! and end of period
748  ibudfl = this%oc%set_print_flag('BUDGET', icnvg, endofperiod)
749  idvprint = this%oc%set_print_flag('QOUTFLOW', icnvg, endofperiod)
750  !
751  ! Calculate and save observations
752  call this%swf_ot_obs()
753  ! !
754  ! Save and print flows
755  call this%swf_ot_flow(icbcfl, ibudfl, icbcun)
756  !
757  ! Save and print dependent variables
758  call this%swf_ot_dv(idvsave, idvprint, ipflag)
759  !
760  ! Print budget summaries
761  call this%swf_ot_bdsummary(ibudfl, ipflag)
762  !
763  ! -- Timing Output; if any dependent variables or budgets
764  ! are printed, then ipflag is set to 1.
765  if (ipflag == 1) call tdis_ot(this%iout)
766  !
767  ! -- Return
768  return
769  end subroutine swf_ot
770 
771  subroutine swf_ot_obs(this)
772  class(swfmodeltype) :: this
773  class(bndtype), pointer :: packobj
774  integer(I4B) :: ip
775 
776  ! -- Calculate and save SWF observations
777  call this%obs%obs_bd()
778  call this%obs%obs_ot()
779 
780  ! -- Calculate and save dfw observations
781  if (this%indfw > 0) then
782  call this%dfw%dfw_bd_obs()
783  call this%dfw%obs%obs_ot()
784  end if
785 
786  ! -- Calculate and save package observations
787  do ip = 1, this%bndlist%Count()
788  packobj => getbndfromlist(this%bndlist, ip)
789  call packobj%bnd_bd_obs()
790  call packobj%bnd_ot_obs()
791  end do
792 
793  end subroutine swf_ot_obs
794 
795  subroutine swf_ot_flow(this, icbcfl, ibudfl, icbcun)
796  class(swfmodeltype) :: this
797  integer(I4B), intent(in) :: icbcfl
798  integer(I4B), intent(in) :: ibudfl
799  integer(I4B), intent(in) :: icbcun
800  class(bndtype), pointer :: packobj
801  integer(I4B) :: ip
802 
803  ! -- Save SWF flows
804  if (this%insto > 0) then
805  call this%sto%sto_save_model_flows(icbcfl, icbcun)
806  end if
807  if (this%indfw > 0) then
808  call this%dfw%dfw_save_model_flows(this%flowja, icbcfl, icbcun)
809  end if
810  do ip = 1, this%bndlist%Count()
811  packobj => getbndfromlist(this%bndlist, ip)
812  call packobj%bnd_ot_model_flows(icbcfl=icbcfl, ibudfl=0, icbcun=icbcun)
813  end do
814 
815  ! -- Save advanced package flows
816  do ip = 1, this%bndlist%Count()
817  packobj => getbndfromlist(this%bndlist, ip)
818  call packobj%bnd_ot_package_flows(icbcfl=icbcfl, ibudfl=0)
819  end do
820  ! if (this%inmvr > 0) then
821  ! call this%mvr%mvr_ot_saveflow(icbcfl, ibudfl)
822  ! end if
823 
824  ! -- Print SWF flows
825  if (this%indfw > 0) then
826  call this%dfw%dfw_print_model_flows(ibudfl, this%flowja)
827  end if
828  do ip = 1, this%bndlist%Count()
829  packobj => getbndfromlist(this%bndlist, ip)
830  call packobj%bnd_ot_model_flows(icbcfl=icbcfl, ibudfl=ibudfl, icbcun=0)
831  end do
832 
833  ! -- Print advanced package flows
834  do ip = 1, this%bndlist%Count()
835  packobj => getbndfromlist(this%bndlist, ip)
836  call packobj%bnd_ot_package_flows(icbcfl=0, ibudfl=ibudfl)
837  end do
838  ! if (this%inmvr > 0) then
839  ! call this%mvr%mvr_ot_printflow(icbcfl, ibudfl)
840  ! end if
841 
842  end subroutine swf_ot_flow
843 
844  subroutine swf_ot_dv(this, idvsave, idvprint, ipflag)
845  class(swfmodeltype) :: this
846  integer(I4B), intent(in) :: idvsave
847  integer(I4B), intent(in) :: idvprint
848  integer(I4B), intent(inout) :: ipflag
849  class(bndtype), pointer :: packobj
850  integer(I4B) :: ip
851  !
852  ! -- Print advanced package dependent variables
853  do ip = 1, this%bndlist%Count()
854  packobj => getbndfromlist(this%bndlist, ip)
855  call packobj%bnd_ot_dv(idvsave, idvprint)
856  end do
857  !
858  ! -- save stage and print stage (if implemented)
859  call this%oc%oc_ot(ipflag)
860  !
861  ! -- Return
862  return
863  end subroutine swf_ot_dv
864 
865  subroutine swf_ot_bdsummary(this, ibudfl, ipflag)
866  use tdismodule, only: kstp, kper, totim, delt
867  class(swfmodeltype) :: this
868  integer(I4B), intent(in) :: ibudfl
869  integer(I4B), intent(inout) :: ipflag
870  class(bndtype), pointer :: packobj
871  integer(I4B) :: ip
872 
873  !
874  ! -- Package budget summary
875  do ip = 1, this%bndlist%Count()
876  packobj => getbndfromlist(this%bndlist, ip)
877  call packobj%bnd_ot_bdsummary(kstp, kper, this%iout, ibudfl)
878  end do
879 
880  ! ! -- mover budget summary
881  ! if (this%inmvr > 0) then
882  ! call this%mvr%mvr_ot_bdsummary(ibudfl)
883  ! end if
884 
885  ! -- model budget summary
886  call this%budget%finalize_step(delt)
887  if (ibudfl /= 0) then
888  ipflag = 1
889  call this%budget%budget_ot(kstp, kper, this%iout)
890  end if
891 
892  ! -- Write to budget csv every time step
893  call this%budget%writecsv(totim)
894 
895  end subroutine swf_ot_bdsummary
896 
897  !> @brief Deallocate
898  subroutine swf_da(this)
899  ! -- modules
903  ! -- dummy
904  class(swfmodeltype) :: this
905  ! -- local
906  integer(I4B) :: ip
907  class(bndtype), pointer :: packobj
908  !
909  ! -- Deallocate idm memory
910  call memorylist_remove(this%name, 'NAM', idm_context)
911  call memorylist_remove(component=this%name, context=idm_context)
912  !
913  ! -- Internal flow packages deallocate
914  call this%dis%dis_da()
915  if (this%insto > 0) call this%sto%sto_da()
916  if (this%inic > 0) call this%ic%ic_da()
917  if (this%indfw > 0) call this%dfw%dfw_da()
918  call this%cxs%cxs_da()
919  call this%obs%obs_da()
920  call this%oc%oc_da()
921  call this%budget%budget_da()
922  !
923  ! -- Internal package objects
924  deallocate (this%dis)
925  deallocate (this%budget)
926  deallocate (this%obs)
927  deallocate (this%oc)
928  !
929  ! -- Boundary packages
930  do ip = 1, this%bndlist%Count()
931  packobj => getbndfromlist(this%bndlist, ip)
932  call packobj%bnd_da()
933  deallocate (packobj)
934  end do
935  !
936  ! -- Scalars
937  call mem_deallocate(this%inic)
938  call mem_deallocate(this%indfw)
939  call mem_deallocate(this%incxs)
940  call mem_deallocate(this%insto)
941  call mem_deallocate(this%inobs)
942  call mem_deallocate(this%inoc)
943  call mem_deallocate(this%iss)
944  call mem_deallocate(this%inewtonur)
945  !
946  ! -- Arrays
947  !
948  ! -- NumericalModelType
949  call this%NumericalModelType%model_da()
950  !
951  ! -- return
952  return
953  end subroutine swf_da
954 
955  !> @brief Surface Flow Model Budget Entry
956  !!
957  !! This subroutine adds a budget entry to the flow budget. It was added as
958  !! a method for the swf model object so that the exchange object could add its
959  !! contributions.
960  !!
961  !! (1) adds the entry to the budget object
962  !<
963  subroutine swf_bdentry(this, budterm, budtxt, rowlabel)
964  ! -- modules
965  use constantsmodule, only: lenbudtxt
966  use tdismodule, only: delt
967  ! -- dummy
968  class(swfmodeltype) :: this
969  real(DP), dimension(:, :), intent(in) :: budterm
970  character(len=LENBUDTXT), dimension(:), intent(in) :: budtxt
971  character(len=*), intent(in) :: rowlabel
972  !
973  call this%budget%addentry(budterm, delt, budtxt, rowlabel=rowlabel)
974  !
975  ! -- return
976  return
977  end subroutine swf_bdentry
978 
979  !> @brief Create boundary condition packages for this model
980  !<
981  subroutine package_create(this, filtyp, ipakid, ipaknum, pakname, mempath, &
982  inunit, iout)
983  ! -- modules
984  use constantsmodule, only: linelength
986  use swfflwmodule, only: flw_create
987  use chdmodule, only: chd_create
988  use swfcdbmodule, only: cdb_create
989  use swfzdgmodule, only: zdg_create
990  ! -- dummy
991  class(swfmodeltype) :: this
992  character(len=*), intent(in) :: filtyp
993  integer(I4B), intent(in) :: ipakid
994  integer(I4B), intent(in) :: ipaknum
995  character(len=*), intent(in) :: pakname
996  character(len=*), intent(in) :: mempath
997  integer(I4B), intent(in) :: inunit
998  integer(I4B), intent(in) :: iout
999  ! -- local
1000  class(bndtype), pointer :: packobj
1001  class(bndtype), pointer :: packobj2
1002  integer(I4B) :: ip
1003  !
1004  ! -- This part creates the package object
1005  select case (filtyp)
1006  case ('FLW6')
1007  call flw_create(packobj, ipakid, ipaknum, inunit, iout, this%name, &
1008  pakname, mempath)
1009  packobj%ictMemPath = ''
1010  case ('CHD6')
1011  call chd_create(packobj, ipakid, ipaknum, inunit, iout, this%name, &
1012  pakname, mempath)
1013  packobj%ictMemPath = create_mem_path(this%name, 'DFW')
1014  case ('CDB6')
1015  call cdb_create(packobj, ipakid, ipaknum, inunit, iout, this%name, &
1016  pakname, mempath, this%dis, this%cxs, &
1017  this%dfw%lengthconv, this%dfw%timeconv)
1018  case ('ZDG6')
1019  call zdg_create(packobj, ipakid, ipaknum, inunit, iout, this%name, &
1020  pakname, mempath, this%dis, this%cxs, this%dfw%unitconv)
1021  case default
1022  write (errmsg, *) 'Invalid package type: ', filtyp
1023  call store_error(errmsg)
1024  call store_error_filename(this%filename)
1025  end select
1026  !
1027  ! -- Check to make sure that the package name is unique, then store a
1028  ! pointer to the package in the model bndlist
1029  do ip = 1, this%bndlist%Count()
1030  packobj2 => getbndfromlist(this%bndlist, ip)
1031  if (packobj2%packName == pakname) then
1032  write (errmsg, '(a,a)') 'Cannot create package. Package name '// &
1033  'already exists: ', trim(pakname)
1034  call store_error(errmsg, terminate=.true.)
1035  end if
1036  end do
1037  call addbndtolist(this%bndlist, packobj)
1038  !
1039  ! -- return
1040  return
1041  end subroutine package_create
1042 
1043  !> @brief Check to make sure required input files have been specified
1044  subroutine ftype_check(this, indis)
1045  ! -- modules
1046  ! -- dummy
1047  class(swfmodeltype) :: this
1048  integer(I4B), intent(in) :: indis
1049  ! -- local
1050  !
1051  ! -- Check for required packages. Stop if not present.
1052  if (indis == 0) then
1053  write (errmsg, '(a)') &
1054  'Discretization Package (DISV1D6 or DIS2D6) not specified.'
1055  call store_error(errmsg)
1056  end if
1057  if (this%inic == 0 .and. this%indfw /= 0) then
1058  write (errmsg, '(a)') &
1059  'Initial Conditions (IC6) must be specified if the Diffusive &
1060  &Wave (DFW) package is used.'
1061  call store_error(errmsg)
1062  end if
1063  if (this%indfw == 0) then
1064  write (errmsg, '(1x,a)') &
1065  'DFW6 Package must be specified.'
1066  call store_error(errmsg)
1067  end if
1068  if (count_errors() > 0) then
1069  write (errmsg, '(a)') 'One or more required package(s) not specified.'
1070  call store_error(errmsg)
1071  call store_error_filename(this%filename)
1072  end if
1073  !
1074  ! -- return
1075  return
1076  end subroutine ftype_check
1077 
1078  !> @brief Source package info and begin to process
1079  !<
1080  subroutine create_bndpkgs(this, bndpkgs, pkgtypes, pkgnames, &
1081  mempaths, inunits)
1082  ! -- modules
1085  ! -- dummy
1086  class(swfmodeltype) :: this
1087  integer(I4B), dimension(:), allocatable, intent(inout) :: bndpkgs
1088  type(characterstringtype), dimension(:), contiguous, &
1089  pointer, intent(inout) :: pkgtypes
1090  type(characterstringtype), dimension(:), contiguous, &
1091  pointer, intent(inout) :: pkgnames
1092  type(characterstringtype), dimension(:), contiguous, &
1093  pointer, intent(inout) :: mempaths
1094  integer(I4B), dimension(:), contiguous, &
1095  pointer, intent(inout) :: inunits
1096  ! -- local
1097  integer(I4B) :: ipakid, ipaknum
1098  character(len=LENFTYPE) :: pkgtype, bndptype
1099  character(len=LENPACKAGENAME) :: pkgname
1100  character(len=LENMEMPATH) :: mempath
1101  integer(I4B), pointer :: inunit
1102  integer(I4B) :: n
1103 
1104  if (allocated(bndpkgs)) then
1105  !
1106  ! -- create stress packages
1107  ipakid = 1
1108  bndptype = ''
1109  do n = 1, size(bndpkgs)
1110  !
1111  pkgtype = pkgtypes(bndpkgs(n))
1112  pkgname = pkgnames(bndpkgs(n))
1113  mempath = mempaths(bndpkgs(n))
1114  inunit => inunits(bndpkgs(n))
1115  !
1116  if (bndptype /= pkgtype) then
1117  ipaknum = 1
1118  bndptype = pkgtype
1119  end if
1120  !
1121  call this%package_create(pkgtype, ipakid, ipaknum, pkgname, mempath, &
1122  inunit, this%iout)
1123  ipakid = ipakid + 1
1124  ipaknum = ipaknum + 1
1125  end do
1126  !
1127  ! -- cleanup
1128  deallocate (bndpkgs)
1129  end if
1130  !
1131  ! -- return
1132  return
1133  end subroutine create_bndpkgs
1134 
1135  !> @brief Source package info and begin to process
1136  !<
1137  subroutine create_packages(this)
1138  ! -- modules
1141  use arrayhandlersmodule, only: expandarray
1142  use memorymanagermodule, only: mem_setptr
1144  use simvariablesmodule, only: idm_context
1145  use disv1dmodule, only: disv1d_cr
1146  use dis2dmodule, only: dis2d_cr
1147  use disv2dmodule, only: disv2d_cr
1148  use swfdfwmodule, only: dfw_cr
1149  use swfcxsmodule, only: cxs_cr
1150  use swfstomodule, only: sto_cr
1151  use swficmodule, only: ic_cr
1152  use swfocmodule, only: oc_cr
1153  ! -- dummy
1154  class(swfmodeltype) :: this
1155  ! -- local
1156  type(characterstringtype), dimension(:), contiguous, &
1157  pointer :: pkgtypes => null()
1158  type(characterstringtype), dimension(:), contiguous, &
1159  pointer :: pkgnames => null()
1160  type(characterstringtype), dimension(:), contiguous, &
1161  pointer :: mempaths => null()
1162  integer(I4B), dimension(:), contiguous, &
1163  pointer :: inunits => null()
1164  character(len=LENMEMPATH) :: model_mempath
1165  character(len=LENPACKAGETYPE) :: pkgtype
1166  character(len=LENPACKAGENAME) :: pkgname
1167  character(len=LENMEMPATH) :: mempath
1168  integer(I4B), pointer :: inunit
1169  integer(I4B), dimension(:), allocatable :: bndpkgs
1170  integer(I4B) :: n
1171  integer(I4B) :: indis = 0 ! DIS enabled flag
1172  character(len=LENMEMPATH) :: mempathic = ''
1173  character(len=LENMEMPATH) :: mempathdfw = ''
1174  character(len=LENMEMPATH) :: mempathcxs = ''
1175  !
1176  ! -- set input model memory path
1177  model_mempath = create_mem_path(component=this%name, context=idm_context)
1178  !
1179  ! -- set pointers to model path package info
1180  call mem_setptr(pkgtypes, 'PKGTYPES', model_mempath)
1181  call mem_setptr(pkgnames, 'PKGNAMES', model_mempath)
1182  call mem_setptr(mempaths, 'MEMPATHS', model_mempath)
1183  call mem_setptr(inunits, 'INUNITS', model_mempath)
1184  !
1185  do n = 1, size(pkgtypes)
1186  !
1187  ! attributes for this input package
1188  pkgtype = pkgtypes(n)
1189  pkgname = pkgnames(n)
1190  mempath = mempaths(n)
1191  inunit => inunits(n)
1192  !
1193  ! -- create dis package as it is a prerequisite for other packages
1194  select case (pkgtype)
1195  case ('DISV1D6')
1196  indis = 1
1197  call disv1d_cr(this%dis, this%name, mempath, indis, this%iout)
1198  case ('DIS2D6')
1199  indis = 1
1200  call dis2d_cr(this%dis, this%name, mempath, indis, this%iout)
1201  case ('DISV2D6')
1202  indis = 1
1203  call disv2d_cr(this%dis, this%name, mempath, indis, this%iout)
1204  case ('DFW6')
1205  this%indfw = 1
1206  mempathdfw = mempath
1207  case ('CXS6')
1208  this%incxs = 1
1209  mempathcxs = mempath
1210  case ('STO6')
1211  this%insto = inunit
1212  case ('IC6')
1213  this%inic = 1
1214  mempathic = mempath
1215  case ('OC6')
1216  this%inoc = inunit
1217  case ('OBS6')
1218  this%inobs = inunit
1219  case ('CHD6', 'FLW6', 'CDB6', 'ZDG6')
1220  call expandarray(bndpkgs)
1221  bndpkgs(size(bndpkgs)) = n
1222  case default
1223  ! TODO
1224  end select
1225  end do
1226  !
1227  ! -- Create packages that are tied directly to model
1228  if (this%inic > 0) then
1229  call ic_cr(this%ic, this%name, mempathic, this%inic, this%iout, &
1230  this%dis)
1231  end if
1232  call cxs_cr(this%cxs, this%name, mempathcxs, this%incxs, this%iout, &
1233  this%dis)
1234  if (this%indfw > 0) then
1235  call dfw_cr(this%dfw, this%name, mempathdfw, this%indfw, this%iout, &
1236  this%cxs)
1237  end if
1238  if (this%insto > 0) then
1239  call sto_cr(this%sto, this%name, this%insto, this%iout, this%cxs)
1240  end if
1241  call oc_cr(this%oc, this%name, this%inoc, this%iout)
1242  call swf_obs_cr(this%obs, this%inobs)
1243  !
1244  ! -- Check to make sure that required ftype's have been specified
1245  call this%ftype_check(indis)
1246  !
1247  call this%create_bndpkgs(bndpkgs, pkgtypes, pkgnames, mempaths, inunits)
1248  !
1249  ! -- return
1250  return
1251  end subroutine create_packages
1252 
1253  !> @brief Write model namfile options to list file
1254  !<
1255  subroutine log_namfile_options(this, found)
1257  class(swfmodeltype) :: this
1258  type(swfnamparamfoundtype), intent(in) :: found
1259 
1260  write (this%iout, '(1x,a)') 'NAMEFILE OPTIONS:'
1261 
1262  if (found%print_input) then
1263  write (this%iout, '(4x,a)') 'STRESS PACKAGE INPUT WILL BE PRINTED '// &
1264  'FOR ALL MODEL STRESS PACKAGES'
1265  end if
1266 
1267  if (found%print_flows) then
1268  write (this%iout, '(4x,a)') 'PACKAGE FLOWS WILL BE PRINTED '// &
1269  'FOR ALL MODEL PACKAGES'
1270  end if
1271 
1272  if (found%save_flows) then
1273  write (this%iout, '(4x,a)') &
1274  'FLOWS WILL BE SAVED TO BUDGET FILE SPECIFIED IN OUTPUT CONTROL'
1275  end if
1276 
1277  write (this%iout, '(1x,a)') 'END NAMEFILE OPTIONS:'
1278  end subroutine log_namfile_options
1279 
1280  !> @brief Check for steady state period
1281  !!
1282  !! Write warning message if steady state
1283  !! period and adaptive time stepping is
1284  !! active for the period
1285  !!
1286  !<
1287  subroutine steady_period_check(this)
1288  ! -- modules
1289  use tdismodule, only: kper
1291  use simvariablesmodule, only: warnmsg
1292  use simmodule, only: store_warning
1293  ! -- dummy
1294  class(swfmodeltype) :: this
1295  if (this%iss == 1) then
1296  if (isadaptiveperiod(kper)) then
1297  write (warnmsg, '(a,a,a,i0,a)') &
1298  'SWF Model (', trim(this%name), ') is steady state for period ', &
1299  kper, ' and adaptive time stepping is active. Adaptive time &
1300  &stepping may not work properly for steady-state conditions.'
1301  call store_warning(warnmsg)
1302  end if
1303  end if
1304  return
1305  end subroutine steady_period_check
1306 
1307  !> @brief return 1 if any package causes the matrix to be asymmetric.
1308  !! Otherwise return 0.
1309  !<
1310  function swf_get_iasym(this) result(iasym)
1311  class(swfmodeltype) :: this
1312  ! -- local
1313  integer(I4B) :: iasym
1314  integer(I4B) :: ip
1315  class(bndtype), pointer :: packobj
1316  !
1317  ! -- Start by setting iasym to zero
1318  iasym = 0
1319  !
1320  ! -- DFW
1321  if (this%indfw > 0) then
1322  iasym = 1
1323  end if
1324  !
1325  ! -- Check for any packages that introduce matrix asymmetry
1326  do ip = 1, this%bndlist%Count()
1327  packobj => getbndfromlist(this%bndlist, ip)
1328  if (packobj%iasym /= 0) iasym = 1
1329  end do
1330  !
1331  ! -- return
1332  return
1333  end function swf_get_iasym
1334 
1335 end module swfmodule
logical(lgp) function, public isadaptiveperiod(kper)
@ brief Determine if period is adaptive
Definition: ats.f90:45
subroutine, public addbasemodeltolist(list, model)
Definition: BaseModel.f90:161
This module contains the base boundary package.
subroutine, public addbndtolist(list, bnd)
Add boundary to package list.
class(bndtype) function, pointer, public getbndfromlist(list, idx)
Get boundary from package list.
This module contains the BudgetModule.
Definition: Budget.f90:20
subroutine, public budget_cr(this, name_model)
@ brief Create a new budget object
Definition: Budget.f90:84
subroutine, public chd_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath)
Create a new constant head package.
Definition: gwf-chd.f90:56
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:44
integer(i4b), parameter lenpackagename
maximum length of the package name
Definition: Constants.f90:22
real(dp), parameter dp9
real constant 9/10
Definition: Constants.f90:71
real(dp), parameter dnodata
real no data constant
Definition: Constants.f90:94
integer(i4b), parameter lenpackagetype
maximum length of a package type (DIS6, SFR6, CSUB6, etc.)
Definition: Constants.f90:37
integer(i4b), parameter lenftype
maximum length of a package type (DIS, WEL, OC, etc.)
Definition: Constants.f90:38
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:64
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
Definition: Constants.f90:36
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:26
real(dp), parameter done
real constant 1
Definition: Constants.f90:75
subroutine, public dis2d_cr(dis, name_model, input_mempath, inunit, iout)
Create a new structured discretization object.
Definition: Dis2d.f90:93
subroutine, public disv1d_cr(dis, name_model, input_mempath, inunit, iout)
Definition: Disv1d.f90:90
subroutine, public disv2d_cr(dis, name_model, input_mempath, inunit, iout)
Create a new discretization by vertices object.
Definition: Disv2d.f90:94
This module defines variable data types.
Definition: kind.f90:8
type(listtype), public basemodellist
Definition: mf6lists.f90:16
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public memorylist_remove(component, subcomponent, context)
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public store_warning(msg, substring)
Store warning message.
Definition: Sim.f90:236
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
integer(i4b) function, public count_errors()
Return number of errors.
Definition: Sim.f90:59
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition: Sim.f90:203
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=maxcharlen) errmsg
error message string
character(len=linelength) idm_context
integer(i4b) isimcheck
simulation input check flag (1) to check input, (0) to ignore checks
integer(i4b) ifailedstepretry
current retry for this time step
character(len=maxcharlen) warnmsg
warning message string
subroutine csr_diagsum(ia, flowja)
Definition: Sparse.f90:281
This module contains the CDB package methods.
Definition: swf-cdb.f90:7
subroutine, public cdb_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath, dis, cxs, lengthconv, timeconv)
@ brief Create a new package object
Definition: swf-cdb.f90:75
subroutine, public cxs_cr(pobj, name_model, input_mempath, inunit, iout, dis)
create package
Definition: swf-cxs.f90:62
This module contains the FLW package methods.
Definition: swf-flw.f90:7
subroutine, public flw_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath)
@ brief Create a new package object
Definition: swf-flw.f90:65
subroutine, public ic_cr(ic, name_model, input_mempath, inunit, iout, dis)
Create a new initial conditions object.
Definition: swf-ic.f90:33
Stream Network Flow (SWF) Module.
Definition: swf.f90:38
subroutine swf_ad(this)
Stream Network Flow Model Time Step Advance.
Definition: swf.f90:459
character(len=lenpackagetype), dimension(swf_nbasepkg), public swf_basepkg
Definition: swf.f90:118
subroutine swf_ar(this)
SWF Allocate and Read.
Definition: swf.f90:378
subroutine create_packages(this)
Source package info and begin to process.
Definition: swf.f90:1138
subroutine swf_bdentry(this, budterm, budtxt, rowlabel)
Surface Flow Model Budget Entry.
Definition: swf.f90:964
subroutine swf_cf(this, kiter)
Calculate coefficients.
Definition: swf.f90:506
subroutine package_create(this, filtyp, ipakid, ipaknum, pakname, mempath, inunit, iout)
Create boundary condition packages for this model.
Definition: swf.f90:983
subroutine swf_df(this)
Define packages of the model.
Definition: swf.f90:285
integer(i4b), parameter niunit_swf
Definition: swf.f90:134
subroutine create_bndpkgs(this, bndpkgs, pkgtypes, pkgnames, mempaths, inunits)
Source package info and begin to process.
Definition: swf.f90:1082
character(len=lenpackagetype), dimension(swf_nmultipkg), public swf_multipkg
Definition: swf.f90:129
subroutine swf_ot_obs(this)
Definition: swf.f90:772
subroutine allocate_scalars(this, modelname)
Allocate memory for scalar members.
Definition: swf.f90:221
integer(i4b), parameter, public swf_nbasepkg
SWF base package array descriptors.
Definition: swf.f90:117
subroutine steady_period_check(this)
Check for steady state period.
Definition: swf.f90:1288
subroutine swf_ot_dv(this, idvsave, idvprint, ipflag)
Definition: swf.f90:845
subroutine log_namfile_options(this, found)
Write model namfile options to list file.
Definition: swf.f90:1256
subroutine swf_mc(this, matrix_sln)
Map the positions of this models connections in the numerical solution coefficient matrix.
Definition: swf.f90:351
subroutine swf_ac(this, sparse)
Add the internal connections of this model to the sparse matrix.
Definition: swf.f90:322
subroutine swf_ot_bdsummary(this, ibudfl, ipflag)
Definition: swf.f90:866
integer(i4b) function swf_get_iasym(this)
return 1 if any package causes the matrix to be asymmetric. Otherwise return 0.
Definition: swf.f90:1311
subroutine swf_nur(this, neqmod, x, xtemp, dx, inewtonur, dxmax, locmax)
under-relaxation
Definition: swf.f90:598
subroutine, public swf_cr(filename, id, modelname)
Create a new stream network flow model object.
Definition: swf.f90:145
subroutine swf_cq(this, icnvg, isuppress_output)
Calculate flow.
Definition: swf.f90:643
subroutine swf_da(this)
Deallocate.
Definition: swf.f90:899
subroutine swf_ot_flow(this, icbcfl, ibudfl, icbcun)
Definition: swf.f90:796
subroutine swf_ot(this)
Stream Network Flow Model Output.
Definition: swf.f90:721
subroutine swf_bd(this, icnvg, isuppress_output)
Model Budget.
Definition: swf.f90:680
integer(i4b), parameter, public swf_nmultipkg
SWF multi package array descriptors.
Definition: swf.f90:128
subroutine swf_fc(this, kiter, matrix_sln, inwtflag)
Fill coefficients.
Definition: swf.f90:526
subroutine allocate_arrays(this)
Allocate memory for scalar members.
Definition: swf.f90:255
subroutine swf_rp(this)
Stream Network Flow Model Read and Prepare.
Definition: swf.f90:424
subroutine ftype_check(this, indis)
Check to make sure required input files have been specified.
Definition: swf.f90:1045
subroutine, public swf_obs_cr(obs, inobs)
Create a new obs object.
Definition: swf-obs.f90:39
subroutine, public oc_cr(ocobj, name_model, inunit, iout)
@ brief Create SwfOcType
Definition: swf-oc.f90:31
This module contains the storage package methods.
Definition: swf-sto.f90:7
subroutine, public sto_cr(stoobj, name_model, inunit, iout, cxs)
@ brief Create a new package object
Definition: swf-sto.f90:70
This module contains the ZDG package methods.
Definition: swf-zdg.f90:7
subroutine, public zdg_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath, dis, cxs, unitconv)
@ brief Create a new package object
Definition: swf-zdg.f90:79
logical(lgp), pointer, public endofperiod
flag indicating end of stress period
Definition: tdis.f90:27
subroutine, public tdis_ot(iout)
Print simulation time.
Definition: tdis.f90:349
real(dp), pointer, public totim
time relative to start of simulation
Definition: tdis.f90:32
logical(lgp), pointer, public readnewdata
flag indicating time to read new data
Definition: tdis.f90:26
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
real(dp), pointer, public delt
length of the current time step
Definition: tdis.f90:29
Highest level model type. All models extend this parent type.
Definition: BaseModel.f90:13
@ brief BndType
Derived type for the Budget object.
Definition: Budget.f90:39
This class is used to store a single deferred-length character string. It was designed to work in an ...
Definition: CharString.f90:23
@ brief Output control
Definition: swf-oc.f90:17