MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
simulationcreatemodule Module Reference

Functions/Subroutines

subroutine, public simulation_cr ()
 Read the simulation name file and initialize the models, exchanges. More...
 
subroutine, public simulation_da ()
 Deallocate simulation variables. More...
 
subroutine source_simulation_nam ()
 Source the simulation name file. More...
 
subroutine options_create ()
 Set the simulation options. More...
 
subroutine timing_create ()
 Set the timing module to be used for the simulation. More...
 
subroutine models_create ()
 Set the models to be used for the simulation. More...
 
subroutine exchanges_create ()
 Set the exchanges to be used for the simulation. More...
 
subroutine solution_group_check (sgp, sgid, isgpsoln)
 Check a solution_group to be used for the simulation. More...
 
subroutine solution_groups_create ()
 Set the solution_groups to be used for the simulation. More...
 
subroutine check_model_assignment ()
 Check for dangling models, and break with error when found. More...
 
subroutine assign_exchanges ()
 Assign exchanges to solutions. More...
 
subroutine check_model_name (mtype, mname)
 Check that the model name is valid. More...
 
subroutine, public create_load_mask (mask_array)
 Create a load mask to determine which models should be loaded by idm on this process. This is in sync with models create. The mask array should be pre-allocated with size equal to the global number of models. It is returned as (1, 1, 0, 0, ... 0) with each entry being a load mask for the model at the corresponding location in the 'MNAME' array. More...
 
subroutine create_load_balance (mranks)
 Distribute the models over the available processes in a parallel run. Expects an array sized. More...
 

Function/Subroutine Documentation

◆ assign_exchanges()

subroutine simulationcreatemodule::assign_exchanges
private

This assigns NumericalExchanges to NumericalSolutions, based on the link between the models in the solution and those exchanges. The BaseExchangeconnects_model() function should be overridden to indicate if such a link exists.

Definition at line 764 of file SimulationCreate.f90.

765  ! -- local
766  class(BaseSolutionType), pointer :: sp
767  class(BaseExchangeType), pointer :: ep
768  class(BaseModelType), pointer :: mp
769  type(ListType), pointer :: models_in_solution
770  integer(I4B) :: is, ie, im
771 
772  do is = 1, basesolutionlist%Count()
773  sp => getbasesolutionfromlist(basesolutionlist, is)
774  !
775  ! -- now loop over exchanges
776  do ie = 1, baseexchangelist%Count()
777  ep => getbaseexchangefromlist(baseexchangelist, ie)
778  !
779  ! -- and add when it affects (any model in) the solution matrix
780  models_in_solution => sp%get_models()
781  do im = 1, models_in_solution%Count()
782  mp => getbasemodelfromlist(models_in_solution, im)
783  if (ep%connects_model(mp)) then
784  !
785  ! -- add to solution (and only once)
786  call sp%add_exchange(ep)
787  exit
788  end if
789  end do
790  end do
791  end do
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_model_assignment()

subroutine simulationcreatemodule::check_model_assignment

Definition at line 738 of file SimulationCreate.f90.

739  character(len=LINELENGTH) :: errmsg
740  class(BaseModelType), pointer :: mp
741  integer(I4B) :: im
742 
743  do im = 1, basemodellist%Count()
744  mp => getbasemodelfromlist(basemodellist, im)
745  if (mp%idsoln == 0) then
746  write (errmsg, '(a,a)') &
747  'Model was not assigned to a solution: ', mp%name
748  call store_error(errmsg)
749  end if
750  end do
751  if (count_errors() > 0) then
752  call store_error_filename('mfsim.nam')
753  end if
754 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_model_name()

subroutine simulationcreatemodule::check_model_name ( character(len=*), intent(in)  mtype,
character(len=*), intent(inout)  mname 
)
private

Definition at line 796 of file SimulationCreate.f90.

797  ! -- dummy
798  character(len=*), intent(in) :: mtype
799  character(len=*), intent(inout) :: mname
800  ! -- local
801  integer :: ilen
802  integer :: i
803  character(len=LINELENGTH) :: errmsg
804  logical :: terminate = .true.
805  ! ------------------------------------------------------------------------------
806  ilen = len_trim(mname)
807  if (ilen > lenmodelname) then
808  write (errmsg, '(a,a)') 'Invalid model name: ', trim(mname)
809  call store_error(errmsg)
810  write (errmsg, '(a,i0,a,i0)') &
811  'Name length of ', ilen, ' exceeds maximum length of ', &
812  lenmodelname
813  call store_error(errmsg, terminate)
814  end if
815  do i = 1, ilen
816  if (mname(i:i) == ' ') then
817  write (errmsg, '(a,a)') 'Invalid model name: ', trim(mname)
818  call store_error(errmsg)
819  write (errmsg, '(a)') &
820  'Model name cannot have spaces within it.'
821  call store_error(errmsg, terminate)
822  end if
823  end do
824  !
825  ! -- return
826  return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_load_balance()

subroutine simulationcreatemodule::create_load_balance ( integer(i4b), dimension(:)  mranks)

