50 integer(I4B) :: blocknum
51 logical(LGP) :: deferred_shape = .false.
52 integer(I4B) :: deferred_size_init = 5
53 character(len=LENMEMPATH) :: mempath
54 character(len=LENMEMPATH) :: component_mempath
56 integer(I4B),
dimension(:),
allocatable :: startidx
57 integer(I4B),
dimension(:),
allocatable :: numcols
89 component_mempath, size_init)
result(struct_array)
91 integer(I4B),
intent(in) :: ncol
92 integer(I4B),
intent(in) :: nrow
93 integer(I4B),
intent(in) :: blocknum
94 character(len=*),
intent(in) :: mempath
95 character(len=*),
intent(in) :: component_mempath
96 integer(I4B),
optional,
intent(in) :: size_init
100 allocate (struct_array)
103 struct_array%mf6_input = mf6_input
106 struct_array%ncol = ncol
109 struct_array%nrow = nrow
110 if (struct_array%nrow == -1)
then
111 struct_array%nrow = 0
112 struct_array%deferred_shape = .true.
113 if (
present(size_init))
then
115 if (size_init >= 1) struct_array%deferred_size_init = size_init
120 if (blocknum > 0)
then
121 struct_array%blocknum = blocknum
123 struct_array%blocknum = 0
127 struct_array%mempath = mempath
128 struct_array%component_mempath = component_mempath
131 allocate (struct_array%struct_vectors(ncol))
132 allocate (struct_array%startidx(ncol))
133 allocate (struct_array%numcols(ncol))
140 deallocate (struct_array%struct_vectors)
141 deallocate (struct_array%startidx)
142 deallocate (struct_array%numcols)
143 deallocate (struct_array)
144 nullify (struct_array)
151 integer(I4B),
intent(in) :: icol
153 integer(I4B),
optional,
intent(in) :: charlen
154 character(len=*),
optional,
intent(in) :: varname
156 integer(I4B) :: numcol
162 if (
present(charlen)) sv%charlen = charlen
163 if (
present(varname)) sv%varname_override = varname
166 if (this%deferred_shape)
then
167 sv%size = this%deferred_size_init
173 select case (idt%datatype)
175 call this%allocate_int_type(sv)
177 call this%allocate_dbl_type(sv)
178 case (
'STRING',
'KEYWORD')
179 call this%allocate_charstr_type(sv)
181 call this%allocate_int1d_type(sv)
186 call this%allocate_dbl1d_type(sv)
189 errmsg =
'IDM unimplemented. StructArray::mem_create_vector &
190 &type='//trim(idt%datatype)
195 this%struct_vectors(icol) = sv
196 this%numcols(icol) = numcol
198 this%startidx(icol) = 1
200 this%startidx(icol) = this%startidx(icol - 1) + this%numcols(icol - 1)
212 integer(I4B),
intent(in) :: icol
214 integer(I4B),
intent(in) :: body_start
215 integer(I4B),
intent(in) :: head_nbody
220 sv%body_start = body_start
221 sv%head_nbody = head_nbody
225 this%struct_vectors(icol) = sv
226 this%numcols(icol) = 0
228 this%startidx(icol) = 1
230 this%startidx(icol) = this%startidx(icol - 1) + this%numcols(icol - 1)
239 character(len=LENVARNAME) :: varname
242 write (
errmsg,
'(*(G0))') &
243 'IDM mf6internal "', trim(idt%mf6varname),
'" exceeds ', &
254 integer(I4B) ::
count
255 count =
size(this%struct_vectors)
264 function get(this, idx)
result(sv)
266 integer(I4B),
intent(in) :: idx
276 integer(I4B),
dimension(:),
pointer,
contiguous :: int1d
277 integer(I4B) :: j, nrow
279 if (this%deferred_shape)
then
281 nrow = this%deferred_size_init
282 allocate (int1d(this%deferred_size_init))
286 call mem_allocate(int1d, this%nrow, sv%idt%mf6varname, this%mempath)
303 real(DP),
dimension(:),
pointer,
contiguous :: dbl1d
304 character(len=LENVARNAME) :: varname
305 integer(I4B) :: j, nrow
307 varname = sv%idt%mf6varname
308 if (len_trim(sv%varname_override) > 0) varname = sv%varname_override
310 if (this%deferred_shape)
then
312 nrow = this%deferred_size_init
313 allocate (dbl1d(this%deferred_size_init))
317 call mem_allocate(dbl1d, this%nrow, varname, this%mempath)
335 integer(I4B) :: j, nrow
337 if (this%deferred_shape)
then
339 nrow = this%deferred_size_init
340 allocate (charstr1d(this%deferred_size_init))
345 sv%idt%mf6varname, this%mempath)
353 sv%charstr1d => charstr1d
364 integer(I4B),
dimension(:, :),
pointer,
contiguous :: int2d
367 integer(I4B),
pointer :: ncelldim, exgid
368 character(len=LENMEMPATH) :: input_mempath
369 character(len=LENMODELNAME) :: mname
372 integer(I4B) :: nrow, n, m
374 if (sv%idt%shape ==
'NCELLDIM')
then
376 if (this%mf6_input%component_type ==
'EXG')
then
378 call mem_setptr(exgid,
'EXGID', this%mf6_input%mempath)
381 if (sv%idt%tagname ==
'CELLIDM1')
then
382 call mem_setptr(charstr1d,
'EXGMNAMEA', input_mempath)
383 else if (sv%idt%tagname ==
'CELLIDM2')
then
384 call mem_setptr(charstr1d,
'EXGMNAMEB', input_mempath)
388 mname = charstr1d(exgid)
392 call mem_setptr(ncelldim, sv%idt%shape, input_mempath)
394 call mem_setptr(ncelldim, sv%idt%shape, this%component_mempath)
397 if (this%deferred_shape)
then
399 nrow = this%deferred_size_init
400 allocate (int2d(ncelldim, this%deferred_size_init))
405 sv%idt%mf6varname, this%mempath)
417 sv%intshape => ncelldim
422 call intvector%init()
424 sv%intvector => intvector
427 allocate (intvector_ia)
428 call intvector_ia%init()
429 call intvector_ia%push_back(1)
430 sv%intvector_ia => intvector_ia
431 if (trim(sv%idt%shape) ==
':')
then
434 sv%intvector_ragged = .true.
437 call mem_setptr(sv%intvector_shape, sv%idt%shape, this%mempath)
448 real(DP),
dimension(:, :),
pointer,
contiguous :: dbl2d
449 integer(I4B),
pointer :: naux, nseg, nseg_1
450 integer(I4B) :: nseg1_isize, n, m
452 if (sv%idt%shape ==
'NAUX')
then
453 call mem_setptr(naux, sv%idt%shape, this%mempath)
455 if (this%deferred_shape)
then
457 allocate (dbl2d(naux, sv%size))
459 call mem_allocate(dbl2d, naux, this%nrow, sv%idt%mf6varname, this%mempath)
472 else if (sv%idt%shape ==
'NSEG-1')
then
474 call get_isize(
'NSEG_1', this%mempath, nseg1_isize)
476 if (nseg1_isize < 0)
then
480 call mem_setptr(nseg_1,
'NSEG_1', this%mempath)
483 if (this%deferred_shape)
then
485 allocate (dbl2d(nseg_1, sv%size))
487 call mem_allocate(dbl2d, nseg_1, sv%size, sv%idt%mf6varname, this%mempath)
499 sv%intshape => nseg_1
501 errmsg =
'IDM unimplemented. StructArray::allocate_dbl1d_type &
502 & unsupported shape "'//trim(sv%idt%shape)//
'".'
510 integer(I4B),
intent(in) :: icol
511 integer(I4B) :: i, j, isize
512 integer(I4B),
dimension(:),
pointer,
contiguous :: p_int1d
513 integer(I4B),
dimension(:, :),
pointer,
contiguous :: p_int2d
514 real(DP),
dimension(:),
pointer,
contiguous :: p_dbl1d
515 real(DP),
dimension(:, :),
pointer,
contiguous :: p_dbl2d
517 character(len=LENVARNAME) :: varname
518 logical(LGP) :: overwrite
521 if (this%struct_vectors(icol)%idt%blockname ==
'SOLUTIONGROUP') &
525 varname = this%struct_vectors(icol)%idt%mf6varname
527 call get_isize(varname, this%mempath, isize)
530 select case (this%struct_vectors(icol)%memtype)
534 call mem_setptr(p_int1d, varname, this%mempath)
538 if (this%nrow > isize)
then
545 p_int1d(i) = this%struct_vectors(icol)%int1d(i)
548 if (isize > this%nrow)
then
550 do i = this%nrow + 1, isize
556 call mem_reallocate(p_int1d, this%nrow + isize, varname, this%mempath)
560 p_int1d(isize + i) = this%struct_vectors(icol)%int1d(i)
565 call mem_allocate(p_int1d, this%nrow, varname, this%mempath)
569 p_int1d(i) = this%struct_vectors(icol)%int1d(i)
574 deallocate (this%struct_vectors(icol)%int1d)
577 this%struct_vectors(icol)%int1d => p_int1d
578 this%struct_vectors(icol)%size = this%nrow
581 call mem_setptr(p_dbl1d, varname, this%mempath)
584 if (this%nrow > isize)
then
589 p_dbl1d(i) = this%struct_vectors(icol)%dbl1d(i)
592 if (isize > this%nrow)
then
593 do i = this%nrow + 1, isize
601 p_dbl1d(isize + i) = this%struct_vectors(icol)%dbl1d(i)
605 call mem_allocate(p_dbl1d, this%nrow, varname, this%mempath)
608 p_dbl1d(i) = this%struct_vectors(icol)%dbl1d(i)
612 deallocate (this%struct_vectors(icol)%dbl1d)
614 this%struct_vectors(icol)%dbl1d => p_dbl1d
615 this%struct_vectors(icol)%size = this%nrow
619 call mem_setptr(p_charstr1d, varname, this%mempath)
622 if (this%nrow > isize)
then
623 call mem_reallocate(p_charstr1d, this%struct_vectors(icol)%charlen, &
624 this%nrow, varname, this%mempath)
628 p_charstr1d(i) = this%struct_vectors(icol)%charstr1d(i)
631 if (isize > this%nrow)
then
632 do i = this%nrow + 1, isize
637 call mem_reallocate(p_charstr1d, this%struct_vectors(icol)%charlen, &
638 this%nrow + isize, varname, this%mempath)
640 p_charstr1d(isize + i) = this%struct_vectors(icol)%charstr1d(i)
644 call mem_allocate(p_charstr1d, this%struct_vectors(icol)%charlen, &
645 this%nrow, varname, this%mempath)
647 p_charstr1d(i) = this%struct_vectors(icol)%charstr1d(i)
648 call this%struct_vectors(icol)%charstr1d(i)%destroy()
652 deallocate (this%struct_vectors(icol)%charstr1d)
654 this%struct_vectors(icol)%charstr1d => p_charstr1d
655 this%struct_vectors(icol)%size = this%nrow
657 errmsg =
'StructArray::load_deferred_vector &
658 &intvector reallocate unimplemented.'
662 errmsg =
'StructArray::load_deferred_vector &
663 &int2d reallocate unimplemented.'
666 call mem_allocate(p_int2d, this%struct_vectors(icol)%intshape, &
667 this%nrow, varname, this%mempath)
669 do j = 1, this%struct_vectors(icol)%intshape
670 p_int2d(j, i) = this%struct_vectors(icol)%int2d(j, i)
675 deallocate (this%struct_vectors(icol)%int2d)
677 this%struct_vectors(icol)%int2d => p_int2d
678 this%struct_vectors(icol)%size = this%nrow
681 errmsg =
'StructArray::load_deferred_vector &
682 &dbl2d reallocate unimplemented.'
685 call mem_allocate(p_dbl2d, this%struct_vectors(icol)%intshape, &
686 this%nrow, varname, this%mempath)
688 do j = 1, this%struct_vectors(icol)%intshape
689 p_dbl2d(j, i) = this%struct_vectors(icol)%dbl2d(j, i)
694 deallocate (this%struct_vectors(icol)%dbl2d)
696 this%struct_vectors(icol)%dbl2d => p_dbl2d
697 this%struct_vectors(icol)%size = this%nrow
706 integer(I4B) :: icol, j
707 integer(I4B),
dimension(:),
pointer,
contiguous :: p_intvector
708 integer(I4B),
dimension(:),
pointer,
contiguous :: p_intvector_ia
709 character(len=LENVARNAME) :: varname
711 do icol = 1, this%ncol
713 varname = this%struct_vectors(icol)%idt%mf6varname
715 if (this%struct_vectors(icol)%memtype ==
mtype_intvec)
then
718 call this%struct_vectors(icol)%intvector%shrink_to_fit()
722 this%struct_vectors(icol)%intvector%size, &
723 varname, this%mempath)
726 do j = 1, this%struct_vectors(icol)%intvector%size
727 p_intvector(j) = this%struct_vectors(icol)%intvector%at(j)
731 call this%struct_vectors(icol)%intvector%destroy()
732 deallocate (this%struct_vectors(icol)%intvector)
733 nullify (this%struct_vectors(icol)%intvector_shape)
737 this%struct_vectors(icol)%intvector_ia%size, &
738 trim(varname)//
'_IA', this%mempath)
739 do j = 1, this%struct_vectors(icol)%intvector_ia%size
740 p_intvector_ia(j) = this%struct_vectors(icol)%intvector_ia%at(j)
742 call this%struct_vectors(icol)%intvector_ia%destroy()
743 deallocate (this%struct_vectors(icol)%intvector_ia)
744 nullify (this%struct_vectors(icol)%intvector_ia)
745 else if (this%deferred_shape)
then
747 call this%load_deferred_vector(icol)
756 integer(I4B),
intent(in) :: iout
757 integer(I4B) :: j, nts
758 integer(I4B),
dimension(:),
pointer,
contiguous :: int1d
759 character(len=LINELENGTH) :: ts_count_str
764 select case (this%struct_vectors(j)%memtype)
767 this%struct_vectors(j)%idt%tagname, &
770 nts = this%struct_vectors(j)%ts_strlocs%count()
772 write (ts_count_str,
'(i0, " time-series bound entries")') nts
773 call idm_log_var(this%struct_vectors(j)%idt%tagname, &
774 this%mempath, iout, .false., trim(ts_count_str))
777 this%struct_vectors(j)%idt%tagname, &
781 call mem_setptr(int1d, this%struct_vectors(j)%idt%mf6varname, &
783 call idm_log_var(int1d, this%struct_vectors(j)%idt%tagname, &
787 this%struct_vectors(j)%idt%tagname, &
790 nts = this%struct_vectors(j)%ts_strlocs%count()
792 write (ts_count_str,
'(i0, " time-series bound entries")') nts
793 call idm_log_var(this%struct_vectors(j)%idt%tagname, &
794 this%mempath, iout, .false., trim(ts_count_str))
797 this%struct_vectors(j)%idt%tagname, &
808 integer(I4B) :: i, j, k, newsize
809 integer(I4B),
dimension(:),
pointer,
contiguous :: p_int1d
810 integer(I4B),
dimension(:, :),
pointer,
contiguous :: p_int2d
811 real(DP),
dimension(:),
pointer,
contiguous :: p_dbl1d
812 real(DP),
dimension(:, :),
pointer,
contiguous :: p_dbl2d
814 integer(I4B) :: reallocate_mult
821 select case (this%struct_vectors(j)%memtype)
824 if (this%nrow > this%struct_vectors(j)%size)
then
826 newsize = this%struct_vectors(j)%size * reallocate_mult
828 allocate (p_int1d(newsize))
831 do i = 1, this%struct_vectors(j)%size
832 p_int1d(i) = this%struct_vectors(j)%int1d(i)
836 deallocate (this%struct_vectors(j)%int1d)
839 this%struct_vectors(j)%int1d => p_int1d
840 this%struct_vectors(j)%size = newsize
843 if (this%nrow > this%struct_vectors(j)%size)
then
844 newsize = this%struct_vectors(j)%size * reallocate_mult
845 allocate (p_dbl1d(newsize))
847 do i = 1, this%struct_vectors(j)%size
848 p_dbl1d(i) = this%struct_vectors(j)%dbl1d(i)
851 deallocate (this%struct_vectors(j)%dbl1d)
853 this%struct_vectors(j)%dbl1d => p_dbl1d
854 this%struct_vectors(j)%size = newsize
858 if (this%nrow > this%struct_vectors(j)%size)
then
859 newsize = this%struct_vectors(j)%size * reallocate_mult
860 allocate (p_charstr1d(newsize))
862 do i = 1, this%struct_vectors(j)%size
863 p_charstr1d(i) = this%struct_vectors(j)%charstr1d(i)
864 call this%struct_vectors(j)%charstr1d(i)%destroy()
867 deallocate (this%struct_vectors(j)%charstr1d)
869 this%struct_vectors(j)%charstr1d => p_charstr1d
870 this%struct_vectors(j)%size = newsize
873 if (this%nrow > this%struct_vectors(j)%size)
then
874 newsize = this%struct_vectors(j)%size * reallocate_mult
875 allocate (p_int2d(this%struct_vectors(j)%intshape, newsize))
877 do i = 1, this%struct_vectors(j)%size
878 do k = 1, this%struct_vectors(j)%intshape
879 p_int2d(k, i) = this%struct_vectors(j)%int2d(k, i)
883 deallocate (this%struct_vectors(j)%int2d)
885 this%struct_vectors(j)%int2d => p_int2d
886 this%struct_vectors(j)%size = newsize
889 if (this%nrow > this%struct_vectors(j)%size)
then
890 newsize = this%struct_vectors(j)%size * reallocate_mult
891 allocate (p_dbl2d(this%struct_vectors(j)%intshape, newsize))
893 do i = 1, this%struct_vectors(j)%size
894 do k = 1, this%struct_vectors(j)%intshape
895 p_dbl2d(k, i) = this%struct_vectors(j)%dbl2d(k, i)
899 deallocate (this%struct_vectors(j)%dbl2d)
901 this%struct_vectors(j)%dbl2d => p_dbl2d
902 this%struct_vectors(j)%size = newsize
907 errmsg =
'IDM unimplemented. StructArray::check_reallocate &
908 &unsupported memtype.'
914 subroutine read_param(this, parser, sv_col, irow, timeseries, iout)
918 integer(I4B),
intent(in) :: sv_col
919 integer(I4B),
intent(in) :: irow
920 logical(LGP),
intent(in) :: timeseries
921 integer(I4B),
intent(in) :: iout
922 integer(I4B) :: n, intval, numval, icol
923 character(len=LINELENGTH) :: str
924 character(len=:),
allocatable :: line
925 logical(LGP) :: preserve_case, success
927 select case (this%struct_vectors(sv_col)%memtype)
930 write (
errmsg,
'(a,i0)') &
931 'IDM read_param called for MTYPE_UNDEF metadata vector at column ', sv_col
935 if (sv_col == 1 .and. this%blocknum > 0)
then
937 this%struct_vectors(sv_col)%int1d(irow) = this%blocknum
940 this%struct_vectors(sv_col)%int1d(irow) = parser%GetInteger()
943 if (this%struct_vectors(sv_col)%idt%timeseries .and. timeseries)
then
944 call parser%GetString(str)
945 this%struct_vectors(sv_col)%dbl1d(irow) = &
946 this%struct_vectors(sv_col)%read_token(str, this%startidx(sv_col), &
948 else if (sv_col == this%ncol .and. &
949 .not. this%struct_vectors(sv_col)%idt%required)
then
950 call parser%TryGetDouble(this%struct_vectors(sv_col)%dbl1d(irow), success)
952 this%struct_vectors(sv_col)%dbl1d(irow) =
dnodata
954 this%struct_vectors(sv_col)%dbl1d(irow) = parser%GetDouble()
957 if (this%struct_vectors(sv_col)%idt%shape /=
'' .and. &
958 sv_col == this%ncol)
then
960 call parser%GetRemainingLine(line)
961 this%struct_vectors(sv_col)%charstr1d(irow) = line
966 preserve_case = (.not. this%struct_vectors(sv_col)%idt%preserve_case)
967 call parser%GetString(str, preserve_case)
968 this%struct_vectors(sv_col)%charstr1d(irow) = str
971 if (this%struct_vectors(sv_col)%intvector_ragged)
then
977 call parser%TryGetInteger(intval, success)
979 call this%struct_vectors(sv_col)%intvector%push_back(intval)
985 numval = this%struct_vectors(sv_col)%intvector_shape(irow)
988 intval = parser%GetInteger()
989 call this%struct_vectors(sv_col)%intvector%push_back(intval)
993 call this%struct_vectors(sv_col)%intvector_ia%push_back( &
994 this%struct_vectors(sv_col)%intvector_ia%at( &
995 this%struct_vectors(sv_col)%intvector_ia%size) + numval)
999 if (trim(this%mf6_input%subcomponent_type) ==
'SFR' .and. &
1000 this%struct_vectors(sv_col)%idt%tagname ==
'CELLID')
then
1001 call parser%GetString(str)
1003 if (str ==
'NONE')
then
1005 do n = 1, this%struct_vectors(sv_col)%intshape
1006 this%struct_vectors(sv_col)%int2d(n, irow) = 0
1010 read (str, *, iostat=numval) intval
1011 if (numval /= 0)
then
1012 write (
errmsg,
'(a,a,a)') &
1013 'CELLID must be an integer or the keyword NONE, got: ', &
1017 this%struct_vectors(sv_col)%int2d(1, irow) = intval
1018 do n = 2, this%struct_vectors(sv_col)%intshape
1019 this%struct_vectors(sv_col)%int2d(n, irow) = parser%GetInteger()
1023 do n = 1, this%struct_vectors(sv_col)%intshape
1024 this%struct_vectors(sv_col)%int2d(n, irow) = parser%GetInteger()
1029 do n = 1, this%struct_vectors(sv_col)%intshape
1030 if (this%struct_vectors(sv_col)%idt%timeseries .and. timeseries)
then
1031 call parser%GetString(str)
1032 icol = this%startidx(sv_col) + n - 1
1033 this%struct_vectors(sv_col)%dbl2d(n, irow) = &
1034 this%struct_vectors(sv_col)%read_token(str, icol, n, irow)
1036 this%struct_vectors(sv_col)%dbl2d(n, irow) = parser%GetDouble()
1049 res = (trim(idt%tagname) ==
'AUXVAL')
1055 character(len=*),
intent(in) :: auxname
1057 integer(I4B),
intent(in) :: naux
1059 character(len=LINELENGTH) :: thisauxname
1064 thisauxname = auxnames(n)
1065 if (trim(auxname) == trim(thisauxname))
then
1078 logical(LGP),
intent(in) :: timeseries
1079 integer(I4B),
intent(in) :: iout
1080 character(len=*),
intent(in) :: input_name
1081 integer(I4B) :: irow, j
1082 logical(LGP) :: endofblock
1088 if (this%deferred_shape)
then
1095 call parser%GetNextLine(endofblock)
1096 if (endofblock)
then
1099 else if (this%deferred_shape)
then
1101 this%nrow = this%nrow + 1
1103 call this%check_reallocate()
1107 if (this%deferred_shape)
then
1110 if (irow > this%nrow)
then
1111 write (
errmsg,
'(a,i0,a)') &
1112 'Input error: line count exceeds input dimension. Expected rows=', &
1120 call this%read_param(parser, j, irow, timeseries, iout)
1124 call this%memload_vectors()
1127 call this%log_structarray_vars(iout)
1153 iout, input_name)
result(irow)
1158 logical(LGP),
intent(in) :: timeseries
1159 integer(I4B),
intent(in) :: nleading
1160 integer(I4B),
intent(in) :: iout
1161 character(len=*),
intent(in) :: input_name
1162 integer(I4B) :: irow
1163 logical(LGP) :: endofblock, is_keyword_dispatch
1164 character(len=LINELENGTH) :: keyword
1165 integer(I4B) :: icol, found_col, last_set_col, setting_icol
1171 if (nleading + 1 <= this%ncol)
then
1172 if (trim(this%struct_vectors(nleading + 1)%idt%tagname) ==
'SETTING')
then
1173 setting_icol = nleading + 1
1178 if (this%deferred_shape)
then
1183 call parser%GetNextLine(endofblock)
1184 if (endofblock)
exit
1186 if (this%deferred_shape)
then
1187 this%nrow = this%nrow + 1
1188 call this%check_reallocate()
1193 if (.not. this%deferred_shape)
then
1194 if (irow > this%nrow)
then
1195 write (
errmsg,
'(a,i0,a)') &
1196 'Input error: keystring row count exceeds pre-allocated maxbound=', &
1205 do icol = 1, nleading
1206 call this%read_param(parser, icol, irow, .false., iout)
1210 call parser%GetString(keyword)
1217 do while (icol <= this%ncol)
1218 if (icol == setting_icol)
then
1222 if (trim(this%struct_vectors(icol)%idt%tagname) == trim(keyword))
then
1226 if (this%struct_vectors(icol)%head_nbody > 0)
then
1227 icol = icol + this%struct_vectors(icol)%head_nbody + 1
1233 if (found_col < 1)
then
1234 write (
errmsg,
'(a,a,a)') &
1235 'Unrecognized keystring keyword "', trim(keyword), &
1236 '" in PERIOD block.'
1244 if (setting_icol > 0)
then
1245 this%struct_vectors(setting_icol)%charstr1d(irow) = &
1246 trim(this%struct_vectors(found_col)%idt%mf6varname)
1250 is_keyword_dispatch = &
1251 (this%struct_vectors(found_col)%idt%datatype ==
'KEYWORD')
1253 if (is_keyword_dispatch)
then
1256 last_set_col = found_col
1257 if (this%struct_vectors(found_col)%body_start > 0)
then
1258 do icol = this%struct_vectors(found_col)%body_start, &
1259 this%struct_vectors(found_col)%body_start + &
1260 this%struct_vectors(found_col)%head_nbody - 1
1261 if (icol > this%ncol)
exit
1262 call this%read_param(parser, icol, irow, timeseries, iout)
1268 call this%read_param(parser, found_col, irow, timeseries, iout)
1269 last_set_col = found_col
1273 do icol = nleading + 1, this%ncol
1275 if (icol == setting_icol) cycle
1277 if (this%struct_vectors(icol)%memtype ==
mtype_undef) cycle
1278 if (icol >= found_col .and. icol <= last_set_col) cycle
1279 select case (this%struct_vectors(icol)%memtype)
1281 this%struct_vectors(icol)%int1d(irow) =
izero
1283 this%struct_vectors(icol)%dbl1d(irow) =
dnodata
1285 this%struct_vectors(icol)%charstr1d(irow) =
''
1290 call this%memload_vectors()
1293 call this%log_structarray_vars(iout)
1301 integer(I4B),
intent(in) :: inunit
1302 integer(I4B),
intent(in) :: iout
1303 integer(I4B) :: irow, ierr
1304 integer(I4B) :: j, k
1305 integer(I4B) :: intval, numval
1306 character(len=LINELENGTH) :: fname
1307 character(len=*),
parameter :: fmtlsterronly = &
1308 "('Error reading LIST from file: ',&
1309 &1x,a,1x,' on UNIT: ',I0)"
1312 if (this%deferred_shape)
then
1313 errmsg =
'IDM unimplemented. StructArray::read_from_binary deferred shape &
1314 ¬ supported for binary inputs.'
1325 select case (this%struct_vectors(j)%memtype)
1327 read (inunit, iostat=ierr) this%struct_vectors(j)%int1d(irow)
1329 read (inunit, iostat=ierr) this%struct_vectors(j)%dbl1d(irow)
1331 errmsg =
'List style binary inputs not supported &
1332 &for text columns, tag='// &
1333 trim(this%struct_vectors(j)%idt%tagname)//
'.'
1336 if (this%struct_vectors(j)%intvector_ragged)
then
1337 errmsg =
'List style binary inputs not supported for &
1338 &self-sizing (ragged) columns, tag='// &
1339 trim(this%struct_vectors(j)%idt%tagname)//
'.'
1343 numval = this%struct_vectors(j)%intvector_shape(irow)
1347 read (inunit, iostat=ierr) intval
1348 call this%struct_vectors(j)%intvector%push_back(intval)
1353 do k = 1, this%struct_vectors(j)%intshape
1355 read (inunit, iostat=ierr) this%struct_vectors(j)%int2d(k, irow)
1359 do k = 1, this%struct_vectors(j)%intshape
1361 read (inunit, iostat=ierr) this%struct_vectors(j)%dbl2d(k, irow)
1376 inquire (unit=inunit, name=fname)
1377 write (
errmsg, fmtlsterronly) trim(adjustl(fname)), inunit
1382 if (irow == this%nrow)
exit readloop
1391 call this%memload_vectors()
1395 call this%log_structarray_vars(iout)
1407 subroutine ts_update(this, tsmanager, subcomp_name, iprpak, input_name, &
1408 auxname_cst, clear_strlocs, ifno_map)
1411 character(len=*),
intent(in) :: subcomp_name
1412 integer(I4B),
intent(in) :: iprpak
1413 character(len=*),
intent(in) :: input_name
1415 optional :: auxname_cst
1416 logical(LGP),
optional,
intent(in) :: clear_strlocs
1417 integer(I4B),
dimension(:),
optional,
intent(in) :: ifno_map
1420 real(DP),
pointer :: bndElem
1421 character(len=LENBOUNDNAME) :: boundname
1422 integer(I4B) :: m, n, iboundname, irow
1423 logical(LGP) :: do_clear
1426 if (
present(clear_strlocs)) do_clear = clear_strlocs
1431 if (this%struct_vectors(m)%idt%mf6varname ==
'BOUNDNAME')
then
1438 if (.not. this%struct_vectors(m)%idt%timeseries) cycle
1439 do n = 1, this%struct_vectors(m)%ts_strlocs%count()
1440 ts_strloc => this%struct_vectors(m)%get_ts_strloc(n)
1442 irow = ts_strloc%row
1443 if (
present(ifno_map)) irow = ifno_map(ts_strloc%row)
1444 select case (this%struct_vectors(m)%memtype)
1446 bndelem => this%struct_vectors(m)%dbl1d(ts_strloc%row)
1451 subcomp_name,
'BND', tsmanager, &
1453 if (
associated(tslink))
then
1454 tslink%Text = this%struct_vectors(m)%idt%mf6varname
1455 if (iboundname > 0)
then
1457 this%struct_vectors(iboundname)%charstr1d(ts_strloc%row)
1458 tslink%BndName = boundname
1462 if (.not.
present(auxname_cst)) cycle
1463 if (.not.
associated(auxname_cst)) cycle
1464 bndelem => this%struct_vectors(m)%dbl2d(ts_strloc%col, ts_strloc%row)
1468 ts_strloc%col, bndelem, &
1469 subcomp_name,
'AUX', tsmanager, &
1471 if (
associated(tslink))
then
1472 tslink%Text = auxname_cst(ts_strloc%col)
1473 if (iboundname > 0)
then
1475 this%struct_vectors(iboundname)%charstr1d(ts_strloc%row)
1476 tslink%BndName = boundname
1481 if (do_clear)
call this%struct_vectors(m)%clear()
1495 nrows, addr_map, category, names, featarr2d, &
1498 integer(I4B),
intent(in) :: icol
1500 character(len=*),
intent(in) :: subcomp_name
1501 character(len=*),
intent(in) :: category
1502 integer(I4B),
intent(in) :: iprpak
1503 integer(I4B),
intent(in) :: nrows
1504 integer(I4B),
dimension(:),
intent(in) :: addr_map
1505 character(len=LENVARNAME),
dimension(:),
intent(in) :: names
1506 real(DP),
dimension(:, :),
pointer,
intent(in) :: featarr2d
1507 real(DP),
dimension(:, :),
pointer,
intent(in) :: raw2d
1509 real(DP),
pointer :: bndElem
1510 logical(LGP) :: found
1511 integer(I4B) :: n, j, k, nts, i, naux
1512 logical(LGP),
dimension(:, :),
allocatable :: handled2
1515 allocate (handled2(naux, nrows))
1519 nts = this%struct_vectors(icol)%ts_strlocs%count()
1521 ts_strloc => this%struct_vectors(icol)%get_ts_strloc(k)
1522 i = addr_map(ts_strloc%row)
1523 if (i < 1 .or. i >
size(featarr2d, 2)) cycle
1524 bndelem => featarr2d(ts_strloc%col, i)
1526 ts_strloc%token, i, ts_strloc%col, bndelem, subcomp_name, &
1527 category, tsmanager, iprpak, trim(names(ts_strloc%col)))
1528 handled2(ts_strloc%col, ts_strloc%row) = .true.
1535 if (i < 1 .or. i >
size(featarr2d, 2)) cycle
1537 if (handled2(j, n)) cycle
1538 if (raw2d(j, n) ==
dnodata) cycle
1540 category, trim(names(j)))
1541 featarr2d(j, i) = raw2d(j, n)
1544 deallocate (handled2)
1548 call this%struct_vectors(icol)%clear()
1555 nrows, ifno_map, auxname_cst, featarr2d)
1557 integer(I4B),
intent(in) :: icol
1559 character(len=*),
intent(in) :: subcomp_name
1560 integer(I4B),
intent(in) :: iprpak
1561 integer(I4B),
intent(in) :: nrows
1562 integer(I4B),
dimension(:),
intent(in) :: ifno_map
1564 real(DP),
dimension(:, :),
pointer,
intent(in) :: featarr2d
1565 character(len=LENVARNAME) :: names(size(auxname_cst))
1568 do j = 1,
size(auxname_cst)
1569 names(j) = auxname_cst(j)
1571 call this%ts_update_dedup(icol, tsmanager, subcomp_name, iprpak, &
1572 nrows, ifno_map,
'AUX', names, featarr2d, &
1573 this%struct_vectors(icol)%dbl2d)
1582 iprpak, nrows, row_addr, varname, featarr)
1584 integer(I4B),
intent(in) :: icol
1586 character(len=*),
intent(in) :: subcomp_name
1587 integer(I4B),
intent(in) :: iprpak
1588 integer(I4B),
intent(in) :: nrows
1589 integer(I4B),
dimension(:),
intent(in) :: row_addr
1590 character(len=*),
intent(in) :: varname
1591 real(DP),
dimension(:),
pointer,
contiguous,
intent(in) :: featarr
1592 real(DP),
dimension(:, :),
pointer :: featarr2d, raw2d
1593 character(len=LENVARNAME) :: names(1)
1596 featarr2d(1:1, 1:
size(featarr)) => featarr
1597 raw2d(1:1, 1:nrows) => this%struct_vectors(icol)%dbl1d(1:nrows)
1599 call this%ts_update_dedup(icol, tsmanager, subcomp_name, iprpak, &
1600 nrows, row_addr,
'BND', names, featarr2d, &
This module contains block parser methods.
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lenmodelname
maximum length of the model name
real(dp), parameter dnodata
real no data constant
character(len= *), parameter idm_input_suffix
input array suffix applied when data array shares name
integer(i4b), parameter lenvarname
maximum length of a variable name
integer(i4b), parameter lenboundname
maximum length of a bound name
integer(i4b), parameter izero
integer constant zero
real(dp), parameter dzero
real constant zero
integer(i4b), parameter lenmempath
maximum length of the memory path
This module contains the Input Data Model Logger Module.
This module defines variable data types.
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
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.
integer(i4b) function, public count_errors()
Return number of errors.
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=linelength) idm_context
This module contains the StructArrayModule.
integer(i4b) function count(this)
character(len=lenvarname) function, public idm_input_varname(idt)
Derive a TS-capable setting's raw input array name, distinct from its persistent array (allocated und...
integer(i4b) function read_from_binary(this, inunit, iout)
read from binary input to fill the StructArrayType
subroutine memload_vectors(this)
load deferred vectors into managed memory
integer(i4b) function read_from_parser_keystring(this, parser, timeseries, nleading, iout, input_name)
read keystring period block into the StructArrayType
subroutine set_pointer(sv, sv_target)
logical(lgp) function, public is_auxval(idt)
True if idt is AUXVAL: its AUX index is resolved dynamically from a sibling AUXNAME,...
subroutine allocate_dbl1d_type(this, sv)
allocate dbl1d input type
subroutine ts_update_dedup(this, icol, tsmanager, subcomp_name, iprpak, nrows, addr_map, category, names, featarr2d, raw2d)
Shared dedup-aware TS resolution for one PERIOD-block column: TS-linked rows resolve via their preser...
subroutine mem_create_metadata_vector(this, icol, idt, body_start, head_nbody)
Create a metadata-only StructVector for a KEYWORD indicator column.
subroutine check_reallocate(this)
reallocate local memory for deferred vectors if necessary
integer(i4b) function, public find_auxname_index(auxname, auxnames, naux)
Find the AUX array position matching auxname, 0 if none.
subroutine ts_update_adv(this, icol, tsmanager, subcomp_name, iprpak, nrows, ifno_map, auxname_cst, featarr2d)
Dedup-aware counterpart to ts_update for one MTYPE_DBL2D (AUX) PERIOD-block column.
subroutine load_deferred_vector(this, icol)
subroutine allocate_dbl_type(this, sv)
allocate double input type
subroutine allocate_charstr_type(this, sv)
allocate charstr input type
subroutine ts_update_indexed(this, icol, tsmanager, subcomp_name, iprpak, nrows, row_addr, varname, featarr)
Dedup-aware resolution of one MTYPE_DBL PERIOD-block column into its permanent array,...
subroutine mem_create_vector(this, icol, idt, charlen, varname)
create new vector in StructArrayType
integer(i4b) function read_from_parser(this, parser, timeseries, iout, input_name)
read from the block parser to fill the StructArrayType
subroutine allocate_int_type(this, sv)
allocate integer input type
subroutine ts_update(this, tsmanager, subcomp_name, iprpak, input_name, auxname_cst, clear_strlocs, ifno_map)
link time-series strings in this struct array to a tsmanager
subroutine log_structarray_vars(this, iout)
log information about the StructArrayType
subroutine read_param(this, parser, sv_col, irow, timeseries, iout)
subroutine, public destructstructarray(struct_array)
destructor for a struct_array
subroutine allocate_int1d_type(this, sv)
allocate int1d input type
type(structvectortype) function, pointer get(this, idx)
type(structarraytype) function, pointer, public constructstructarray(mf6_input, ncol, nrow, blocknum, mempath, component_mempath, size_init)
constructor for a struct_array
This module contains the StructVectorModule.
@, public mtype_intvec
intvector column
@, public mtype_dbl
dbl1d column
@, public mtype_int2d
int2d (NCELLDIM) column
@, public mtype_int
int1d column
@, public mtype_dbl2d
dbl2d (NAUX/NSEG) column
@, public mtype_str
charstr1d column
@, public mtype_undef
undefined memtype
subroutine, public read_value_or_time_series_adv(textInput, ii, jj, bndElem, pkgName, auxOrBnd, tsManager, iprpak, varName)
Call this subroutine from advanced packages to define timeseries link for a variable (varName).
logical function, public remove_existing_link(tsManager, ii, jj, pkgName, auxOrBnd, varName)
Remove an existing timeseries link if it is defined.
subroutine, public read_value_or_time_series(textInput, ii, jj, bndElem, pkgName, auxOrBnd, tsManager, iprpak, tsLink)
Call this subroutine if the time-series link is available or needed.
This class is used to store a single deferred-length character string. It was designed to work in an ...
type for structured array
derived type for generic vector
derived type which describes time series string field