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
80 contiguous :: auxname_cst => null()
82 contiguous :: boundname_cst => null()
83 real(dp),
dimension(:, :),
pointer, &
84 contiguous :: auxvar => null()
85 integer(I4B),
dimension(:),
pointer,
contiguous :: mshape => null()
86 character(len=LINELENGTH),
dimension(:),
allocatable :: params
105 subroutine init(this, mf6_input, blockname, named_bound)
110 character(len=*),
optional,
intent(in) :: blockname
111 character(len=*),
dimension(:),
optional,
intent(in) :: named_bound
115 this%mf6_input = mf6_input
116 this%readarray = .false.
120 select case (mf6_input%load_scope)
124 if (mf6_input%subcomponent_type ==
'NAM')
then
126 else if (mf6_input%subcomponent_type ==
'TDIS' .or. &
127 mf6_input%subcomponent_type ==
'HPC')
then
129 else if (mf6_input%component_type ==
'EXG')
then
133 if (mf6_input%subcomponent_type ==
'OC' .or. &
134 mf6_input%subcomponent_type ==
'STO')
then
143 errmsg =
'LoadContext unidentified context for mempath: '// &
144 trim(mf6_input%mempath)
148 if (
present(blockname))
then
149 this%blockname = blockname
150 call upcase(this%blockname)
152 this%blockname =
'PERIOD'
155 if (
present(named_bound))
then
156 allocate (this%named_bound(
size(named_bound)))
157 do n = 1,
size(named_bound)
158 this%named_bound(n) = named_bound(n)
159 call upcase(this%named_bound(n))
162 allocate (this%named_bound(1))
163 this%named_bound(1) =
'MAXBOUND'
167 do n = 1,
size(mf6_input%block_dfns)
168 if (mf6_input%block_dfns(n)%blockname == this%blockname)
then
169 if (mf6_input%block_dfns(n)%aggregate)
then
170 if (this%blockname ==
'PERIOD' .and. &
183 do n = 1,
size(mf6_input%block_dfns)
184 if (mf6_input%block_dfns(n)%blockname ==
'PACKAGEDATA')
then
193 do n = 1,
size(mf6_input%param_dfns)
194 idt => mf6_input%param_dfns(n)
195 if (idt%blockname ==
'OPTIONS')
then
196 select case (idt%tagname)
197 case (
'READASARRAYS')
199 this%readarray = .true.
200 case (
'READARRAYGRID')
202 this%readarray = .true.
211 call this%set_params()
214 call this%allocate_scalars()
225 character(len=LINELENGTH),
allocatable :: cols(:), ks_cols(:)
226 integer(I4B) :: nmembers, ncol, isize
227 integer(I4B),
pointer :: maxbound_ptr
233 call setptr(this%nbound,
'NBOUND', this%mf6_input%mempath)
234 call setval(this%naux,
'NAUX', this%mf6_input%mempath)
235 call setval(this%ncpl,
'NCPL', this%mf6_input%mempath)
236 call setval(this%nodes,
'NODES', this%mf6_input%mempath)
237 call setval(this%boundnames,
'BOUNDNAMES', this%mf6_input%mempath)
238 call setval(this%iprpak,
'IPRPAK', this%mf6_input%mempath)
241 allocate (this%maxbound)
246 if (this%maxbound == 0)
then
247 call get_isize(
'MAXBOUND', this%mf6_input%mempath, isize)
249 call mem_setptr(maxbound_ptr,
'MAXBOUND', this%mf6_input%mempath)
250 this%maxbound = maxbound_ptr
251 nullify (maxbound_ptr)
260 this%blockname ==
'PERIOD')
then
262 this%mf6_input%component_mempath)
264 if (this%ncpl == 0)
then
265 if (
size(this%mshape) == 2)
then
266 this%ncpl = this%mshape(2)
267 else if (
size(this%mshape) == 3)
then
268 this%ncpl = this%mshape(2) * this%mshape(3)
272 if (this%nodes == 0) this%nodes = product(this%mshape)
282 this%mf6_input%component_type, &
283 this%mf6_input%subcomponent_type, &
287 if (
associated(ks_aidt))
then
290 if (
allocated(cols))
deallocate (cols)
291 if (
allocated(ks_cols))
deallocate (ks_cols)
292 if (this%maxbound == 0) this%maxbound = this%nodes * nmembers
308 integer(I4B),
dimension(:, :),
pointer,
contiguous :: cellid
309 integer(I4B),
dimension(:),
pointer,
contiguous :: nodeulist
312 this%blockname ==
'PERIOD')
then
314 if (this%readarray)
then
315 call mem_allocate(cellid, 0, 0,
'CELLID', this%mf6_input%mempath)
323 call mem_allocate(nodeulist, 0,
'NODEULIST', this%mf6_input%mempath)
330 call setptr(this%auxname_cst,
'AUXILIARY', &
332 call setptr(this%boundname_cst,
'BOUNDNAME', &
334 call setptr(this%auxvar, this%mf6_input%mempath)
337 else if (this%ctxtype ==
exchange)
then
339 call setptr(this%auxname_cst,
'AUXILIARY', &
341 call setptr(this%boundname_cst,
'BOUNDNAME', &
343 call setptr(this%auxvar, this%mf6_input%mempath)
353 integer(I4B) :: dimsize
358 if (this%readarray)
then
359 select case (idt%shape)
360 case (
'NCPL',
'NAUX NCPL')
362 case (
'NODES',
'NAUX NODES')
363 dimsize = this%maxbound
368 select case (idt%datatype)
370 if (this%loadtype ==
list)
then
372 this%mf6_input%mempath)
375 if (this%loadtype ==
list)
then
377 this%mf6_input%mempath)
380 if (this%loadtype ==
list)
then
382 this%mf6_input%mempath)
385 if (this%loadtype ==
list)
then
386 if (idt%shape ==
'NCELLDIM')
then
388 idt%mf6varname, this%mf6_input%mempath)
390 else if (this%readarray)
then
392 this%mf6_input%mempath)
395 if (idt%shape ==
'NAUX')
then
397 idt%mf6varname, this%mf6_input%mempath)
398 else if (this%readarray)
then
400 this%mf6_input%mempath)
403 if (this%readarray)
then
405 this%mf6_input%mempath)
417 subroutine tags(this, params, nparam, input_name, create)
422 character(len=LINELENGTH),
dimension(:),
allocatable, &
423 intent(inout) :: params
424 integer(I4B),
intent(inout) :: nparam
425 character(len=*),
intent(in) :: input_name
426 logical(LGP),
optional,
intent(in) :: create
428 character(len=LINELENGTH) :: dev_msg
429 logical(LGP) :: allocate_params
433 allocate_params = .false.
436 if (
present(create))
then
437 allocate_params = create
440 if (
allocated(params))
deallocate (params)
441 nparam =
size(this%params)
442 allocate (params(nparam))
446 this%mf6_input%component_type, &
447 this%mf6_input%subcomponent_type, &
448 this%blockname, this%params(n),
'')
451 if (idt%developmode)
then
452 dev_msg =
'Input tag "'//trim(idt%tagname)// &
453 &
'" read from file "'//trim(input_name)// &
454 &
'" is still under development. Install the &
455 &nightly build or compile from source with IDEVELOPMODE = 1.'
459 params(n) = this%params(n)
460 if (allocate_params)
call this%allocate_param(idt)
466 function in_scope(this, mf6_input, blockname, tagname)
471 character(len=*),
intent(in) :: blockname
472 character(len=*),
intent(in) :: tagname
475 character(len=LENVARNAME) :: checkname
476 character(len=LINELENGTH) :: datatype
477 integer(I4B) :: isize, checksize
478 integer(I4B),
pointer :: intptr
482 mf6_input%component_type, &
483 mf6_input%subcomponent_type, &
484 blockname, tagname,
'')
485 if (idt%required)
then
491 if (datatype ==
'KEYSTRING' .or. &
492 datatype ==
'RECARRAY' .or. &
493 datatype ==
'RECORD')
return
500 if (tagname ==
'AUXVAR' .or. &
501 tagname ==
'AUX')
then
503 else if (tagname ==
'BOUNDNAME')
then
504 checkname =
'BOUNDNAMES'
505 else if (tagname ==
'I'//trim(mf6_input%subcomponent_type(1:3)))
then
508 select case (mf6_input%subcomponent_type)
510 if (tagname ==
'PXDP' .or. tagname ==
'PETM')
then
513 else if (tagname ==
'PETM0')
then
514 checkname =
'SURFRATESPEC'
516 case (
'MVR',
'MVT',
'MVE')
517 if (tagname ==
'MNAME' .or. &
518 tagname ==
'MNAME1' .or. &
519 tagname ==
'MNAME2')
then
520 checkname =
'MODELNAMES'
525 if (tagname ==
'MIXED')
in_scope = .true.
529 errmsg =
'LoadContext in_scope needs new check for: '// &
530 trim(mf6_input%subcomponent_type)//
'/'//trim(idt%tagname)
537 call get_isize(checkname, mf6_input%mempath, isize)
539 call mem_setptr(intptr, checkname, mf6_input%mempath)
540 if (intptr > checksize)
in_scope = .true.
554 character(len=LINELENGTH),
dimension(:),
allocatable :: tags
555 character(len=LINELENGTH),
dimension(:),
allocatable :: cols
556 integer(I4B) :: keepcnt, iparam, nparam
557 logical(LGP) :: keep, tag_found
562 if (this%loadtype ==
list .or. &
568 this%mf6_input%component_type, &
569 this%mf6_input%subcomponent_type, &
574 nparam =
size(this%mf6_input%param_dfns)
578 do iparam = 1, nparam
579 if (this%loadtype ==
list .or. &
584 this%mf6_input%component_type, &
585 this%mf6_input%subcomponent_type, &
586 this%blockname, cols(iparam),
'', &
590 idt => this%mf6_input%param_dfns(iparam)
593 if (.not. tag_found)
then
595 else if (idt%blockname /= this%blockname)
then
598 keep = this%in_scope(this%mf6_input, this%blockname, idt%tagname)
602 keepcnt = keepcnt + 1
604 tags(keepcnt) = trim(idt%tagname)
613 if (this%loadtype ==
list .or. &
615 this%loadtype ==
advanced) this%nleading = nparam
618 allocate (this%params(nparam))
621 do iparam = 1, nparam
622 this%params(iparam) = trim(tags(iparam))
626 if (
allocated(tags))
deallocate (tags)
643 character(len=*),
intent(in) :: mf6varname
644 character(len=LENVARNAME) :: varname
645 integer(I4B),
pointer :: intvar
647 call mem_allocate(intvar, varname, this%mf6_input%mempath)
656 if (
allocated(this%named_bound))
deallocate (this%named_bound)
661 deallocate (this%naux)
662 deallocate (this%ncpl)
663 deallocate (this%nodes)
664 deallocate (this%maxbound)
665 deallocate (this%boundnames)
666 deallocate (this%iprpak)
671 nullify (this%nbound)
674 nullify (this%maxbound)
675 nullify (this%boundnames)
676 nullify (this%iprpak)
677 nullify (this%auxname_cst)
678 nullify (this%boundname_cst)
679 nullify (this%auxvar)
680 nullify (this%mshape)
689 character(len=LINELENGTH),
intent(in) :: rec_cols(:)
690 integer(I4B),
intent(in) :: nrec_col
692 character(len=LINELENGTH) :: token, tagname
693 integer(I4B) :: m, n, ilen
696 token = trim(rec_cols(m))
698 ilen = len_trim(token)
700 if (token(ilen - 6:ilen) /=
'SETTING') cycle
701 do n = 1,
size(mf6_input%aggregate_dfns)
702 tagname = mf6_input%aggregate_dfns(n)%tagname
704 if (trim(tagname) == trim(token))
then
705 ks_aidt => mf6_input%aggregate_dfns(n)
706 if (
idt_datatype(ks_aidt) /=
'KEYSTRING') ks_aidt => null()
722 character(len=LINELENGTH),
allocatable,
intent(inout) :: member_names(:)
723 integer(I4B),
intent(inout) :: nmembers
725 character(len=LINELENGTH),
allocatable :: sub_cols(:)
726 character(len=LINELENGTH) :: token, tagname
727 integer(I4B) :: k, j, nsub_col
730 token = trim(sub_cols(k))
732 do j = 1,
size(mf6_input%param_dfns)
733 sub_idt => mf6_input%param_dfns(j)
734 if (sub_idt%blockname /=
'PERIOD') cycle
735 tagname = sub_idt%tagname
737 if (trim(tagname) /= trim(token)) cycle
739 nmembers = nmembers + 1
741 member_names(nmembers) = trim(sub_idt%tagname)
745 if (
allocated(sub_cols))
deallocate (sub_cols)
754 logical(LGP) :: res, has_period
756 character(len=LINELENGTH),
allocatable :: cols(:)
757 integer(I4B) :: n, ncol
760 do n = 1,
size(mf6_input%block_dfns)
761 if (mf6_input%block_dfns(n)%blockname ==
'PERIOD')
then
765 if (.not. has_period)
return
767 mf6_input%component_type, &
768 mf6_input%subcomponent_type, &
773 if (
associated(ks_aidt)) res = .true.
775 if (
allocated(cols))
deallocate (cols)
793 character(len=LINELENGTH),
allocatable,
intent(out) :: member_names(:)
794 integer(I4B),
intent(out) :: nmembers
796 character(len=LINELENGTH),
allocatable :: rec_cols(:), ks_cols(:)
797 character(len=LINELENGTH) :: rec_token, tagname
798 integer(I4B) :: m, n, nrec_col, nks_col
804 this%mf6_input%component_type, &
805 this%mf6_input%subcomponent_type, &
811 if (
allocated(rec_cols))
deallocate (rec_cols)
812 if (.not.
associated(ks_aidt))
return
819 rec_token = trim(ks_cols(m))
823 do n = 1,
size(this%mf6_input%param_dfns)
824 if (this%mf6_input%param_dfns(n)%blockname /=
'PERIOD') cycle
825 tagname = this%mf6_input%param_dfns(n)%tagname
827 if (trim(tagname) /= trim(rec_token)) cycle
829 idt => this%mf6_input%param_dfns(n)
836 nmembers = nmembers + 1
838 member_names(nmembers) = trim(this%mf6_input%param_dfns(n)%tagname)
844 if (
allocated(ks_cols))
deallocate (ks_cols)
851 character(len=*),
intent(in) :: mf6varname
852 character(len=LENVARNAME) :: varname
854 character(len=2) :: prefix =
'IN'
855 ilen = len_trim(mf6varname)
857 varname = prefix//mf6varname(1:(
lenvarname - len(prefix)))
859 varname = prefix//trim(mf6varname)
867 integer(I4B),
intent(in) :: strlen
868 integer(I4B),
intent(in) :: nrow
869 character(len=*),
intent(in) :: varname
870 character(len=*),
intent(in) :: mempath
872 contiguous :: charstr1d
874 call mem_allocate(charstr1d, strlen, nrow, varname, mempath)
884 integer(I4B),
intent(in) :: nrow
885 character(len=*),
intent(in) :: varname
886 character(len=*),
intent(in) :: mempath
887 integer(I4B),
dimension(:),
pointer,
contiguous :: int1d
899 integer(I4B),
intent(in) :: ncol
900 integer(I4B),
intent(in) :: nrow
901 character(len=*),
intent(in) :: varname
902 character(len=*),
intent(in) :: mempath
903 integer(I4B),
dimension(:, :),
pointer,
contiguous :: int2d
917 integer(I4B),
intent(in) :: nrow
918 character(len=*),
intent(in) :: varname
919 character(len=*),
intent(in) :: mempath
920 real(DP),
dimension(:),
pointer,
contiguous :: dbl1d
932 integer(I4B),
intent(in) :: ncol
933 integer(I4B),
intent(in) :: nrow
934 character(len=*),
intent(in) :: varname
935 character(len=*),
intent(in) :: mempath
936 real(DP),
dimension(:, :),
pointer,
contiguous :: dbl2d
955 character(len=*),
dimension(:),
intent(in) :: named_bound
956 character(len=*),
intent(in) :: mempath
957 integer(I4B),
intent(inout) :: total
958 integer(I4B),
pointer :: dimptr
959 integer(I4B) :: n, isize
961 do n = 1,
size(named_bound)
962 call get_isize(trim(named_bound(n)), mempath, isize)
964 call mem_setptr(dimptr, trim(named_bound(n)), mempath)
965 total = total + dimptr
974 subroutine setval(intptr, varname, mempath)
976 integer(I4B),
pointer,
intent(inout) :: intptr
977 character(len=*),
intent(in) :: varname
978 character(len=*),
intent(in) :: mempath
979 logical(LGP) :: found
990 integer(I4B),
pointer,
intent(inout) :: intptr
991 character(len=*),
intent(in) :: varname
992 character(len=*),
intent(in) :: mempath
993 integer(I4B) :: isize
1008 contiguous,
intent(inout) :: charstr1d
1009 character(len=*),
intent(in) :: varname
1010 character(len=*),
intent(in) :: mempath
1011 integer(I4B),
intent(in) :: strlen
1012 integer(I4B) :: isize
1014 if (isize > -1)
then
1017 call mem_allocate(charstr1d, strlen, 0, varname, mempath)
1026 real(DP),
dimension(:, :),
pointer, &
1027 contiguous,
intent(inout) :: auxvar
1028 character(len=*),
intent(in) :: mempath
1029 integer(I4B) :: isize
1030 call get_isize(
'AUXVAR', mempath, isize)
1031 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 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
@ advanced
advanced keystring period block 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
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
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.