Definition at line 857 of file SimulationCreate.f90.

861  integer(I4B), dimension(:) :: mranks
862  ! local
863  integer(I4B) :: im, imm, ie, ip, cnt
864  integer(I4B) :: nr_models, nr_gwf_models
865  integer(I4B) :: nr_exchanges
866  integer(I4B) :: min_per_proc, nr_left
867  integer(I4B) :: rank
868  integer(I4B), dimension(:), allocatable :: nr_models_proc
869  character(len=LENPACKAGETYPE) :: model_type_str
870  character(len=LINELENGTH) :: errmsg
871  character(len=LENMEMPATH) :: input_mempath
872  type(CharacterStringType), dimension(:), contiguous, &
873  pointer :: mtypes !< model types
874  type(CharacterStringType), dimension(:), contiguous, &
875  pointer :: mnames !< model names
876  type(CharacterStringType), dimension(:), contiguous, &
877  pointer :: etypes !< exg types
878  type(CharacterStringType), dimension(:), contiguous, &
879  pointer :: emnames_a !< model a names
880  type(CharacterStringType), dimension(:), contiguous, &
881  pointer :: emnames_b !< model b names
882 
883  mranks = 0
884  if (simulation_mode /= 'PARALLEL') return
885 
886  ! load IDM data
887  input_mempath = create_mem_path('SIM', 'NAM', idm_context)
888  call mem_setptr(mtypes, 'MTYPE', input_mempath)
889  call mem_setptr(mnames, 'MNAME', input_mempath)
890  call mem_setptr(etypes, 'EXGTYPE', input_mempath)
891  call mem_setptr(emnames_a, 'EXGMNAMEA', input_mempath)
892  call mem_setptr(emnames_b, 'EXGMNAMEB', input_mempath)
893 
894  ! count flow models
895  nr_models = size(mnames)
896  nr_gwf_models = 0
897  do im = 1, nr_models
898  if (mtypes(im) == 'GWF6') then
899  nr_gwf_models = nr_gwf_models + 1
900  end if
901 
902  if (mtypes(im) == 'GWF6' .or. &
903  mtypes(im) == 'GWT6' .or. &
904  mtypes(im) == 'GWE6') then
905  cycle
906  end if
907 
908  model_type_str = mtypes(im)
909  write (errmsg, *) 'Model type ', model_type_str, &
910  ' not supported in parallel mode.'
911  call store_error(errmsg, terminate=.true.)
912  end do
913 
914  ! calculate nr of flow models for each rank
915  allocate (nr_models_proc(nr_procs))
916  min_per_proc = nr_gwf_models / nr_procs
917  nr_left = nr_gwf_models - nr_procs * min_per_proc
918  cnt = 1
919  do ip = 1, nr_procs
920  rank = ip - 1
921  nr_models_proc(ip) = min_per_proc
922  if (rank < nr_left) then
923  nr_models_proc(ip) = nr_models_proc(ip) + 1
924  end if
925  end do
926 
927  ! assign ranks for flow models
928  rank = 0
929  do im = 1, nr_models
930  if (mtypes(im) == 'GWF6') then
931  if (nr_models_proc(rank + 1) == 0) then
932  rank = rank + 1
933  end if
934  mranks(im) = rank
935  nr_models_proc(rank + 1) = nr_models_proc(rank + 1) - 1
936  end if
937  end do
938 
939  ! match other models to flow
940  nr_exchanges = size(etypes)
941  do im = 1, nr_models
942  if (mtypes(im) == 'GWT6') then
943 
944  ! find match
945  do ie = 1, nr_exchanges
946  if (etypes(ie) == 'GWF6-GWT6' .and. mnames(im) == emnames_b(ie)) then
947  rank = 0
948  do imm = 1, nr_models
949  if (mnames(imm) == emnames_a(ie)) then
950  rank = mranks(imm)
951  exit
952  end if
953  end do
954  mranks(im) = rank
955  exit
956  end if
957  end do
958 
959  else if (mtypes(im) == 'GWE6') then
960  do ie = 1, nr_exchanges
961  if (etypes(ie) == 'GWF6-GWE6' .and. mnames(im) == emnames_b(ie)) then
962  rank = 0
963  do imm = 1, nr_models
964  if (mnames(imm) == emnames_a(ie)) then
965  rank = mranks(imm)
966  exit
967  end if
968  end do
969  mranks(im) = rank
970  exit
971  end if
972  end do
973 
974  else
975  cycle ! e.g., for a flow model
976  end if
977  end do
978 
979  ! cleanup
980  deallocate (nr_models_proc)
981 
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=linelength) idm_context
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_load_mask()

subroutine, public simulationcreatemodule::create_load_mask ( integer(i4b), dimension(:)  mask_array)

Definition at line 837 of file SimulationCreate.f90.

