51 integer(I4B),
pointer :: invar
66 character(len=LENVARNAME) :: blockname
67 character(len=LENVARNAME),
allocatable :: named_bound(:)
68 integer(I4B),
pointer :: naux => null()
69 integer(I4B),
pointer :: maxbound => null()
70 integer(I4B),
pointer :: boundnames => null()
71 integer(I4B),
pointer :: iprpak => null()
72 integer(I4B),
pointer :: nbound => null()
73 integer(I4B),
pointer :: ncpl => null()
74 integer(I4B),
pointer :: nodes => null()
75 integer(I4B) :: loadtype
76 integer(I4B) :: ctxtype
77 integer(I4B) :: nleading = 0
78 logical(LGP) :: readarray
79 logical(LGP) :: is_dimensions_scoped = .false.
80 logical(LGP) :: is_cellid_scoped = .false.
81 logical(LGP) :: has_setting_dispatch = .false.
84 contiguous :: auxname_cst => null()
86 contiguous :: boundname_cst => null()
87 real(dp),
dimension(:, :),
pointer, &
88 contiguous :: auxvar => null()
89 integer(I4B),
dimension(:),
pointer,
contiguous :: mshape => null()
90 character(len=LINELENGTH),
dimension(:),
allocatable :: params
109 subroutine init(this, mf6_input, blockname, named_bound)
115 character(len=*),
optional,
intent(in) :: blockname
116 character(len=*),
dimension(:),
optional,
intent(in) :: named_bound
120 this%mf6_input = mf6_input
121 this%readarray = .false.
125 select case (mf6_input%load_scope)
129 if (mf6_input%subcomponent_type ==
'NAM')
then
131 else if (mf6_input%subcomponent_type ==
'TDIS' .or. &
132 mf6_input%subcomponent_type ==
'HPC')
then
134 else if (mf6_input%component_type ==
'EXG')
then
138 if (mf6_input%subcomponent_type ==
'OC' .or. &
139 mf6_input%subcomponent_type ==
'STO')
then
148 errmsg =
'LoadContext unidentified context for mempath: '// &
149 trim(mf6_input%mempath)
153 if (
present(blockname))
then
154 this%blockname = blockname
155 call upcase(this%blockname)
157 this%blockname =
'PERIOD'
160 if (
present(named_bound))
then
161 allocate (this%named_bound(
size(named_bound)))
162 do n = 1,
size(named_bound)
163 this%named_bound(n) = named_bound(n)
164 call upcase(this%named_bound(n))
167 allocate (this%named_bound(1))
168 this%named_bound(1) =
'MAXBOUND'
172 do n = 1,
size(mf6_input%block_dfns)
173 if (mf6_input%block_dfns(n)%blockname == this%blockname)
then
174 if (mf6_input%block_dfns(n)%aggregate)
then
175 if (this%blockname ==
'PERIOD' .and. &
191 this%has_setting_dispatch = &
192 this%is_dimensions_scoped .or. this%is_cellid_scoped
193 if (this%has_setting_dispatch)
then
194 this%setting_idt => &
195 idt_default(mf6_input%component_type, mf6_input%subcomponent_type, &
196 'PERIOD',
'SETTING',
'SETTING',
'STRING')
202 do n = 1,
size(mf6_input%param_dfns)
203 idt => mf6_input%param_dfns(n)
204 if (idt%blockname ==
'OPTIONS')
then
205 select case (idt%tagname)
206 case (
'READASARRAYS')
208 this%readarray = .true.
209 case (
'READARRAYGRID')
211 this%readarray = .true.
220 call this%set_params()
223 call this%allocate_scalars()
234 character(len=LINELENGTH),
allocatable :: cols(:), ks_cols(:)
235 integer(I4B) :: nmembers, ncol, isize
236 integer(I4B),
pointer :: maxbound_ptr
242 call setptr(this%nbound,
'NBOUND', this%mf6_input%mempath)
243 call setval(this%naux,
'NAUX', this%mf6_input%mempath)
244 call setval(this%ncpl,
'NCPL', this%mf6_input%mempath)
245 call setval(this%nodes,
'NODES', this%mf6_input%mempath)
246 call setval(this%boundnames,
'BOUNDNAMES', this%mf6_input%mempath)
247 call setval(this%iprpak,
'IPRPAK', this%mf6_input%mempath)
250 allocate (this%maxbound)
255 if (this%maxbound == 0)
then
256 call get_isize(
'MAXBOUND', this%mf6_input%mempath, isize)
258 call mem_setptr(maxbound_ptr,
'MAXBOUND', this%mf6_input%mempath)
259 this%maxbound = maxbound_ptr
260 nullify (maxbound_ptr)
269 this%blockname ==
'PERIOD')
then
271 this%mf6_input%component_mempath)
273 if (this%ncpl == 0)
then
274 if (
size(this%mshape) == 2)
then
275 this%ncpl = this%mshape(2)
276 else if (
size(this%mshape) == 3)
then
277 this%ncpl = this%mshape(2) * this%mshape(3)
281 if (this%nodes == 0) this%nodes = product(this%mshape)
290 this%mf6_input%component_type, &
291 this%mf6_input%subcomponent_type, &
295 if (
associated(ks_aidt))
then
298 if (
allocated(cols))
deallocate (cols)
299 if (
allocated(ks_cols))
deallocate (ks_cols)
300 if (this%maxbound == 0)
then
301 this%maxbound = this%nodes * nmembers
302 else if (this%is_dimensions_scoped .and. nmembers > 0)
then
305 this%maxbound = this%maxbound * nmembers
322 integer(I4B),
dimension(:, :),
pointer,
contiguous :: cellid
323 integer(I4B),
dimension(:),
pointer,
contiguous :: nodeulist
326 this%blockname ==
'PERIOD')
then
328 if (this%readarray)
then
329 call mem_allocate(cellid, 0, 0,
'CELLID', this%mf6_input%mempath)
336 call mem_allocate(nodeulist, 0,
'NODEULIST', this%mf6_input%mempath)
342 call setptr(this%auxname_cst,
'AUXILIARY', &
344 call setptr(this%boundname_cst,
'BOUNDNAME', &
346 call setptr(this%auxvar, this%mf6_input%mempath)
349 else if (this%ctxtype ==
exchange)
then
351 call setptr(this%auxname_cst,
'AUXILIARY', &
353 call setptr(this%boundname_cst,
'BOUNDNAME', &
355 call setptr(this%auxvar, this%mf6_input%mempath)
365 integer(I4B) :: dimsize
370 if (this%readarray)
then
371 select case (idt%shape)
372 case (
'NCPL',
'NAUX NCPL')
374 case (
'NODES',
'NAUX NODES')
375 dimsize = this%maxbound
380 select case (idt%datatype)
382 if (this%loadtype ==
list)
then
384 this%mf6_input%mempath)
387 if (this%loadtype ==
list)
then
389 this%mf6_input%mempath)
392 if (this%loadtype ==
list)
then
394 this%mf6_input%mempath)
397 if (this%loadtype ==
list)
then
398 if (idt%shape ==
'NCELLDIM')
then
400 idt%mf6varname, this%mf6_input%mempath)
402 else if (this%readarray)
then
404 this%mf6_input%mempath)
407 if (idt%shape ==
'NAUX')
then
409 idt%mf6varname, this%mf6_input%mempath)
410 else if (this%readarray)
then
412 this%mf6_input%mempath)
415 if (this%readarray)
then
417 this%mf6_input%mempath)
429 subroutine tags(this, params, nparam, input_name, create)
434 character(len=LINELENGTH),
dimension(:),
allocatable, &
435 intent(inout) :: params
436 integer(I4B),
intent(inout) :: nparam
437 character(len=*),
intent(in) :: input_name
438 logical(LGP),
optional,
intent(in) :: create
440 character(len=LINELENGTH) :: dev_msg
441 logical(LGP) :: allocate_params
445 allocate_params = .false.
448 if (
present(create))
then
449 allocate_params = create
452 if (
allocated(params))
deallocate (params)
453 nparam =
size(this%params)
454 allocate (params(nparam))
458 this%mf6_input%component_type, &
459 this%mf6_input%subcomponent_type, &
460 this%blockname, this%params(n),
'')
463 if (idt%developmode)
then
464 dev_msg =
'Input tag "'//trim(idt%tagname)// &
465 &
'" read from file "'//trim(input_name)// &
466 &
'" is still under development. Install the &
467 &nightly build or compile from source with IDEVELOPMODE = 1.'
471 params(n) = this%params(n)
472 if (allocate_params)
call this%allocate_param(idt)
478 function in_scope(this, mf6_input, blockname, tagname)
483 character(len=*),
intent(in) :: blockname
484 character(len=*),
intent(in) :: tagname
487 character(len=LENVARNAME) :: checkname
488 character(len=LINELENGTH) :: datatype
489 integer(I4B) :: isize, checksize
490 integer(I4B),
pointer :: intptr
494 mf6_input%component_type, &
495 mf6_input%subcomponent_type, &
496 blockname, tagname,
'')
497 if (idt%required)
then
503 if (datatype ==
'KEYSTRING' .or. &
504 datatype ==
'RECARRAY' .or. &
505 datatype ==
'RECORD')
return
512 if (tagname ==
'AUXVAR' .or. &
513 tagname ==
'AUX')
then
515 else if (tagname ==
'BOUNDNAME')
then
516 checkname =
'BOUNDNAMES'
517 else if (tagname ==
'I'//trim(mf6_input%subcomponent_type(1:3)))
then
520 select case (mf6_input%subcomponent_type)
522 if (tagname ==
'PXDP' .or. tagname ==
'PETM')
then
525 else if (tagname ==
'PETM0')
then
526 checkname =
'SURFRATESPEC'
528 case (
'MVR',
'MVT',
'MVE')
529 if (tagname ==
'MNAME' .or. &
530 tagname ==
'MNAME1' .or. &
531 tagname ==
'MNAME2')
then
532 checkname =
'MODELNAMES'
537 if (tagname ==
'MIXED')
in_scope = .true.
541 errmsg =
'LoadContext in_scope needs new check for: '// &
542 trim(mf6_input%subcomponent_type)//
'/'//trim(idt%tagname)
549 call get_isize(checkname, mf6_input%mempath, isize)
551 call mem_setptr(intptr, checkname, mf6_input%mempath)
552 if (intptr > checksize)
in_scope = .true.
566 character(len=LINELENGTH),
dimension(:),
allocatable :: tags
567 character(len=LINELENGTH),
dimension(:),
allocatable :: cols
568 integer(I4B) :: keepcnt, iparam, nparam
569 logical(LGP) :: keep, tag_found
574 if (this%loadtype ==
list .or. &
579 this%mf6_input%component_type, &
580 this%mf6_input%subcomponent_type, &
585 nparam =
size(this%mf6_input%param_dfns)
589 do iparam = 1, nparam
590 if (this%loadtype ==
list .or. &
594 this%mf6_input%component_type, &
595 this%mf6_input%subcomponent_type, &
596 this%blockname, cols(iparam),
'', &
600 idt => this%mf6_input%param_dfns(iparam)
603 if (.not. tag_found)
then
605 else if (idt%blockname /= this%blockname)
then
608 keep = this%in_scope(this%mf6_input, this%blockname, idt%tagname)
612 keepcnt = keepcnt + 1
614 tags(keepcnt) = trim(idt%tagname)
623 if (this%loadtype ==
list .or. &
624 this%loadtype ==
keystring) this%nleading = nparam
627 allocate (this%params(nparam))
630 do iparam = 1, nparam
631 this%params(iparam) = trim(tags(iparam))
635 if (
allocated(tags))
deallocate (tags)
652 character(len=*),
intent(in) :: mf6varname
653 character(len=LENVARNAME) :: varname
654 integer(I4B),
pointer :: intvar
656 call mem_allocate(intvar, varname, this%mf6_input%mempath)
665 if (
allocated(this%named_bound))
deallocate (this%named_bound)
667 if (
associated(this%setting_idt))
then
668 deallocate (this%setting_idt)
669 nullify (this%setting_idt)
675 deallocate (this%naux)
676 deallocate (this%ncpl)
677 deallocate (this%nodes)
678 deallocate (this%maxbound)
679 deallocate (this%boundnames)
680 deallocate (this%iprpak)
685 nullify (this%nbound)
688 nullify (this%maxbound)
689 nullify (this%boundnames)
690 nullify (this%iprpak)
691 nullify (this%auxname_cst)
692 nullify (this%boundname_cst)
693 nullify (this%auxvar)
694 nullify (this%mshape)
703 character(len=LINELENGTH),
intent(in) :: rec_cols(:)
704 integer(I4B),
intent(in) :: nrec_col
706 character(len=LINELENGTH) :: token, tagname
707 integer(I4B) :: m, n, ilen
710 token = trim(rec_cols(m))
712 ilen = len_trim(token)
714 if (token(ilen - 6:ilen) /=
'SETTING') cycle
715 do n = 1,
size(mf6_input%aggregate_dfns)
716 tagname = mf6_input%aggregate_dfns(n)%tagname
718 if (trim(tagname) == trim(token))
then
719 ks_aidt => mf6_input%aggregate_dfns(n)
720 if (
idt_datatype(ks_aidt) /=
'KEYSTRING') ks_aidt => null()
736 character(len=LINELENGTH),
allocatable,
intent(inout) :: member_names(:)
737 integer(I4B),
intent(inout) :: nmembers
739 character(len=LINELENGTH),
allocatable :: sub_cols(:)
740 character(len=LINELENGTH) :: token, tagname
741 integer(I4B) :: k, j, nsub_col
744 token = trim(sub_cols(k))
746 do j = 1,
size(mf6_input%param_dfns)
747 sub_idt => mf6_input%param_dfns(j)
748 if (sub_idt%blockname /=
'PERIOD') cycle
749 tagname = sub_idt%tagname
751 if (trim(tagname) /= trim(token)) cycle
753 nmembers = nmembers + 1
755 member_names(nmembers) = trim(sub_idt%tagname)
759 if (
allocated(sub_cols))
deallocate (sub_cols)
768 logical(LGP) :: res, has_period
770 character(len=LINELENGTH),
allocatable :: cols(:)
771 integer(I4B) :: n, ncol
774 do n = 1,
size(mf6_input%block_dfns)
775 if (mf6_input%block_dfns(n)%blockname ==
'PERIOD')
then
779 if (.not. has_period)
return
781 mf6_input%component_type, &
782 mf6_input%subcomponent_type, &
787 if (
associated(ks_aidt)) res = .true.
789 if (
allocated(cols))
deallocate (cols)
799 logical(LGP) :: has_dimensions
802 has_dimensions = .false.
803 do n = 1,
size(mf6_input%block_dfns)
804 if (mf6_input%block_dfns(n)%blockname ==
'DIMENSIONS')
then
805 has_dimensions = .true.
809 if (mf6_input%block_dfns(n)%blockname ==
'PACKAGEDATA')
return
824 do n = 1,
size(mf6_input%param_dfns)
825 if (mf6_input%param_dfns(n)%blockname ==
'PERIOD' .and. &
826 mf6_input%param_dfns(n)%tagname ==
'CELLID')
then
848 character(len=LINELENGTH),
allocatable,
intent(out) :: member_names(:)
849 integer(I4B),
intent(out) :: nmembers
851 character(len=LINELENGTH),
allocatable :: rec_cols(:), ks_cols(:)
852 character(len=LINELENGTH) :: rec_token, tagname
853 integer(I4B) :: m, n, nrec_col, nks_col
859 this%mf6_input%component_type, &
860 this%mf6_input%subcomponent_type, &
866 if (
allocated(rec_cols))
deallocate (rec_cols)
867 if (.not.
associated(ks_aidt))
return
874 rec_token = trim(ks_cols(m))
878 do n = 1,
size(this%mf6_input%param_dfns)
879 if (this%mf6_input%param_dfns(n)%blockname /=
'PERIOD') cycle
880 tagname = this%mf6_input%param_dfns(n)%tagname
882 if (trim(tagname) /= trim(rec_token)) cycle
884 idt => this%mf6_input%param_dfns(n)
891 nmembers = nmembers + 1
893 member_names(nmembers) = trim(this%mf6_input%param_dfns(n)%tagname)
899 if (
allocated(ks_cols))
deallocate (ks_cols)
906 character(len=*),
intent(in) :: mf6varname
907 character(len=LENVARNAME) :: varname
909 character(len=2) :: prefix =
'IN'
910 ilen = len_trim(mf6varname)
912 varname = prefix//mf6varname(1:(
lenvarname - len(prefix)))
914 varname = prefix//trim(mf6varname)
922 integer(I4B),
intent(in) :: strlen
923 integer(I4B),
intent(in) :: nrow
924 character(len=*),
intent(in) :: varname
925 character(len=*),
intent(in) :: mempath
927 contiguous :: charstr1d
929 call mem_allocate(charstr1d, strlen, nrow, varname, mempath)
939 integer(I4B),
intent(in) :: nrow
940 character(len=*),
intent(in) :: varname
941 character(len=*),
intent(in) :: mempath
942 integer(I4B),
dimension(:),
pointer,
contiguous :: int1d
954 integer(I4B),
intent(in) :: ncol
955 integer(I4B),
intent(in) :: nrow
956 character(len=*),
intent(in) :: varname
957 character(len=*),
intent(in) :: mempath
958 integer(I4B),
dimension(:, :),
pointer,
contiguous :: int2d
972 integer(I4B),
intent(in) :: nrow
973 character(len=*),
intent(in) :: varname
974 character(len=*),
intent(in) :: mempath
975 real(DP),
dimension(:),
pointer,
contiguous :: dbl1d
987 integer(I4B),
intent(in) :: ncol
988 integer(I4B),
intent(in) :: nrow
989 character(len=*),
intent(in) :: varname
990 character(len=*),
intent(in) :: mempath
991 real(DP),
dimension(:, :),
pointer,
contiguous :: dbl2d
1010 character(len=*),
dimension(:),
intent(in) :: named_bound
1011 character(len=*),
intent(in) :: mempath
1012 integer(I4B),
intent(inout) :: total
1013 integer(I4B),
pointer :: dimptr
1014 integer(I4B) :: n, isize
1016 do n = 1,
size(named_bound)
1017 call get_isize(trim(named_bound(n)), mempath, isize)
1018 if (isize > -1)
then
1019 call mem_setptr(dimptr, trim(named_bound(n)), mempath)
1020 total = total + dimptr
1031 integer(I4B),
pointer,
intent(inout) :: intptr
1032 character(len=*),
intent(in) :: varname
1033 character(len=*),
intent(in) :: mempath
1034 logical(LGP) :: found
1037 call mem_set_value(intptr, varname, mempath, found, release=.false.)
1045 integer(I4B),
pointer,
intent(inout) :: intptr
1046 character(len=*),
intent(in) :: varname
1047 character(len=*),
intent(in) :: mempath
1048 integer(I4B) :: isize
1050 if (isize > -1)
then
1063 contiguous,
intent(inout) :: charstr1d
1064 character(len=*),
intent(in) :: varname
1065 character(len=*),
intent(in) :: mempath
1066 integer(I4B),
intent(in) :: strlen
1067 integer(I4B) :: isize
1069 if (isize > -1)
then
1072 call mem_allocate(charstr1d, strlen, 0, varname, mempath)
1081 real(DP),
dimension(:, :),
pointer, &
1082 contiguous,
intent(inout) :: auxvar
1083 character(len=*),
intent(in) :: mempath
1084 integer(I4B) :: isize
1085 call get_isize(
'AUXVAR', mempath, isize)
1086 if (isize > -1)
then
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lenvarname
maximum length of a variable name
integer(i4b), parameter lenauxname
maximum length of a aux variable
integer(i4b), parameter lenboundname
maximum length of a bound name
integer(i4b), parameter izero
integer constant zero
real(dp), parameter dzero
real constant zero
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public idt_default(component_type, subcomponent_type, blockname, tagname, mf6varname, datatype)
return allocated input definition type
type(inputparamdefinitiontype) function, pointer, public get_aggregate_definition_type(input_definition_types, component_type, subcomponent_type, blockname)
Return aggregate definition.
subroutine, public idt_parse_rectype(idt, cols, ncol)
allocate and set RECARRAY, KEYSTRING or RECORD param list
character(len=linelength) function, public idt_datatype(idt)
return input definition type datatype
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename, found)
Return parameter definition.
Disable development features in release mode.
subroutine, public developmode(errmsg, iunit)
Terminate if in release mode (guard development features)
This module defines variable data types.
This module contains the LoadContextModule.
subroutine set_params(this)
set set of in scope parameters for package
subroutine allocate_dbl2d(ncol, nrow, varname, mempath)
allocate dbl2d
subroutine keystring_member_names(this, member_names, nmembers)
Return keystring member column names for the PERIOD block.
subroutine tags(this, params, nparam, input_name, create)
get in scope package params
subroutine setptr_auxvar(auxvar, mempath)
set auxvar pointer
subroutine allocate_charstr1d(strlen, nrow, varname, mempath)
allocate character string type array
subroutine allocate_int1d(nrow, varname, mempath)
allocate int1d
@ load_undef
undefined load type
@ gridarray
readarraygrid load
@ keystring
basic keystring period block load
@ layerarray
readasarrays load
@ list
list (structarray) based load
type(inputparamdefinitiontype) function, pointer find_setting_aggregate(mf6_input, rec_cols, nrec_col)
Return the KEYSTRING aggregate for the SETTING token in rec_cols, or null().
subroutine allocate_dbl1d(nrow, varname, mempath)
allocate dbl1d
@ stresspkg
model stress package context type
@ exchange
exchange context type
@ model
model context type
@ modelpkg
model package context type
@ context_undef
undefined context type
logical(lgp) function, public is_cellid_addressed(mf6_input)
Return .true. if mf6_input is a keystring PERIOD dispatch whose leading column is CELLID (e....
subroutine setval(intptr, varname, mempath)
allocate intptr and update from input contextset intptr to varname
subroutine allocate_scalars(this)
allocate scalars
subroutine allocate_param(this, idt)
allocate a package dynamic input parameter
logical(lgp) function, public has_dimensions_block(mf6_input)
Return .true. if mf6_input is a keystring PERIOD dispatch paired with a DIMENSIONS block (e....
subroutine allocate_arrays(this)
allocate arrays
subroutine setptr_int(intptr, varname, mempath)
set intptr to varname
subroutine allocate_int2d(ncol, nrow, varname, mempath)
allocate int2d
subroutine destroy(this)
destroy input context object
character(len=lenvarname) function, public rsv_name(mf6varname)
create read state variable name
logical(lgp) function in_scope(this, mf6_input, blockname, tagname)
establish if input parameter is in scope for package load
subroutine sum_named_bounds(named_bound, mempath, total)
sum named dimension variables from mempath
character(len=lenvarname) function rsv_alloc(this, mf6varname)
allocate a read state variable
subroutine setptr_charstr1d(charstr1d, varname, mempath, strlen)
set charstr1d pointer to varname
logical(lgp) function, public is_keystring_period(mf6_input)
Return .true. if mf6_input's PERIOD block uses keystring dispatch.
subroutine expand_record_submembers(mf6_input, rec_idt, member_names, nmembers)
Append sub-member column names from a RECORD compound entry to member_names.
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
integer(i4b) iout
file unit number for simulation output
This class is used to store a single deferred-length character string. It was designed to work in an ...
derived type for boundary package input context
Pointer type for read state variable.