67 integer(I4B),
intent(in) :: iu, iout
68 integer(I4B),
intent(in) :: jj
69 integer(I4B),
dimension(jj),
intent(inout) :: iarr
70 character(len=*),
intent(in) :: aname
71 integer(I4B),
intent(in) :: ndim
72 integer(I4B),
intent(in) :: k
75 integer(I4B) :: iclose, iconst, iprn, j, locat, ncpl, ndig
76 integer(I4B) :: nval, nvalt
78 character(len=100) :: prfmt
80 character(len=30) :: arrname
81 character(len=MAXCHARLEN) :: ermsgr
83 2
format(/, 1x, a,
' = ', i0,
' FOR LAYER ', i0)
84 3
format(/, 1x, a,
' = ', i0)
97 write (iout, 2) trim(aname), iconst, k
99 write (iout, 3) trim(aname), iconst
102 elseif (locat > 0)
then
104 read (locat, *, iostat=istat, iomsg=ermsgr) (iarr(j), j=1, jj)
106 arrname = adjustl(aname)
107 errmsg =
"Error reading data for array '"//trim(arrname)// &
108 "'. "//trim(adjustl(ermsgr))
113 iarr(j) = iarr(j) * iconst
115 if (iclose == 1)
then
125 if (isok .EQV. .false.)
exit
126 read (locat, iostat=istat, iomsg=ermsgr) &
127 (iarr(j), j=nvalt + 1, nvalt + nval)
129 arrname = adjustl(aname)
130 errmsg =
"Error reading data for array '"//trim(arrname)// &
131 "'. "//trim(adjustl(ermsgr))
136 if (nvalt ==
size(iarr))
exit
141 iarr(j) = iarr(j) * iconst
145 if (iclose == 1)
then
151 if (iprn >= 0 .and. locat /= 0)
then
152 prowcolnum = (ndim == 3)
161 integer(I4B),
intent(in) :: iu, iout
162 integer(I4B),
intent(in) :: jj, ii
163 integer(I4B),
dimension(jj, ii),
intent(inout) :: iarr
164 character(len=*),
intent(in) :: aname
165 integer(I4B),
intent(in) :: ndim
166 integer(I4B),
intent(in) :: k
169 integer(I4B) :: i, iclose, iconst, iprn, j, locat, ncpl, ndig
171 logical :: prowcolnum
172 character(len=100) :: prfmt
173 integer(I4B) :: istat
174 character(len=30) :: arrname
175 character(len=MAXCHARLEN) :: ermsgr
177 2
format(/, 1x, a,
' = ', i0,
' FOR LAYER ', i0)
178 3
format(/, 1x, a,
' = ', i0)
193 write (iout, 2) trim(aname), iconst, k
195 write (iout, 3) trim(aname), iconst
198 elseif (locat > 0)
then
201 read (locat, *, iostat=istat, iomsg=ermsgr) (iarr(j, i), j=1, jj)
203 arrname = adjustl(aname)
204 errmsg =
"Error reading data for array '"//trim(arrname)// &
205 "'. "//trim(adjustl(ermsgr))
210 iarr(j, i) = iarr(j, i) * iconst
213 if (iclose == 1)
then
223 read (locat, iostat=istat, iomsg=ermsgr) (iarr(j, i), j=1, jj)
225 arrname = adjustl(aname)
226 errmsg =
"Error reading data for array '"//trim(arrname)// &
227 "'. "//trim(adjustl(ermsgr))
232 iarr(j, i) = iarr(j, i) * iconst
236 if (iclose == 1)
then
242 if (iprn >= 0 .and. locat /= 0)
then
243 prowcolnum = (ndim == 3)
252 integer(I4B),
intent(in) :: iu
253 integer(I4B),
intent(in) :: iout
254 integer(I4B),
intent(in) :: ndim
255 integer(I4B),
intent(in) :: ncol
256 integer(I4B),
intent(in) :: nrow
257 integer(I4B),
intent(in) :: nlay
258 integer(I4B),
intent(in) :: k1, k2
259 integer(I4B),
dimension(ncol, nrow, nlay),
intent(inout) :: iarr
260 character(len=*),
intent(in) :: aname
262 integer(I4B) :: k, kk
274 integer(I4B),
intent(in) :: iu
275 integer(I4B),
intent(in) :: iout
276 integer(I4B),
intent(in) :: ndim
277 integer(I4B),
intent(in) :: nvals
278 integer(I4B),
dimension(nvals, 1, 1),
intent(inout) :: iarr
279 character(len=*),
intent(in) :: aname
286 nlay, nval, iout, k1, k2)
288 integer(I4B),
intent(in) :: iu, iout
289 integer(I4B),
intent(in) :: ncol, nrow, nlay, nval
290 integer(I4B),
dimension(nval),
intent(inout) :: iarr
291 character(len=*),
intent(in) :: aname
292 integer(I4B),
intent(in) :: ndim
293 integer(I4B),
intent(in) :: k1, k2
296 call read_array_int3d(iu, iarr, aname, ndim, ncol, nrow, nlay, iout, k1, k2)
303 integer(I4B),
intent(in) :: iu, iout
304 integer(I4B),
intent(in) :: jj
305 real(DP),
dimension(jj),
intent(inout) :: darr
306 character(len=*),
intent(in) :: aname
307 integer(I4B),
intent(in) :: ndim
308 integer(I4B),
intent(in) :: k
311 integer(I4B) :: j, iclose, iprn, locat, ncpl, ndig
313 logical :: prowcolnum
314 character(len=100) :: prfmt
315 integer(I4B) :: istat
316 integer(I4B) :: nvalt, nval
317 character(len=30) :: arrname
318 character(len=MAXCHARLEN) :: ermsgr
320 2
format(/, 1x, a,
' = ', g14.7,
' FOR LAYER ', i0)
321 3
format(/, 1x, a,
' = ', g14.7)
334 write (iout, 2) trim(aname), cnstnt, k
336 write (iout, 3) trim(aname), cnstnt
339 elseif (locat > 0)
then
341 read (locat, *, iostat=istat, iomsg=ermsgr) (darr(j), j=1, jj)
343 arrname = adjustl(aname)
344 errmsg =
"Error reading data for array '"// &
345 trim(adjustl(arrname))//
"'. "//trim(adjustl(ermsgr))
350 darr(j) = darr(j) * cnstnt
352 if (iclose == 1)
then
362 if (isok .EQV. .false.)
exit
363 read (locat, iostat=istat, iomsg=ermsgr) &
364 (darr(j), j=nvalt + 1, nvalt + nval)
366 arrname = adjustl(aname)
367 errmsg =
"Error reading data for array '"// &
368 trim(adjustl(arrname))//
"'. "//trim(adjustl(ermsgr))
373 if (nvalt ==
size(darr))
exit
378 darr(j) = darr(j) * cnstnt
382 if (iclose == 1)
then
388 if (iprn >= 0 .and. locat /= 0)
then
389 prowcolnum = (ndim == 3)
398 integer(I4B),
intent(in) :: iu, iout
399 integer(I4B),
intent(in) :: jj, ii
400 real(DP),
dimension(jj, ii),
intent(inout) :: darr
401 character(len=*),
intent(in) :: aname
402 integer(I4B),
intent(in) :: ndim
403 integer(I4B),
intent(in) :: k
406 integer(I4B) :: i, iclose, iprn, j, locat, ncpl, ndig
409 logical :: prowcolnum
410 character(len=100) :: prfmt
411 integer(I4B) :: istat
412 character(len=30) :: arrname
413 character(len=MAXCHARLEN) :: ermsgr
415 2
format(/, 1x, a,
' = ', g14.7,
' FOR LAYER ', i0)
416 3
format(/, 1x, a,
' = ', g14.7)
431 write (iout, 2) trim(aname), cnstnt, k
433 write (iout, 3) trim(aname), cnstnt
436 elseif (locat > 0)
then
439 read (locat, *, iostat=istat, iomsg=ermsgr) (darr(j, i), j=1, jj)
441 arrname = adjustl(aname)
442 errmsg =
"Error reading data for array '"// &
443 trim(adjustl(arrname))//
"'. "//trim(adjustl(ermsgr))
448 darr(j, i) = darr(j, i) * cnstnt
451 if (iclose == 1)
then
461 read (locat, iostat=istat, iomsg=ermsgr) (darr(j, i), j=1, jj)
463 arrname = adjustl(aname)
464 errmsg =
"Error reading data for array '"// &
465 trim(adjustl(arrname))//
"'. "//trim(adjustl(ermsgr))
470 darr(j, i) = darr(j, i) * cnstnt
474 if (iclose == 1)
then
480 if (iprn >= 0 .and. locat /= 0)
then
481 prowcolnum = (ndim == 3)
490 integer(I4B),
intent(in) :: iu
491 integer(I4B),
intent(in) :: iout
492 integer(I4B),
intent(in) :: ndim
493 integer(I4B),
intent(in) :: ncol
494 integer(I4B),
intent(in) :: nrow
495 integer(I4B),
intent(in) :: nlay
496 integer(I4B),
intent(in) :: k1, k2
497 real(DP),
dimension(ncol, nrow, nlay),
intent(inout) :: darr
498 character(len=*),
intent(in) :: aname
500 integer(I4B) :: k, kk
513 integer(I4B),
intent(in) :: iu
514 integer(I4B),
intent(in) :: iout
515 integer(I4B),
intent(in) :: ndim
516 integer(I4B),
intent(in) :: nvals
517 real(DP),
dimension(nvals, 1, 1),
intent(inout) :: darr
518 character(len=*),
intent(in) :: aname
525 nlay, nval, iout, k1, k2)
527 integer(I4B),
intent(in) :: iu, iout
528 integer(I4B),
intent(in) :: ncol, nrow, nlay, nval
529 real(DP),
dimension(nval),
intent(inout) :: darr
530 character(len=*),
intent(in) :: aname
531 integer(I4B),
intent(in) :: ndim
532 integer(I4B),
intent(in) :: k1, k2
535 call read_array_dbl3d(iu, darr, aname, ndim, ncol, nrow, nlay, iout, k1, k2)
549 integer(I4B),
intent(in) :: iu
550 integer(I4B),
intent(in) :: iout
551 character(len=*),
intent(in) :: aname
552 integer(I4B),
intent(out) :: locat
553 integer(I4B),
intent(out) :: iconst
554 integer(I4B),
intent(out) :: iclose
555 integer(I4B),
intent(out) :: iprn
557 integer(I4B) :: icol, icol1, istart, istop, n
559 character(len=MAXCHARLEN) :: fname
560 character(len=:),
allocatable :: line
563 call read_control_1(iu, iout, aname, locat, iclose, line, icol, fname)
566 call urword(line, icol, istart, istop, 2, iconst, r, iout, iu)
574 call urword(line, icol, istart, istop, 1, n, r, iout, iu)
575 if (line(istart:istop) ==
'FACTOR')
then
576 call urword(line, icol, istart, istop, 2, iconst, r, iout, iu)
577 if (iconst == 0) iconst = 1
584 call read_control_2(iu, iout, fname, line, icol, locat, iclose, iprn)
596 integer(I4B),
intent(in) :: iu
597 integer(I4B),
intent(in) :: iout
598 character(len=*),
intent(in) :: aname
599 integer(I4B),
intent(out) :: locat
600 real(DP),
intent(out) :: cnstnt
601 integer(I4B),
intent(out) :: iclose
602 integer(I4B),
intent(out) :: iprn
605 integer(I4B) :: icol, icol1, istart, istop, n
607 character(len=MAXCHARLEN) :: fname
608 character(len=:),
allocatable :: line
611 call read_control_1(iu, iout, aname, locat, iclose, line, icol, fname)
614 call urword(line, icol, istart, istop, 3, n, cnstnt, iout, iu)
622 call urword(line, icol, istart, istop, 1, n, r, iout, iu)
623 if (line(istart:istop) ==
'FACTOR')
then
624 call urword(line, icol, istart, istop, 3, n, cnstnt, iout, iu)
632 call read_control_2(iu, iout, fname, line, icol, locat, iclose, iprn)
639 integer(I4B),
intent(in) :: iu
640 integer(I4B),
intent(in) :: iout
641 character(len=*),
intent(in) :: aname
642 integer(I4B),
intent(out) :: locat
643 integer(I4B),
intent(out) :: iclose
644 character(len=:),
allocatable,
intent(inout) :: line
645 integer(I4B),
intent(inout) :: icol
646 character(len=*),
intent(inout) :: fname
649 integer(I4B) :: istart, istop, n
655 call u9rdcom(iu, iout, line, ierr)
660 call urword(line, icol, istart, istop, 1, n, r, iout, iu)
661 if (line(istart:istop) .eq.
'CONSTANT')
then
663 elseif (line(istart:istop) .eq.
'INTERNAL')
then
665 elseif (line(istart:istop) .eq.
'OPEN/CLOSE')
then
666 call urword(line, icol, istart, istop, 0, n, r, iout, iu)
667 fname = line(istart:istop)
671 errmsg =
'READING CONTROL RECORD FOR '// &
672 trim(adjustl(aname))//
"'. "// &
673 'Use CONSTANT, INTERNAL, or OPEN/CLOSE.'
675 call store_error_unit(iu)
684 integer(I4B),
intent(in) :: iu, iout, iclose
685 character(len=*),
intent(in) :: fname
686 character(len=*),
intent(inout) :: line
687 integer(I4B),
intent(inout) :: icol, iprn, locat
689 integer(I4B) :: i, n, istart, istop, lenkey
691 character(len=MAXCHARLEN) :: keyword
697 if (locat .ne. 0)
then
701 call urword(line, icol, istart, istop, 1, n, r, iout, iu)
702 keyword = line(istart:istop)
703 lenkey = len_trim(keyword)
704 select case (keyword)
706 if (iclose == 0)
then
707 errmsg =
'"(BINARY)" option for array input is valid only if'// &
708 ' OPEN/CLOSE is also specified.'
715 call urword(line, icol, istart, istop, 2, iprn, r, iout, iu)
720 errmsg =
'Invalid option found in array-control record: "' &
727 if (iclose == 0)
then
733 call openfile(locat, iout, fname,
'OPEN/CLOSE', fmtarg_opt=
form, &
737 call openfile(locat, iout, fname,
'OPEN/CLOSE')
746 integer(I4B),
intent(inout) :: iprn
747 character(len=*),
intent(out) :: prfmt
748 logical,
intent(in) :: prowcolnum
749 integer(I4B),
intent(out) :: ncpl, ndig
751 integer(I4B) :: nwidp
758 if (iprn > 9) iprn = 0
800 integer(I4B),
intent(inout) :: iprn
801 character(len=*),
intent(out) :: prfmt
802 logical,
intent(in) :: prowcolnum
803 integer(I4B),
intent(out) :: ncpl, ndig
805 integer(I4B) :: nwidp
806 character(len=1) :: editdesc
813 if (iprn > 21) iprn = 0
928 if (editdesc ==
'F')
then
938 ncpl, ndig, prowcolnum)
940 integer(I4B),
intent(in) :: iout, jj, ii, k
941 integer(I4B),
intent(in) :: ncpl
942 integer(I4B),
intent(in) :: ndig
943 integer(I4B),
dimension(jj, ii),
intent(in) :: iarr
944 character(len=*),
intent(in) :: aname
945 character(len=*),
intent(in) :: prfmt
946 logical,
intent(in) :: prowcolnum
950 2
format(/, 1x, a, 1x,
'FOR LAYER ', i0)
953 if (iout <= 0)
return
957 write (iout, 2) trim(aname), k
959 write (iout, 3) trim(aname)
965 call ucolno(1, jj, 4, ncpl, ndig, iout)
969 write (iout, prfmt) i, (iarr(j, i), j=1, jj)
973 errmsg =
'Program error printing array '//trim(aname)// &
974 ': ii > 1 when prowcolnum is false.'
979 write (iout, prfmt) (iarr(j, 1), j=1, jj)
984 ncpl, ndig, prowcolnum)
986 integer(I4B),
intent(in) :: iout, jj, ii, k
987 integer(I4B),
intent(in) :: ncpl
988 integer(I4B),
intent(in) :: ndig
989 real(DP),
dimension(jj, ii),
intent(in) :: darr
990 character(len=*),
intent(in) :: aname
991 character(len=*),
intent(in) :: prfmt
992 logical,
intent(in) :: prowcolnum
996 2
format(/, 1x, a, 1x,
'FOR LAYER ', i0)
999 if (iout <= 0)
return
1003 write (iout, 2) trim(aname), k
1005 write (iout, 3) trim(aname)
1009 if (prowcolnum)
then
1011 call ucolno(1, jj, 4, ncpl, ndig, iout)
1015 write (iout, prfmt) i, (darr(j, i), j=1, jj)
1019 errmsg =
'Program error printing array '//trim(aname)// &
1020 ': ii > 1 when prowcolnum is false.'
1025 write (iout, prfmt) (darr(j, 1), j=1, jj)
1031 integer(I4B),
intent(in) :: locat
1032 integer(I4B),
intent(in) :: iout
1033 character(len=*),
intent(in) :: arrname
1034 integer,
intent(out) :: nval
1036 integer(I4B) :: istat
1037 integer(I4B) :: kstp, kper, m1, m2, m3
1038 real(dp) :: pertim, totim
1039 character(len=BINARY_STRLEN) :: text
1040 character(len=MAXCHARLEN) :: ermsgr
1041 character(len=*),
parameter :: fmthdr = &
1042 "(/,1X,'HEADER FROM BINARY FILE HAS FOLLOWING ENTRIES',&
1043 &/,4X,'KSTP: ',I0,' KPER: ',I0,&
1044 &/,4x,'PERTIM: ',G0,' TOTIM: ',G0,&
1046 &/,4X,'MSIZE 1: ',I0,' MSIZE 2: ',I0,' MSIZE 3: ',I0)"
1049 read (locat, iostat=istat, iomsg=ermsgr) kstp, kper, pertim, totim, text, &
1053 if (istat /= 0)
then
1054 errmsg =
"Error reading data for array '"//adjustl(trim(arrname))// &
1055 "'. "//trim(adjustl(ermsgr))
1062 write (iout, fmthdr) kstp, kper, pertim, totim, text, m1, m2, m3
1071 integer(I4B),
intent(in) :: locat
1072 integer(I4B),
intent(in) :: expected_size
1073 character(len=*),
intent(in) :: arrname
1075 integer(I4B) :: file_size
1077 inquire (unit=locat, size=file_size)
1079 if (expected_size /= file_size)
then
1080 write (
errmsg,
'(a,i0,a,i0,a)') &
1081 'Unexpected file size for binary input array '// &
1082 trim(arrname)//
'. Expected=', expected_size, &
1083 '/Found=', file_size,
' bytes.'
1097 integer(I4B),
intent(in) :: nval
1098 integer(I4B),
intent(in) :: nvalt
1099 integer(I4B),
intent(in) :: arrsize
1100 character(len=*),
intent(in) :: aname
1101 integer(I4B),
intent(in) :: locat
1104 logical(LGP) :: isok
1109 if (nvalt + nval > arrsize)
then
1110 write (
errmsg,
'(a,i0,a,1x,a,1x,a,i0,a,1x,i0,3(1x,a))') &
1111 'The size of the data array calculated from the binary header (', &
1112 nval,
') will exceed the remainder of the', trim(adjustl(aname)), &
1113 'data array (', arrsize,
') array by', nvalt + nval - arrsize, &
1114 'elements. This is usually caused by incorrect assignment of', &
1115 '(m1,m2,m3) in the binary header. See the mf6io.pdf document', &
1116 'for information on assigning (m1,m2,m3).'
subroutine read_array_dbl1d_layered(iu, darr, aname, ndim, ncol, nrow, nlay, nval, iout, k1, k2)
subroutine read_control_2(iu, iout, fname, line, icol, locat, iclose, iprn)
subroutine read_control_1(iu, iout, aname, locat, iclose, line, icol, fname)
subroutine read_array_dbl3d_all(iu, darr, aname, ndim, nvals, iout)
subroutine, public read_binary_header(locat, iout, arrname, nval)
subroutine print_array_dbl(darr, aname, iout, jj, ii, k, prfmt, ncpl, ndig, prowcolnum)
subroutine read_array_int2d(iu, iarr, aname, ndim, jj, ii, iout, k)
subroutine read_array_int3d(iu, iarr, aname, ndim, ncol, nrow, nlay, iout, k1, k2)
integer(i4b), parameter binary_char_bytes
subroutine, public check_binary_filesize(locat, expected_size, arrname)
subroutine read_array_dbl2d(iu, darr, aname, ndim, jj, ii, iout, k)
subroutine read_control_dbl(iu, iout, aname, locat, cnstnt, iclose, iprn)
subroutine read_array_dbl1d(iu, darr, aname, ndim, jj, iout, k)
subroutine read_array_int1d(iu, iarr, aname, ndim, jj, iout, k)
integer(i4b), parameter binary_strlen
integer(i4b), parameter, public binary_int_bytes
subroutine build_format_int(iprn, prfmt, prowcolnum, ncpl, ndig)
logical(lgp) function check_binary_size(nval, nvalt, arrsize, aname, locat)
@ brief Check the binary data size
subroutine read_array_int1d_layered(iu, iarr, aname, ndim, ncol, nrow, nlay, nval, iout, k1, k2)
integer(i4b), parameter, public binary_header_bytes
array text
subroutine read_array_int3d_all(iu, iarr, aname, ndim, nvals, iout)
subroutine build_format_dbl(iprn, prfmt, prowcolnum, ncpl, ndig)
subroutine read_control_int(iu, iout, aname, locat, iconst, iclose, iprn)
subroutine read_array_dbl3d(iu, darr, aname, ndim, ncol, nrow, nlay, iout, k1, k2)
integer(i4b), parameter, public binary_double_bytes
subroutine print_array_int(iarr, aname, iout, jj, ii, k, prfmt, ncpl, ndig, prowcolnum)
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter namedboundflag
named bound flag
integer(i4b), parameter lenbigline
maximum length of a big line
integer(i4b), parameter lenboundname
maximum length of a bound name
real(dp), parameter dzero
real constant zero
integer(i4b), parameter maxcharlen
maximum length of char string
real(dp), parameter done
real constant 1
This module defines variable data types.
This module contains simulation methods.
subroutine, public ustop(stopmess, ioutlocal)
Stop the simulation.
subroutine, public store_error(msg, terminate)
Store an error message.
subroutine, public store_error_unit(iunit, terminate)
Store the file unit number.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string