838  use simvariablesmodule, only: proc_id
839  integer(I4B), dimension(:) :: mask_array
840  ! local
841  integer(I4B) :: i
842 
843  call create_load_balance(mask_array)
844  do i = 1, size(mask_array)
845  if (mask_array(i) == proc_id) then
846  mask_array(i) = 1
847  else
848  mask_array(i) = 0
849  end if
850  end do
851 
integer(i4b) proc_id
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exchanges_create()

subroutine simulationcreatemodule::exchanges_create

Definition at line 353 of file SimulationCreate.f90.

354  ! -- modules
368  ! use VirtualPrtExchangeModule, only: add_virtual_prt_exchange
369  ! -- dummy
370  ! -- locals
371  character(len=LENMEMPATH) :: input_mempath
372  type(CharacterStringType), dimension(:), contiguous, &
373  pointer :: etypes !< exg types
374  type(CharacterStringType), dimension(:), contiguous, &
375  pointer :: efiles !< exg file names
376  type(CharacterStringType), dimension(:), contiguous, &
377  pointer :: emnames_a !< model a names
378  type(CharacterStringType), dimension(:), contiguous, &
379  pointer :: emnames_b !< model b names
380  type(CharacterStringType), dimension(:), contiguous, &
381  pointer :: emempaths
382  character(len=LINELENGTH) :: exgtype
383  integer(I4B) :: exg_id
384  integer(I4B) :: m1_id, m2_id
385  character(len=LINELENGTH) :: fname, name1, name2
386  character(len=LENEXCHANGENAME) :: exg_name
387  character(len=LENMEMPATH) :: exg_mempath
388  integer(I4B) :: n
389  character(len=LINELENGTH) :: errmsg
390  logical(LGP) :: terminate = .true.
391  logical(LGP) :: both_remote, both_local
392  ! -- formats
393  character(len=*), parameter :: fmtmerr = "('Error in simulation control ', &
394  &'file. Could not find model: ', a)"
395  !
396  ! -- set input memory path
397  input_mempath = create_mem_path('SIM', 'NAM', idm_context)
398  !
399  ! -- set pointers to input context exchange attribute arrays
400  call mem_setptr(etypes, 'EXGTYPE', input_mempath)
401  call mem_setptr(efiles, 'EXGFILE', input_mempath)
402  call mem_setptr(emnames_a, 'EXGMNAMEA', input_mempath)
403  call mem_setptr(emnames_b, 'EXGMNAMEB', input_mempath)
404  call mem_setptr(emempaths, 'EXGMEMPATHS', input_mempath)
405  !
406  ! -- open exchange logging block
407  write (iout, '(/1x,a)') 'READING SIMULATION EXCHANGES'
408  !
409  ! -- initialize
410  exg_id = 0
411  !
412  ! -- create exchanges
413  do n = 1, size(etypes)
414  !
415  ! -- attributes for this exchange
416  exgtype = etypes(n)
417  fname = efiles(n)
418  name1 = emnames_a(n)
419  name2 = emnames_b(n)
420  exg_mempath = emempaths(n)
421 
422  exg_id = exg_id + 1
423 
424  ! find model index in list
425  m1_id = ifind(model_names, name1)
426  if (m1_id < 0) then
427  write (errmsg, fmtmerr) trim(name1)
428  call store_error(errmsg, terminate)
429  end if
430  m2_id = ifind(model_names, name2)
431  if (m2_id < 0) then
432  write (errmsg, fmtmerr) trim(name2)
433  call store_error(errmsg, terminate)
434  end if
435 
436  ! both models on other process? then don't create it here...
437  both_remote = (model_loc_idx(m1_id) == -1 .and. &
438  model_loc_idx(m2_id) == -1)
439  both_local = (model_loc_idx(m1_id) > 0 .and. &
440  model_loc_idx(m2_id) > 0)
441  if (.not. both_remote) then
442  write (iout, '(4x,a,a,i0,a,i0,a,i0)') trim(exgtype), ' exchange ', &
443  exg_id, ' will be created to connect model ', m1_id, &
444  ' with model ', m2_id
445  end if
446 
447  select case (exgtype)
448  case ('GWF6-GWF6')
449  write (exg_name, '(a,i0)') 'GWF-GWF_', exg_id
450  if (.not. both_remote) then
451  call gwfexchange_create(fname, exg_name, exg_id, m1_id, m2_id, &
452  exg_mempath)
453  end if
454  call add_virtual_gwf_exchange(exg_name, exg_id, m1_id, m2_id)
455  case ('GWF6-GWT6')
456  if (both_local) then
457  call gwfgwt_cr(fname, exg_id, m1_id, m2_id)
458  end if
459  case ('GWF6-GWE6')
460  if (both_local) then
461  call gwfgwe_cr(fname, exg_id, m1_id, m2_id)
462  end if
463  case ('GWF6-PRT6')
464  call gwfprt_cr(fname, exg_id, m1_id, m2_id)
465  case ('GWT6-GWT6')
466  write (exg_name, '(a,i0)') 'GWT-GWT_', exg_id
467  if (.not. both_remote) then
468  call gwtexchange_create(fname, exg_name, exg_id, m1_id, m2_id, &
469  exg_mempath)
470  end if
471  call add_virtual_gwt_exchange(exg_name, exg_id, m1_id, m2_id)
472  case ('GWE6-GWE6')
473  write (exg_name, '(a,i0)') 'GWE-GWE_', exg_id
474  if (.not. both_remote) then
475  call gweexchange_create(fname, exg_name, exg_id, m1_id, m2_id, &
476  exg_mempath)
477  end if
478  call add_virtual_gwe_exchange(exg_name, exg_id, m1_id, m2_id)
479  case ('SWF6-GWF6')
480  write (exg_name, '(a,i0)') 'SWF-GWF_', exg_id
481  if (both_local) then
482  call swfgwf_cr(fname, exg_name, exg_id, m1_id, m2_id, exg_mempath)
483  end if
484  case default
485  write (errmsg, '(a,a)') &
486  'Unknown simulation exchange type: ', trim(exgtype)
487  call store_error(errmsg, terminate)
488  end select
489  end do
490  !
491  ! -- close exchange logging block
492  write (iout, '(1x,a)') 'END OF SIMULATION EXCHANGES'
493  !
494  ! -- return
495  return
This module contains the GweGweExchangeModule Module.
Definition: exg-gwegwe.f90:10
subroutine, public gweexchange_create(filename, name, id, m1_id, m2_id, input_mempath)
@ brief Create GWT GWT exchange
Definition: exg-gwegwe.f90:111
subroutine, public gwfgwe_cr(filename, id, m1_id, m2_id)
Create a new GWF to GWE exchange object.
Definition: exg-gwfgwe.f90:47
This module contains the GwfGwfExchangeModule Module.
Definition: exg-gwfgwf.f90:10
subroutine, public gwfexchange_create(filename, name, id, m1_id, m2_id, input_mempath)
@ brief Create GWF GWF exchange
Definition: exg-gwfgwf.f90:122
subroutine, public gwfgwt_cr(filename, id, m1_id, m2_id)
Create a new GWF to GWT exchange object.
Definition: exg-gwfgwt.f90:47
subroutine, public gwfprt_cr(filename, id, m1id, m2id)
Create a new GWF to PRT exchange object.
Definition: exg-gwfprt.f90:40
This module contains the GwtGwtExchangeModule Module.
Definition: exg-gwtgwt.f90:10
subroutine, public gwtexchange_create(filename, name, id, m1_id, m2_id, input_mempath)
@ brief Create GWT GWT exchange
Definition: exg-gwtgwt.f90:110
This module contains the SwfGwfExchangeModule Module.
Definition: exg-swfgwf.f90:7
subroutine, public swfgwf_cr(filename, name, id, m1_id, m2_id, input_mempath)
@ brief Create SWF GWF exchange
Definition: exg-swfgwf.f90:97
subroutine, public add_virtual_gwe_exchange(name, exchange_id, model1_id, model2_id)
Add a virtual GWE-GWE exchange to the simulation.
subroutine, public add_virtual_gwf_exchange(name, exchange_id, model1_id, model2_id)
Add a virtual GWF-GWF exchange to the simulation.
subroutine, public add_virtual_gwt_exchange(name, exchange_id, model1_id, model2_id)
Add a virtual GWT-GWT exchange to the simulation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ models_create()

