MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
IdmLoad.f90
Go to the documentation of this file.
1 !> @brief This module contains the IdmLoadModule
2 !!
3 !! This module contains routines for managing static
4 !! and dynamic input loading for supported sources.
5 !!
6 !<
8 
9  use kindmodule, only: dp, i4b, lgp
10  use simvariablesmodule, only: errmsg
14  use listmodule, only: listtype
21 
22  implicit none
23  private
24  public :: simnam_load
25  public :: simtdis_load
26  public :: load_models
27  public :: load_exchanges
28  public :: idm_df
29  public :: idm_rp
30  public :: idm_ad
31  public :: idm_da
32 
33 contains
34 
35  !> @brief advance package dynamic data for period steps
36  !<
37  subroutine idm_df()
39  class(modeldynamicpkgstype), pointer :: model_dynamic_input
40  integer(I4B) :: n
41  !
42  do n = 1, model_dynamic_pkgs%Count()
43  model_dynamic_input => getdynamicmodelfromlist(model_dynamic_pkgs, n)
44  call model_dynamic_input%df()
45  end do
46  !
47  ! -- return
48  return
49  end subroutine idm_df
50 
51  !> @brief load package dynamic data for period
52  !<
53  subroutine idm_rp()
55  class(modeldynamicpkgstype), pointer :: model_dynamic_input
56  integer(I4B) :: n
57  !
58  do n = 1, model_dynamic_pkgs%Count()
59  model_dynamic_input => getdynamicmodelfromlist(model_dynamic_pkgs, n)
60  call model_dynamic_input%rp()
61  end do
62  !
63  ! -- return
64  return
65  end subroutine idm_rp
66 
67  !> @brief advance package dynamic data for period steps
68  !<
69  subroutine idm_ad()
71  class(modeldynamicpkgstype), pointer :: model_dynamic_input
72  integer(I4B) :: n
73  !
74  do n = 1, model_dynamic_pkgs%Count()
75  model_dynamic_input => getdynamicmodelfromlist(model_dynamic_pkgs, n)
76  call model_dynamic_input%ad()
77  end do
78  !
79  ! -- return
80  return
81  end subroutine idm_ad
82 
83  !> @brief idm deallocate routine
84  !<
85  subroutine idm_da(iout)
91  integer(I4B), intent(in) :: iout
92  type(characterstringtype), dimension(:), contiguous, &
93  pointer :: mempaths
94  character(len=LENCOMPONENTNAME) :: exg_comp, exg_subcomp
95  character(len=LENMEMPATH) :: input_mempath, mempath
96  integer(I4B) :: n
97  !
98  ! -- deallocate dynamic loaders
99  call dynamic_da(iout)
100  !
101  ! -- deallocate EXG mempaths
102  input_mempath = create_mem_path('SIM', 'NAM', idm_context)
103  call mem_setptr(mempaths, 'EXGMEMPATHS', input_mempath)
104  do n = 1, size(mempaths)
105  mempath = mempaths(n)
106  if (mempath /= '') then
107  call split_mem_path(mempath, exg_comp, exg_subcomp)
108  call memorystore_remove(exg_comp, exg_subcomp, idm_context)
109  end if
110  end do
111  !
112  ! -- deallocate input context SIM paths
113  call memorystore_remove('UTL', 'HPC', idm_context)
114  call memorystore_remove('SIM', 'TDIS', idm_context)
115  call memorystore_remove('SIM', 'NAM', idm_context)
116  call memorystore_remove(component='SIM', context=idm_context)
117  !
118  ! -- return
119  return
120  end subroutine idm_da
121 
122  !> @brief load an integrated model package from supported source
123  !<
124  recursive subroutine input_load(component_type, subcomponent_type, modelname, &
125  pkgname, pkgtype, filename, modelfname, &
126  nc_vars, iout)
130  character(len=*), intent(in) :: component_type
131  character(len=*), intent(in) :: subcomponent_type
132  character(len=*), intent(in) :: pkgname
133  character(len=*), intent(in) :: pkgtype
134  character(len=*), intent(in) :: filename
135  character(len=*), intent(in) :: modelname
136  character(len=*), intent(in) :: modelfname
137  type(ncfilevarstype), pointer, intent(in) :: nc_vars
138  integer(I4B), intent(in) :: iout
139  class(staticpkgloadbasetype), pointer :: static_loader
140  class(dynamicpkgloadbasetype), pointer :: dynamic_loader
141  class(modeldynamicpkgstype), pointer :: dynamic_pkgs
142  integer(I4B) :: n
143  !
144  ! -- create model package loader
145  static_loader => &
146  create_input_loader(component_type, subcomponent_type, modelname, pkgname, &
147  pkgtype, filename, modelfname, nc_vars)
148  !
149  ! -- load static input and set dynamic loader
150  dynamic_loader => static_loader%load(iout)
151  !
152  if (associated(dynamic_loader)) then
153  !
154  ! -- set pointer to model dynamic packages list
155  dynamic_pkgs => &
156  dynamic_model_pkgs(static_loader%mf6_input%component_type, modelname, &
157  static_loader%component_input_name, nc_vars%nc_fname, &
158  nc_vars%ncid, iout)
159  !
160  ! -- add dynamic pkg loader to list
161  call dynamic_pkgs%add(dynamic_loader)
162  !
163  end if
164  !
165  ! -- create subpackage list
166  call static_loader%create_subpkg_list()
167  !
168  ! -- load idm integrated subpackages
169  do n = 1, static_loader%subpkg_list%pnum
170  !
171  ! -- load subpackage
172  call input_load(static_loader%subpkg_list%component_types(n), &
173  static_loader%subpkg_list%subcomponent_types(n), &
174  static_loader%mf6_input%component_name, &
175  static_loader%subpkg_list%subcomponent_types(n), &
176  static_loader%subpkg_list%pkgtypes(n), &
177  static_loader%subpkg_list%filenames(n), &
178  modelfname, nc_vars, iout)
179  end do
180  !
181  ! -- cleanup
182  call static_loader%destroy()
183  deallocate (static_loader)
184  !
185  ! -- return
186  return
187  end subroutine input_load
188 
189  !> @brief load integrated model package files
190  !<
191  subroutine load_model_pkgs(model_pkg_inputs, iout)
196  type(modelpackageinputstype), intent(inout) :: model_pkg_inputs
197  integer(i4B), intent(in) :: iout
198  type(ncfilevarstype), pointer :: nc_vars
199  integer(I4B) :: itype, ipkg
200  !
201  nc_vars => netcdf_context(model_pkg_inputs%modeltype, &
202  model_pkg_inputs%component_type, &
203  model_pkg_inputs%modelname, &
204  model_pkg_inputs%modelfname, iout)
205  !
206  ! -- load package instances by type
207  do itype = 1, size(model_pkg_inputs%pkglist)
208  !
209  ! -- load package instances
210  do ipkg = 1, model_pkg_inputs%pkglist(itype)%pnum
211 
212  if (idm_integrated(model_pkg_inputs%component_type, &
213  model_pkg_inputs%pkglist(itype)%subcomponent_type)) &
214  then
215  !
216  ! -- only load if model pkg can read from input context
217  call input_load(model_pkg_inputs%component_type, &
218  model_pkg_inputs%pkglist(itype)%subcomponent_type, &
219  model_pkg_inputs%modelname, &
220  model_pkg_inputs%pkglist(itype)%pkgnames(ipkg), &
221  model_pkg_inputs%pkglist(itype)%pkgtype, &
222  model_pkg_inputs%pkglist(itype)%filenames(ipkg), &
223  model_pkg_inputs%modelfname, nc_vars, iout)
224  else
225  !
226  ! -- open input file for package parser
227  model_pkg_inputs%pkglist(itype)%inunits(ipkg) = &
228  open_source_file(model_pkg_inputs%pkglist(itype)%pkgtype, &
229  model_pkg_inputs%pkglist(itype)%filenames(ipkg), &
230  model_pkg_inputs%modelfname, iout)
231  end if
232  end do
233  end do
234  !
235  ! -- cleanup
236  call nc_vars%destroy()
237  deallocate (nc_vars)
238  nullify (nc_vars)
239  !
240  ! -- return
241  return
242  end subroutine load_model_pkgs
243 
244  !> @brief load model namfiles and model package files
245  !<
246  subroutine load_models(iout)
247  ! -- modules
256  ! -- dummy
257  integer(I4B), intent(in) :: iout
258  ! -- local
259  type(distributedsimtype), pointer :: ds
260  integer(I4B), dimension(:), pointer :: model_loadmask
261  character(len=LENMEMPATH) :: input_mempath
262  type(characterstringtype), dimension(:), contiguous, &
263  pointer :: mtypes !< model types
264  type(characterstringtype), dimension(:), contiguous, &
265  pointer :: mfnames !< model file names
266  type(characterstringtype), dimension(:), contiguous, &
267  pointer :: mnames !< model names
268  character(len=LINELENGTH) :: mtype, mfname
269  character(len=LENMODELNAME) :: mname
270  type(modelpackageinputstype), allocatable :: model_pkg_inputs
271  integer(I4B) :: n
272  !
273  ! -- get model mask
274  ds => get_dsim()
275  model_loadmask => ds%get_load_mask()
276  !
277  ! -- set input memory path
278  input_mempath = create_mem_path('SIM', 'NAM', idm_context)
279  !
280  ! -- set pointers to input context model attribute arrays
281  call mem_setptr(mtypes, 'MTYPE', input_mempath)
282  call mem_setptr(mfnames, 'MFNAME', input_mempath)
283  call mem_setptr(mnames, 'MNAME', input_mempath)
284  !
285  do n = 1, size(mtypes)
286  !
287  ! -- attributes for this model
288  mtype = mtypes(n)
289  mfname = mfnames(n)
290  call inlen_check(mnames(n), mname, lenmodelname, 'MODELNAME')
291  !
292  ! -- terminate if errors were detected
293  if (count_errors() > 0) then
295  end if
296  !
297  ! -- load specified model inputs
298  if (model_loadmask(n) > 0) then
299  !
300  ! -- load model nam file
301  call load_modelnam(mtype, mfname, mname, iout)
302  !
303  ! -- create description of model packages
304  allocate (model_pkg_inputs)
305  call model_pkg_inputs%init(mtype, mfname, mname, iout)
306  !
307  ! -- load packages
308  call load_model_pkgs(model_pkg_inputs, iout)
309  !
310  ! -- publish pkg info to input context
311  call model_pkg_inputs%memload()
312  !
313  ! -- cleanup
314  call model_pkg_inputs%destroy()
315  deallocate (model_pkg_inputs)
316  end if
317  end do
318  !
319  ! -- return
320  return
321  end subroutine load_models
322 
323  !> @brief load exchange files
324  !<
325  subroutine load_exchanges(iout)
326  ! -- modules
336  ! -- dummy
337  integer(I4B), intent(in) :: iout
338  ! -- local
339  type(distributedsimtype), pointer :: ds
340  integer(I4B), dimension(:), pointer :: model_loadmask
341  type(characterstringtype), dimension(:), contiguous, &
342  pointer :: etypes !< exg types
343  type(characterstringtype), dimension(:), contiguous, &
344  pointer :: efiles !< exg file names
345  type(characterstringtype), dimension(:), contiguous, &
346  pointer :: emnames_a !< model a names
347  type(characterstringtype), dimension(:), contiguous, &
348  pointer :: emnames_b !< model b names
349  type(characterstringtype), dimension(:), contiguous, &
350  pointer :: emempaths !< exg mempaths
351  type(characterstringtype), dimension(:), contiguous, &
352  pointer :: mtypes !< model types
353  type(characterstringtype), dimension(:), contiguous, &
354  pointer :: mfnames !< model file names
355  type(characterstringtype), dimension(:), contiguous, &
356  pointer :: mnames !< model names
357  character(len=LENMEMPATH) :: input_mempath, mempath
358  integer(I4B), pointer :: exgid, ncelldim
359  character(len=LINELENGTH) :: exgtype, efname, mfname
360  character(len=LENMODELNAME) :: mname1, mname2, mname
361  character(len=LENCOMPONENTNAME) :: sc_type, sc_name, mtype
362  class(staticpkgloadbasetype), pointer :: static_loader
363  class(dynamicpkgloadbasetype), pointer :: dynamic_loader
364  integer(I4B) :: n, m1_idx, m2_idx, irem, isize
365  !
366  ! -- get model mask
367  ds => get_dsim()
368  model_loadmask => ds%get_load_mask()
369  !
370  ! -- set input memory path
371  input_mempath = create_mem_path('SIM', 'NAM', idm_context)
372  !
373  ! -- set pointers to input context exg and model attribute arrays
374  call mem_setptr(etypes, 'EXGTYPE', input_mempath)
375  call mem_setptr(efiles, 'EXGFILE', input_mempath)
376  call mem_setptr(emnames_a, 'EXGMNAMEA', input_mempath)
377  call mem_setptr(emnames_b, 'EXGMNAMEB', input_mempath)
378  call mem_setptr(mtypes, 'MTYPE', input_mempath)
379  call mem_setptr(mfnames, 'MFNAME', input_mempath)
380  call mem_setptr(mnames, 'MNAME', input_mempath)
381  !
382  ! -- allocate mempaths array for exchanges
383  call mem_allocate(emempaths, lenmempath, size(etypes), 'EXGMEMPATHS', &
384  input_mempath)
385  !
386  ! -- load exchanges for local models
387  do n = 1, size(etypes)
388  !
389  ! -- attributes for this exchange
390  exgtype = etypes(n)
391  efname = efiles(n)
392  call inlen_check(emnames_a(n), mname1, lenmodelname, 'MODELNAME')
393  call inlen_check(emnames_b(n), mname2, lenmodelname, 'MODELNAME')
394  !
395  ! initialize mempath as no path
396  emempaths(n) = ''
397  irem = 0
398  !
399  ! -- set indexes for exchange model names
400  m1_idx = ifind_charstr(mnames, mname1)
401  m2_idx = ifind_charstr(mnames, mname2)
402  !
403  if (m1_idx <= 0 .or. m2_idx <= 0) then
404  errmsg = 'Exchange has invalid (unrecognized) model name(s):'
405  if (m1_idx <= 0) errmsg = trim(errmsg)//' '//trim(mname1)
406  if (m2_idx <= 0) errmsg = trim(errmsg)//' '//trim(mname2)
407  call store_error(errmsg)
408  end if
409  !
410  ! -- terminate if errors were detected
411  if (count_errors() > 0) then
413  end if
414  !
415  ! -- load the exchange input if either model local
416  if (model_loadmask(m1_idx) > 0 .or. model_loadmask(m2_idx) > 0) then
417  !
418  ! -- set index if either model is remote
419  if (model_loadmask(m1_idx) == 0) then
420  irem = m1_idx
421  else if (model_loadmask(m2_idx) == 0) then
422  irem = m2_idx
423  end if
424  !
425  ! -- allocate and set remote model NCELLDIM
426  if (irem > 0) then
427  mtype = mtypes(irem)
428  mfname = mfnames(irem)
429  mname = mnames(irem)
430  mempath = create_mem_path(component=mname, context=idm_context)
431  call get_isize('NCELLDIM', mempath, isize)
432  if (isize < 0) then
433  call mem_allocate(ncelldim, 'NCELLDIM', mempath)
434  ncelldim = remote_model_ndim(mtype, mfname)
435  else
436  call mem_setptr(ncelldim, 'NCELLDIM', mempath)
437  end if
438  else
439  nullify (ncelldim)
440  end if
441  !
442  ! -- set subcomponent strings
443  sc_type = trim(idm_subcomponent_type('EXG', exgtype))
444  write (sc_name, '(a,i0)') trim(sc_type)//'_', n
445  !
446  ! -- create and set exchange mempath
447  mempath = create_mem_path('EXG', sc_name, idm_context)
448  emempaths(n) = mempath
449  !
450  ! -- allocate and set exgid
451  call mem_allocate(exgid, 'EXGID', mempath)
452  exgid = n
453  !
454  ! -- create exchange loader
455  static_loader => create_input_loader('EXG', sc_type, 'EXG', sc_name, &
456  exgtype, efname, simfile)
457  ! -- load static input
458  dynamic_loader => static_loader%load(iout)
459  !
460  if (associated(dynamic_loader)) then
461  errmsg = 'IDM unimplemented. Dynamic Exchanges not supported.'
462  call store_error(errmsg)
463  call store_error_filename(efname)
464  else
465  call static_loader%destroy()
466  deallocate (static_loader)
467  end if
468  !
469  end if
470  !
471  end do
472  !
473  ! -- clean up temporary NCELLDIM for remote models
474  do n = 1, size(mnames)
475  if (model_loadmask(n) == 0) then
476  mname = mnames(n)
477  mempath = create_mem_path(component=mname, context=idm_context)
478  call get_isize('NCELLDIM', mempath, isize)
479  if (isize > 0) then
480  call mem_setptr(ncelldim, 'NCELLDIM', mempath)
481  call mem_deallocate(ncelldim)
482  end if
483  end if
484  end do
485  !
486  ! -- return
487  return
488  end subroutine load_exchanges
489 
490  !> @brief MODFLOW 6 mfsim.nam input load routine
491  !<
492  subroutine simnam_load(paramlog)
493  use sourceloadmodule, only: load_simnam
494  integer(I4B), intent(inout) :: paramlog
495  !
496  ! -- load sim nam file
497  call load_simnam()
498  !
499  ! -- allocate any unallocated simnam params
500  call simnam_allocate()
501  !
502  ! -- read and set input parameter logging keyword
503  paramlog = input_param_log()
504  !
505  ! -- memload summary info
506  call simnam_load_dim()
507  !
508  ! --return
509  return
510  end subroutine simnam_load
511 
512  !> @brief MODFLOW 6 tdis input load routine
513  !<
514  subroutine simtdis_load()
515  use sourceloadmodule, only: load_simtdis
516  !
517  ! -- load sim tdis file
518  call load_simtdis()
519  !
520  ! --return
521  return
522  end subroutine simtdis_load
523 
524  !> @brief retrieve list of model dynamic loaders
525  !<
526  function dynamic_model_pkgs(modeltype, modelname, modelfname, nc_fname, &
527  ncid, iout) result(model_dynamic_input)
529  character(len=*), intent(in) :: modeltype
530  character(len=*), intent(in) :: modelname
531  character(len=*), intent(in) :: modelfname
532  character(len=*), intent(in) :: nc_fname
533  integer(I4B), intent(in) :: ncid
534  integer(I4B), intent(in) :: iout
535  class(modeldynamicpkgstype), pointer :: model_dynamic_input
536  class(modeldynamicpkgstype), pointer :: temp
537  integer(I4B) :: id
538  !
539  ! -- initialize
540  nullify (model_dynamic_input)
541  !
542  ! -- assign model loader object if found
543  do id = 1, model_dynamic_pkgs%Count()
544  temp => getdynamicmodelfromlist(model_dynamic_pkgs, id)
545  if (temp%modelname == modelname) then
546  model_dynamic_input => temp
547  exit
548  end if
549  end do
550  !
551  ! -- create if not found
552  if (.not. associated(model_dynamic_input)) then
553  allocate (model_dynamic_input)
554  call model_dynamic_input%init(modeltype, modelname, modelfname, &
555  nc_fname, ncid, iout)
556  call adddynamicmodeltolist(model_dynamic_pkgs, model_dynamic_input)
557  end if
558  !
559  ! -- return
560  return
561  end function dynamic_model_pkgs
562 
563  !> @brief deallocate all model dynamic loader collections
564  !<
565  subroutine dynamic_da(iout)
567  use sourceloadmodule, only: nc_close
568  integer(I4B), intent(in) :: iout
569  class(modeldynamicpkgstype), pointer :: model_dynamic_input
570  integer(I4B) :: n
571  !
572  do n = 1, model_dynamic_pkgs%Count()
573  model_dynamic_input => getdynamicmodelfromlist(model_dynamic_pkgs, n)
574  call nc_close(model_dynamic_input%ncid, model_dynamic_input%nc_fname)
575  call model_dynamic_input%destroy()
576  deallocate (model_dynamic_input)
577  nullify (model_dynamic_input)
578  end do
579  !
580  call model_dynamic_pkgs%Clear()
581  !
582  ! -- return
583  return
584  end subroutine dynamic_da
585 
586  !> @brief return sim input context PRINT_INPUT value
587  !<
588  function input_param_log() result(paramlog)
592  character(len=LENMEMPATH) :: simnam_mempath
593  integer(I4B) :: paramlog
594  integer(I4B), pointer :: p
595  !
596  ! -- read and set input value of PRINT_INPUT
597  simnam_mempath = create_mem_path('SIM', 'NAM', idm_context)
598  call mem_setptr(p, 'PRINT_INPUT', simnam_mempath)
599  paramlog = p
600  !
601  ! -- return
602  return
603  end function input_param_log
604 
605  !> @brief load simulation summary info to input context
606  !<
607  subroutine simnam_load_dim()
612  character(len=LENMEMPATH) :: sim_mempath, simnam_mempath
613  type(characterstringtype), dimension(:), contiguous, &
614  pointer :: mtypes !< model types
615  type(characterstringtype), dimension(:), contiguous, &
616  pointer :: etypes !< model types
617  integer(I4B), pointer :: nummodels
618  integer(I4B), pointer :: numexchanges
619  !
620  ! -- initialize
621  nullify (nummodels)
622  nullify (numexchanges)
623  !
624  ! -- set memory paths
625  sim_mempath = create_mem_path(component='SIM', context=idm_context)
626  simnam_mempath = create_mem_path('SIM', 'NAM', idm_context)
627  !
628  ! -- set pointers to loaded simnam arrays
629  call mem_setptr(mtypes, 'MTYPE', simnam_mempath)
630  call mem_setptr(etypes, 'EXGTYPE', simnam_mempath)
631  !
632  ! -- allocate variables
633  call mem_allocate(nummodels, 'NUMMODELS', sim_mempath)
634  call mem_allocate(numexchanges, 'NUMEXCHANGES', sim_mempath)
635  !
636  ! -- set values
637  nummodels = size(mtypes)
638  numexchanges = size(etypes)
639  !
640  ! -- return
641  return
642  end subroutine simnam_load_dim
643 
644  !> @brief set sim nam input context default integer value
645  !<
646  subroutine allocate_simnam_int(input_mempath, idt)
649  character(len=LENMEMPATH), intent(in) :: input_mempath
650  type(inputparamdefinitiontype), pointer, intent(in) :: idt
651  integer(I4B), pointer :: intvar
652  !
653  ! -- allocate and set default
654  call mem_allocate(intvar, idt%mf6varname, input_mempath)
655  !
656  select case (idt%mf6varname)
657  case ('CONTINUE')
658  intvar = isimcontinue
659  case ('NOCHECK')
660  intvar = isimcheck
661  case ('MAXERRORS')
662  intvar = 1000 !< MessageType max_message
663  case ('MXITER')
664  intvar = 1
665  case ('PRINT_INPUT')
666  intvar = 0
667  case default
668  write (errmsg, '(a,a)') &
669  'Idm SIMNAM Load default value setting '&
670  &'is unhandled for this variable: ', &
671  trim(idt%mf6varname)
672  call store_error(errmsg)
674  end select
675  !
676  ! -- return
677  return
678  end subroutine allocate_simnam_int
679 
680  !> @brief MODFLOW 6 mfsim.nam parameter allocate and set
681  !<
682  subroutine allocate_simnam_param(input_mempath, idt)
683  use simvariablesmodule, only: simfile
687  character(len=LENMEMPATH), intent(in) :: input_mempath
688  type(inputparamdefinitiontype), pointer, intent(in) :: idt
689  character(len=LINELENGTH), pointer :: cstr
690  type(characterstringtype), dimension(:), &
691  pointer, contiguous :: acharstr1d
692  !
693  ! -- initialize
694  !
695  select case (idt_datatype(idt))
696  case ('KEYWORD', 'INTEGER')
697  !
698  if (idt%in_record) then
699  ! -- no-op
700  else
701  ! -- allocate and set default
702  call allocate_simnam_int(input_mempath, idt)
703  end if
704  !
705  case ('STRING')
706  !
707  ! -- did this param originate from sim namfile RECARRAY type
708  if (idt%in_record) then
709  !
710  ! -- allocate 0 size CharacterStringType array
711  call mem_allocate(acharstr1d, linelength, 0, idt%mf6varname, &
712  input_mempath)
713  else
714  !
715  ! -- allocate empty string
716  call mem_allocate(cstr, linelength, idt%mf6varname, input_mempath)
717  cstr = ''
718  end if
719  case ('RECORD')
720  ! -- no-op
721  case default
722  write (errmsg, '(a,a)') &
723  'IdmLoad allocate simnam param unhandled datatype: ', &
724  trim(idt%datatype)
725  call store_error(errmsg)
727  end select
728  !
729  ! -- return
730  return
731  end subroutine allocate_simnam_param
732 
733  !> @brief MODFLOW 6 mfsim.nam input context parameter allocation
734  !<
735  subroutine simnam_allocate()
740  character(len=LENMEMPATH) :: input_mempath
741  type(modflowinputtype) :: mf6_input
742  type(inputparamdefinitiontype), pointer :: idt
743  integer(I4B) :: iparam, isize
744  !
745  ! -- set memory path
746  input_mempath = create_mem_path('SIM', 'NAM', idm_context)
747  !
748  ! -- create description of input
749  mf6_input = getmodflowinput('NAM6', 'SIM', 'NAM', 'SIM', 'NAM')
750  !
751  ! -- allocate sim namfile parameters if not in input context
752  do iparam = 1, size(mf6_input%param_dfns)
753  !
754  ! -- assign param definition pointer
755  idt => mf6_input%param_dfns(iparam)
756  !
757  ! -- check if variable is already allocated
758  call get_isize(idt%mf6varname, input_mempath, isize)
759  !
760  if (isize < 0) then
761  !
762  ! -- allocate and set parameter
763  call allocate_simnam_param(input_mempath, idt)
764  !
765  end if
766  end do
767  !
768  ! -- return
769  return
770  end subroutine simnam_allocate
771 
772 end module idmloadmodule
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:45
integer(i4b), parameter lencomponentname
maximum length of a component name
Definition: Constants.f90:18
integer(i4b), parameter lenmodelname
maximum length of the model name
Definition: Constants.f90:22
integer(i4b), parameter lenexchangename
maximum length of the exchange name
Definition: Constants.f90:24
integer(i4b), parameter lenmempath
maximum length of the memory path
Definition: Constants.f90:27
This module contains the DefinitionSelectModule.
character(len=linelength) function, public idt_datatype(idt)
return input definition type datatype
class(distributedsimtype) function, pointer, public get_dsim()
Get pointer to the distributed simulation object.
logical function, public idm_integrated(component, subcomponent)
This module contains the IdmLoadModule.
Definition: IdmLoad.f90:7
subroutine, public simnam_load(paramlog)
MODFLOW 6 mfsim.nam input load routine.
Definition: IdmLoad.f90:493
integer(i4b) function input_param_log()
return sim input context PRINT_INPUT value
Definition: IdmLoad.f90:589
subroutine load_model_pkgs(model_pkg_inputs, iout)
load integrated model package files
Definition: IdmLoad.f90:192
subroutine, public idm_da(iout)
idm deallocate routine
Definition: IdmLoad.f90:86
subroutine, public idm_df()
advance package dynamic data for period steps
Definition: IdmLoad.f90:38
subroutine, public simtdis_load()
MODFLOW 6 tdis input load routine.
Definition: IdmLoad.f90:515
subroutine, public idm_rp()
load package dynamic data for period
Definition: IdmLoad.f90:54
subroutine, public idm_ad()
advance package dynamic data for period steps
Definition: IdmLoad.f90:70
recursive subroutine input_load(component_type, subcomponent_type, modelname, pkgname, pkgtype, filename, modelfname, nc_vars, iout)
load an integrated model package from supported source
Definition: IdmLoad.f90:127
subroutine simnam_load_dim()
load simulation summary info to input context
Definition: IdmLoad.f90:608
subroutine allocate_simnam_int(input_mempath, idt)
set sim nam input context default integer value
Definition: IdmLoad.f90:647
subroutine, public load_models(iout)
load model namfiles and model package files
Definition: IdmLoad.f90:247
subroutine dynamic_da(iout)
deallocate all model dynamic loader collections
Definition: IdmLoad.f90:566
subroutine, public load_exchanges(iout)
load exchange files
Definition: IdmLoad.f90:326
subroutine simnam_allocate()
MODFLOW 6 mfsim.nam input context parameter allocation.
Definition: IdmLoad.f90:736
class(modeldynamicpkgstype) function, pointer dynamic_model_pkgs(modeltype, modelname, modelfname, nc_fname, ncid, iout)
retrieve list of model dynamic loaders
Definition: IdmLoad.f90:528
subroutine allocate_simnam_param(input_mempath, idt)
MODFLOW 6 mfsim.nam parameter allocate and set.
Definition: IdmLoad.f90:683
This module contains the InputDefinitionModule.
This module contains the InputLoadTypeModule.
class(modeldynamicpkgstype) function, pointer, public getdynamicmodelfromlist(list, idx)
get model dynamic packages object from list
subroutine, public adddynamicmodeltolist(list, model_dynamic)
add model dynamic packages object to list
type(listtype), public model_dynamic_pkgs
This module defines variable data types.
Definition: kind.f90:8
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine split_mem_path(mem_path, component, subcomponent)
Split the memory path into component(s)
subroutine, public memorystore_remove(component, subcomponent, context)
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
This module contains the ModelPackageInputsModule.
This module contains the ModflowInputModule.
Definition: ModflowInput.f90:9
type(modflowinputtype) function, public getmodflowinput(pkgtype, component_type, subcomponent_type, component_name, subcomponent_name, filename)
function to return ModflowInputType
This module contains the NCFileVarsModule.
Definition: NCFileVars.f90:7
This module contains simulation methods.
Definition: Sim.f90:10
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) isimcontinue
simulation continue flag (1) to continue if isimcnvg = 0, (0) to terminate
character(len=linelength) simfile
simulation name file
This module contains the SourceCommonModule.
Definition: SourceCommon.f90:7
character(len=lencomponentname) function, public idm_subcomponent_type(component, subcomponent)
component from package or model type
subroutine, public inlen_check(input_name, mf6_name, maxlen, name_type)
store an error for input exceeding internal name length
character(len=lencomponentname) function, public idm_component_type(component)
component from package or model type
integer(i4b) function, public ifind_charstr(array, str)
This module contains the SourceLoadModule.
Definition: SourceLoad.F90:8
subroutine, public load_simnam()
Definition: SourceLoad.F90:164
integer(i4b) function, public open_source_file(pkgtype, filename, modelfname, iout)
Definition: SourceLoad.F90:110
subroutine, public load_simtdis()
Definition: SourceLoad.F90:203
type(ncfilevarstype) function, pointer, public netcdf_context(modeltype, component_type, modelname, modelfname, iout)
create model netcdf context
Definition: SourceLoad.F90:412
subroutine, public nc_close(ncid, nc_fname)
close an open netcdf file
Definition: SourceLoad.F90:393
integer(i4b) function, public remote_model_ndim(mtype, mfname)
Definition: SourceLoad.F90:260
class(staticpkgloadbasetype) function, pointer, public create_input_loader(component_type, subcomponent_type, component_name, subcomponent_name, input_type, input_fname, component_fname, nc_vars)
factory function to create and setup model package static loader
Definition: SourceLoad.F90:37
subroutine, public load_modelnam(mtype, mfname, mname, iout)
Definition: SourceLoad.F90:136
This class is used to store a single deferred-length character string. It was designed to work in an ...
Definition: CharString.f90:23
Base abstract type for dynamic input loader.
type for storing a dynamic package load list
Base abstract type for static input loader.
A generic heterogeneous doubly-linked list.
Definition: List.f90:14
derived type for model package inputs type
derived type for storing input definition for a file
Type describing modflow6 input variables in model NetCDF file.
Definition: NCFileVars.f90:48