subroutine simulationcreatemodule::models_create

Definition at line 209 of file SimulationCreate.f90.

210  ! -- modules
214  use gwfmodule, only: gwf_cr
215  use gwtmodule, only: gwt_cr
216  use gwemodule, only: gwe_cr
217  use swfmodule, only: swf_cr
218  use prtmodule, only: prt_cr
223  ! use VirtualPrtModelModule, only: add_virtual_prt_model
224  use constantsmodule, only: lenmodelname
225  ! -- dummy
226  ! -- locals
227  character(len=LENMEMPATH) :: input_mempath
228  type(CharacterStringType), dimension(:), contiguous, &
229  pointer :: mtypes !< model types
230  type(CharacterStringType), dimension(:), contiguous, &
231  pointer :: mfnames !< model file names
232  type(CharacterStringType), dimension(:), contiguous, &
233  pointer :: mnames !< model names
234  integer(I4B) :: im
235  class(NumericalModelType), pointer :: num_model
236  character(len=LINELENGTH) :: model_type
237  character(len=LINELENGTH) :: fname, model_name
238  character(len=LINELENGTH) :: errmsg
239  integer(I4B) :: n, nr_models_glob
240  logical :: terminate = .true.
241  !
242  ! -- set input memory path
243  input_mempath = create_mem_path('SIM', 'NAM', idm_context)
244  !
245  ! -- set pointers to input context model attribute arrays
246  call mem_setptr(mtypes, 'MTYPE', input_mempath)
247  call mem_setptr(mfnames, 'MFNAME', input_mempath)
248  call mem_setptr(mnames, 'MNAME', input_mempath)
249  !
250  ! -- allocate global arrays
251  nr_models_glob = size(mnames)
252  call mem_allocate(model_ranks, nr_models_glob, 'MRANKS', input_mempath)
253  allocate (model_names(nr_models_glob))
254  allocate (model_loc_idx(nr_models_glob))
255  !
256  ! -- assign models to cpu cores (in serial all to rank 0)
257  call create_load_balance(model_ranks)
258  !
259  ! -- open model logging block
260  write (iout, '(/1x,a)') 'READING SIMULATION MODELS'
261  !
262  ! -- create models
263  im = 0
264  do n = 1, size(mtypes)
265  !
266  ! -- attributes for this model
267  model_type = mtypes(n)
268  fname = mfnames(n)
269  model_name = mnames(n)
270  !
271  call check_model_name(model_type, model_name)
272  !
273  ! increment global model id
274  model_names(n) = model_name(1:lenmodelname)
275  model_loc_idx(n) = -1
276  num_model => null()
277  !
278  ! -- add a new (local or global) model
279  select case (model_type)
280  case ('GWF6')
281  if (model_ranks(n) == proc_id) then
282  im = im + 1
283  write (iout, '(4x,2a,i0,a)') trim(model_type), ' model ', &
284  n, ' will be created'
285  call gwf_cr(fname, n, model_names(n))
286  num_model => getnumericalmodelfromlist(basemodellist, im)
287  model_loc_idx(n) = im
288  end if
289  call add_virtual_gwf_model(n, model_names(n), num_model)
290  case ('GWT6')
291  if (model_ranks(n) == proc_id) then
292  im = im + 1
293  write (iout, '(4x,2a,i0,a)') trim(model_type), ' model ', &
294  n, ' will be created'
295  call gwt_cr(fname, n, model_names(n))
296  num_model => getnumericalmodelfromlist(basemodellist, im)
297  model_loc_idx(n) = im
298  end if
299  call add_virtual_gwt_model(n, model_names(n), num_model)
300  case ('GWE6')
301  if (model_ranks(n) == proc_id) then
302  im = im + 1
303  write (iout, '(4x,2a,i0,a)') trim(model_type), ' model ', &
304  n, ' will be created'
305  call gwe_cr(fname, n, model_names(n))
306  num_model => getnumericalmodelfromlist(basemodellist, im)
307  model_loc_idx(n) = im
308  end if
309  call add_virtual_gwe_model(n, model_names(n), num_model)
310  case ('SWF6')
311  if (model_ranks(n) == proc_id) then
312  im = im + 1
313  write (iout, '(4x,2a,i0,a)') trim(model_type), " model ", &
314  n, " will be created"
315  call swf_cr(fname, n, model_names(n))
316  call dev_feature('SWF is still under development, install the &
317  &nightly build or compile from source with IDEVELOPMODE = 1.')
318  num_model => getnumericalmodelfromlist(basemodellist, im)
319  model_loc_idx(n) = im
320  end if
321  case ('PRT6')
322  im = im + 1
323  write (iout, '(4x,2a,i0,a)') trim(model_type), ' model ', &
324  n, ' will be created'
325  call prt_cr(fname, n, model_names(n))
326  call dev_feature('PRT is still under development, install the &
327  &nightly build or compile from source with IDEVELOPMODE = 1.')
328  num_model => getnumericalmodelfromlist(basemodellist, im)
329  model_loc_idx(n) = im
330  case default
331  write (errmsg, '(a,a)') &
332  'Unknown simulation model type: ', trim(model_type)
333  call store_error(errmsg, terminate)
334  end select
335  end do
336  !
337  ! -- close model logging block
338  write (iout, '(1x,a)') 'END OF SIMULATION MODELS'
339  !
340  ! -- sanity check
341  if (simulation_mode == 'PARALLEL' .and. im == 0) then
342  write (errmsg, '(a, i0)') &
343  'No MODELS assigned to process ', proc_id
344  call store_error(errmsg, terminate)
345  end if
346  !
347  ! -- return
348  return
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lenmodelname
maximum length of the model name
Definition: Constants.f90:21
Definition: gwe.f90:3
subroutine, public gwe_cr(filename, id, modelname)
Create a new groundwater energy transport model object.
Definition: gwe.f90:96
Definition: gwf.f90:1
subroutine, public gwf_cr(filename, id, modelname)
Create a new groundwater flow model object.
Definition: gwf.f90:138
Definition: gwt.f90:8
subroutine, public gwt_cr(filename, id, modelname)
Create a new groundwater transport model object.
Definition: gwt.f90:98
class(numericalmodeltype) function, pointer, public getnumericalmodelfromlist(list, idx)
Definition: prt.f90:1
subroutine, public prt_cr(filename, id, modelname)
Create a new particle tracking model object.
Definition: prt.f90:123
Stream Network Flow (SWF) Module.
Definition: swf.f90:38
subroutine, public swf_cr(filename, id, modelname)
Create a new stream network flow model object.
Definition: swf.f90:145
subroutine, public add_virtual_gwe_model(model_id, model_name, model)
subroutine, public add_virtual_gwf_model(model_id, model_name, model)
Add virtual GWF model.
subroutine, public add_virtual_gwt_model(model_id, model_name, model)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ options_create()

subroutine simulationcreatemodule::options_create
private

Definition at line 104 of file SimulationCreate.f90.

105  ! -- modules
111  ! -- dummy
112  ! -- locals
113  character(len=LENMEMPATH) :: input_mempath
114  integer(I4B), pointer :: simcontinue, nocheck, maxerror
115  character(len=:), pointer :: prmem
116  character(len=LINELENGTH) :: errmsg
117  !
118  ! -- set input memory path
119  input_mempath = create_mem_path('SIM', 'NAM', idm_context)
120  !
121  ! -- set pointers to input context option params
122  call mem_setptr(simcontinue, 'CONTINUE', input_mempath)
123  call mem_setptr(nocheck, 'NOCHECK', input_mempath)
124  call mem_setptr(prmem, 'PRMEM', input_mempath)
125  call mem_setptr(maxerror, 'MAXERRORS', input_mempath)
126  !
127  ! -- update sim options
128  isimcontinue = simcontinue
129  isimcheck = nocheck
130  call maxerrors(maxerror)
131  !
132  if (prmem /= '') then
133  errmsg = ''
134  call mem_set_print_option(iout, prmem, errmsg)
135  if (errmsg /= '') then
136  call store_error(errmsg, .true.)
137  end if
138  end if
139  !
140  ! -- log values to list file
141  if (iout > 0) then
142  write (iout, '(/1x,a)') 'READING SIMULATION OPTIONS'
143  !
144  if (isimcontinue == 1) then
145  write (iout, '(4x, a)') &
146  'SIMULATION WILL CONTINUE EVEN IF THERE IS NONCONVERGENCE.'
147  end if
148  !
149  if (isimcheck == 0) then
150  write (iout, '(4x, a)') &
151  'MODEL DATA WILL NOT BE CHECKED FOR ERRORS.'
152  end if
153  !
154  write (iout, '(4x, a, i0)') &
155  'MAXIMUM NUMBER OF ERRORS THAT WILL BE STORED IS ', maxerror
156  !
157  if (prmem /= '') then
158  write (iout, '(4x, a, a, a)') &
159  'MEMORY_PRINT_OPTION SET TO "', trim(prmem), '".'
160  end if
161  !
162  write (iout, '(1x,a)') 'END OF SIMULATION OPTIONS'
163  end if
164  !
165  ! -- return
166  return
subroutine, public mem_set_print_option(iout, keyword, error_msg)
Set the memory print option.
integer(i4b) isimcheck
simulation input check flag (1) to check input, (0) to ignore checks
integer(i4b) isimcontinue
simulation continue flag (1) to continue if isimcnvg = 0, (0) to terminate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ simulation_cr()

subroutine, public simulationcreatemodule::simulation_cr

Definition at line 36 of file SimulationCreate.f90.

37  ! -- modules
38  ! -- local
39 ! ------------------------------------------------------------------------------
40  !
41  ! -- Source simulation nam input context and create objects
42  call source_simulation_nam()
43  !
44  ! -- Return
45  return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ simulation_da()

subroutine, public simulationcreatemodule::simulation_da

Definition at line 50 of file SimulationCreate.f90.

51  ! -- modules
53  ! -- local
54 ! ------------------------------------------------------------------------------
55  !
56  ! -- variables
57  deallocate (model_names)
58  deallocate (model_loc_idx)
59  !
60  ! -- Return
61  return
Here is the caller graph for this function:

◆ solution_group_check()

subroutine simulationcreatemodule::solution_group_check ( type(solutiongrouptype), intent(inout), pointer  sgp,
integer(i4b), intent(in)  sgid,
integer(i4b), intent(in)  isgpsoln 
)

Definition at line 500 of file SimulationCreate.f90.

501  ! -- modules
502  ! -- dummy
503  type(SolutionGroupType), pointer, intent(inout) :: sgp
504  integer(I4B), intent(in) :: sgid
505  integer(I4B), intent(in) :: isgpsoln
506  ! -- local
507  character(len=LINELENGTH) :: errmsg
508  logical :: terminate = .true.
509  ! -- formats
510  character(len=*), parameter :: fmterrmxiter = &
511  "('MXITER is set to ', i0, ' but there is only one solution', &
512  &' in SOLUTION GROUP ', i0, '. Set MXITER to 1 in simulation control', &
513  &' file.')"
514  !
515  ! -- error check completed group
516  if (sgid > 0) then
517  !
518  ! -- Make sure there is a solution in this solution group
519  if (isgpsoln == 0) then
520  write (errmsg, '(a,i0)') &
521  'There are no solutions for solution group ', sgid
522  call store_error(errmsg, terminate)
523  end if
524  !
525  ! -- If there is only one solution then mxiter should be 1.
526  if (isgpsoln == 1 .and. sgp%mxiter > 1) then
527  write (errmsg, fmterrmxiter) sgp%mxiter, isgpsoln
528  call store_error(errmsg, terminate)
529  end if
530  end if
531  !
532  ! -- return
533  return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solution_groups_create()

subroutine simulationcreatemodule::solution_groups_create
private

Definition at line 538 of file SimulationCreate.f90.

539  ! -- modules
547  use basemodelmodule, only: basemodeltype
550  ! -- dummy
551  ! -- local
552  character(len=LENMEMPATH) :: input_mempath
553  type(CharacterStringType), dimension(:), contiguous, &
554  pointer :: slntype
555  type(CharacterStringType), dimension(:), contiguous, &
556  pointer :: slnfname
557  type(CharacterStringType), dimension(:), contiguous, &
558  pointer :: slnmnames
559  integer(I4B), dimension(:), contiguous, pointer :: blocknum
560  character(len=LINELENGTH) :: stype, fname
561  character(len=:), allocatable :: mnames
562  type(SolutionGroupType), pointer :: sgp
563  class(BaseSolutionType), pointer :: sp
564  class(BaseModelType), pointer :: mp
565  integer(I4B) :: isoln
566  integer(I4B) :: isgpsoln
567  integer(I4B) :: sgid
568  integer(I4B) :: glo_mid
569  integer(I4B) :: loc_idx
570  integer(I4B) :: i, j, istat, mxiter
571  integer(I4B) :: nwords
572  character(len=LENMODELNAME), dimension(:), allocatable :: words
573  character(len=:), allocatable :: parse_str
574  character(len=LINELENGTH) :: errmsg
575  logical :: terminate = .true.
576 ! ------------------------------------------------------------------------------
577  !
578  ! -- set memory path
579  input_mempath = create_mem_path('SIM', 'NAM', idm_context)
580  !
581  ! -- set pointers to input context solution attribute arrays
582  call mem_setptr(slntype, 'SLNTYPE', input_mempath)
583  call mem_setptr(slnfname, 'SLNFNAME', input_mempath)
584  call mem_setptr(slnmnames, 'SLNMNAMES', input_mempath)
585  call mem_setptr(blocknum, 'SOLUTIONGROUPNUM', input_mempath)
586  !
587  ! -- open solution group logging block
588  write (iout, '(/1x,a)') 'READING SOLUTIONGROUP'
589  !
590  ! -- initialize
591  sgid = 0 ! integer id of soln group, tracks with blocknum
592  isoln = 0 ! cumulative solution number
593  !
594  ! -- create solution groups
595  do i = 1, size(blocknum)
596  !
597  ! -- allocate slnmnames string
598  allocate (character(slnmnames(i)%strlen()) :: mnames)
599  !
600  ! -- attributes for this solution
601  stype = slntype(i)
602  fname = slnfname(i)
603  mnames = slnmnames(i)
604 
605  if (blocknum(i) /= sgid) then
606  !
607  ! -- check for new soln group
608  if (blocknum(i) == sgid + 1) then
609  !
610  ! -- error check completed group
611  call solution_group_check(sgp, sgid, isgpsoln)
612  !
613  ! -- reinitialize
614  nullify (sgp)
615  isgpsoln = 0 ! solution counter for this solution group
616  !
617  ! -- set sgid
618  sgid = blocknum(i)
619  !
620  ! -- create new soln group and add to global list
621  call solutiongroup_create(sgp, sgid)
622  call addsolutiongrouptolist(solutiongrouplist, sgp)
623  else
624  write (errmsg, '(a,i0,a,i0,a)') &
625  'Solution group blocks are not listed consecutively. Found ', &
626  blocknum(i), ' when looking for ', sgid + 1, '.'
627  call store_error(errmsg, terminate)
628  end if
629  end if
630  !
631  ! --
632  select case (stype)
633  !
634  case ('MXITER')
635  read (fname, *, iostat=istat) mxiter
636  if (istat == 0) then
637  sgp%mxiter = mxiter
638  end if
639  case ('IMS6')
640  !
641  ! -- increment solution counters
642  isoln = isoln + 1
643  isgpsoln = isgpsoln + 1
644  !
645  ! -- create soln and add to group
646  sp => create_ims_solution(simulation_mode, fname, isoln)
647  call sgp%add_solution(isoln, sp)
648  !
649  ! -- parse model names
650  parse_str = trim(mnames)//' '
651  call parseline(parse_str, nwords, words)
652  !
653  ! -- Find each model id and get model
654  do j = 1, nwords
655  call upcase(words(j))
656  glo_mid = ifind(model_names, words(j))
657  if (glo_mid == -1) then
658  write (errmsg, '(a,a)') 'Invalid model name: ', trim(words(j))
659  call store_error(errmsg, terminate)
660  end if
661  !
662  loc_idx = model_loc_idx(glo_mid)
663  if (loc_idx == -1) then
664  if (simulation_mode == 'PARALLEL') then
665  ! this is still ok
666  cycle
667  end if
668  end if
669  !
670  mp => getbasemodelfromlist(basemodellist, loc_idx)
671  !
672  ! -- Add the model to the solution
673  call sp%add_model(mp)
674  mp%idsoln = isoln
675  end do
676  case ('EMS6')
677  !
678  ! -- increment solution counters
679  isoln = isoln + 1
680  isgpsoln = isgpsoln + 1
681  !
682  ! -- create soln and add to group
683  sp => create_ems_solution(simulation_mode, fname, isoln)
684  call sgp%add_solution(isoln, sp)
685  !
686  ! -- parse model names
687  parse_str = trim(mnames)//' '
688  call parseline(parse_str, nwords, words)
689  !
690  ! -- Find each model id and get model
691  do j = 1, nwords
692  call upcase(words(j))
693  glo_mid = ifind(model_names, words(j))
694  if (glo_mid == -1) then
695  write (errmsg, '(a,a)') 'Invalid model name: ', trim(words(j))
696  call store_error(errmsg, terminate)
697  end if
698  !
699  loc_idx = model_loc_idx(glo_mid)
700  if (loc_idx == -1) then
701  if (simulation_mode == 'PARALLEL') then
702  ! this is still ok
703  cycle
704  end if
705  end if
706  !
707  mp => getbasemodelfromlist(basemodellist, loc_idx)
708  !
709  ! -- Add the model to the solution
710  call sp%add_model(mp)
711  mp%idsoln = isoln
712  end do
713  case default
714  end select
715  !
716  ! -- clean up
717  deallocate (mnames)
718  end do
719  !
720  ! -- error check final group
721  call solution_group_check(sgp, sgid, isgpsoln)
722  !
723  ! -- close exchange logging block
724  write (iout, '(1x,a)') 'END OF SOLUTIONGROUP'
725  !
726  ! -- Check and make sure at least one solution group was found
727  if (solutiongrouplist%Count() == 0) then
728  call store_error('There are no solution groups.', terminate)
729  end if
730  !
731  ! -- return
732  return
subroutine, public parseline(line, nwords, words, inunit, filename)
Parse a line into words.
subroutine, public upcase(word)
Convert to upper case.
character(len=linelength) simulation_mode
class(basesolutiontype) function, pointer, public create_ims_solution(sim_mode, filename, sol_id)
Create an IMS solution of type NumericalSolution for serial runs or its sub-type ParallelSolution for...
class(basesolutiontype) function, pointer, public create_ems_solution(sim_mode, filename, sol_id)
Create an EMS solution of type ExplicitSolution for serial runs or its sub-type ParallelSolution for.
subroutine, public solutiongroup_create(sgp, id)
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:

◆ source_simulation_nam()

subroutine simulationcreatemodule::source_simulation_nam

Source from the simulation nam input context to initialize the models, exchanges, solutions, solutions groups. Then add the exchanges to the appropriate solutions.

Definition at line 71 of file SimulationCreate.f90.

72  ! -- dummy
73  ! -- local
74 ! ------------------------------------------------------------------------------
75  !
76  ! -- Process OPTIONS block in namfile
77  call options_create()
78  !
79  ! -- Process TIMING block in namfile
80  call timing_create()
81  !
82  ! -- Process MODELS block in namfile
83  call models_create()
84  !
85  ! -- Process EXCHANGES block in namfile
86  call exchanges_create()
87  !
88  ! -- Process SOLUTION_GROUPS blocks in namfile
89  call solution_groups_create()
90  !
91  ! -- Go through each model and make sure that it has been assigned to
92  ! a solution.
93  call check_model_assignment()
94  !
95  ! -- Go through each solution and assign exchanges accordingly
96  call assign_exchanges()
97  !
98  ! -- Return
99  return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timing_create()

subroutine simulationcreatemodule::timing_create

Definition at line 171 of file SimulationCreate.f90.

172  ! -- modules
176  use tdismodule, only: tdis_cr
177  ! -- dummy
178  ! -- locals
179  character(len=LENMEMPATH) :: input_mempath
180  character(len=LENMEMPATH) :: tdis_input_mempath
181  character(len=:), pointer :: tdis6
182  logical :: terminate = .true.
183  !
184  ! -- set input memory path
185  input_mempath = create_mem_path('SIM', 'NAM', idm_context)
186  tdis_input_mempath = create_mem_path('SIM', 'TDIS', idm_context)
187  !
188  write (iout, '(/1x,a)') 'READING SIMULATION TIMING'
189  !
190  ! -- set pointers to input context timing params
191  call mem_setptr(tdis6, 'TDIS6', input_mempath)
192  !
193  ! -- create timing
194  if (tdis6 /= '') then
195  call tdis_cr(tdis6, tdis_input_mempath)
196  else
197  call store_error('TIMING block variable TDIS6 is unset'// &
198  ' in simulation control input.', terminate)
199  end if
200  !
201  write (iout, '(1x,a)') 'END OF SIMULATION TIMING'
202  !
203  ! -- return
204  return
subroutine, public tdis_cr(fname, inmempath)
Create temporal discretization.
Definition: tdis.f90:50
Here is the call graph for this function:
Here is the caller graph for this function: