28 subroutine openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, &
29 filstat_opt, mode_opt)
34 integer(I4B),
intent(inout) :: iu
35 integer(I4B),
intent(in) :: iout
36 character(len=*),
intent(in) :: fname
37 character(len=*),
intent(in) :: ftype
38 character(len=*),
intent(in),
optional :: fmtarg_opt
39 character(len=*),
intent(in),
optional :: accarg_opt
40 character(len=*),
intent(in),
optional :: filstat_opt
41 integer(I4B),
intent(in),
optional :: mode_opt
43 character(len=20) :: fmtarg
44 character(len=20) :: accarg
45 character(len=20) :: filstat
46 character(len=20) :: filact
52 character(len=*),
parameter :: fmtmsg = &
53 "(1x,/1x,'OPENED ',a,/1x,'FILE TYPE:',a,' UNIT ',I4,3x,'STATUS:',a,/ &
54 & 1x,'FORMAT:',a,3x,'ACCESS:',a/1x,'ACTION:',a/)"
55 character(len=*),
parameter :: fmtmsg2 = &
56 "(1x,/1x,'DID NOT OPEN ',a,/)"
59 if (
present(mode_opt))
then
68 write (iout, fmtmsg2) trim(fname)
78 if (
present(fmtarg_opt))
then
82 if (
present(accarg_opt))
then
86 if (
present(filstat_opt))
then
90 if (filstat ==
'OLD')
then
97 iflen = len_trim(fname)
105 inquire (file=fname(1:iflen), number=iuop)
109 open (unit=iu, file=fname(1:iflen), form=fmtarg, access=accarg, &
110 status=filstat,
action=filact, iostat=ivar)
115 write (
errmsg,
'(3a,1x,i0,a)') &
116 'Could not open "', fname(1:iflen),
'" on unit', iu,
'.'
118 write (
errmsg,
'(a,1x,a,1x,i0,a)') &
119 trim(
errmsg),
'File already open on unit', iuop,
'.'
121 write (
errmsg,
'(a,1x,a,1x,a,a)') &
122 trim(
errmsg),
'Specified file status', trim(filstat),
'.'
123 write (
errmsg,
'(a,1x,a,1x,a,a)') &
124 trim(
errmsg),
'Specified file format', trim(fmtarg),
'.'
125 write (
errmsg,
'(a,1x,a,1x,a,a)') &
126 trim(
errmsg),
'Specified file access', trim(accarg),
'.'
127 write (
errmsg,
'(a,1x,a,1x,a,a)') &
128 trim(
errmsg),
'Specified file action', trim(filact),
'.'
129 write (
errmsg,
'(a,1x,a,1x,i0,a)') &
130 trim(
errmsg),
'IOSTAT error number', ivar,
'.'
131 write (
errmsg,
'(a,1x,a)') &
132 trim(
errmsg),
'STOP EXECUTION in subroutine openfile().'
138 write (iout, fmtmsg) fname(1:iflen), ftype, iu, filstat, fmtarg, &
152 integer(I4B),
intent(inout) :: iu
158 inquire (unit=i, opened=opened)
159 if (.not. opened)
exit
175 integer(I4B) :: iunit
189 character(len=*),
intent(inout) :: word
192 integer(I4B) :: idiff
197 idiff = ichar(
'a') - ichar(
'A')
201 IF (word(k:k) >=
'a' .and. word(k:k) <=
'z') &
202 word(k:k) = char(ichar(word(k:k)) - idiff)
213 character(len=*) :: word
215 integer(I4B) :: idiff, k, l
219 idiff = ichar(
'a') - ichar(
'A')
223 if (word(k:k) >=
'A' .and. word(k:k) <=
'Z')
then
224 word(k:k) = char(ichar(word(k:k)) + idiff)
237 character(len=LINELENGTH),
intent(inout) :: name
238 integer(I4B),
intent(in) :: proc_id
240 character(len=LINELENGTH) :: name_local
241 character(len=LINELENGTH) :: name_processor
242 character(len=LINELENGTH) :: extension_local
243 integer(I4B) :: ipos0
244 integer(I4B) :: ipos1
248 ipos0 = index(name_local,
".", back=.true.)
249 ipos1 = len_trim(name)
251 write (extension_local,
'(a)') name(ipos0:ipos1)
256 write (name_processor,
'(a,a,i0,a)') &
257 name(1:ipos0 - 1),
'.p', proc_id, trim(adjustl(extension_local))
258 name = name_processor
267 subroutine uwword(line, icol, ilen, ncode, c, n, r, fmt, alignment, sep)
270 character(len=*),
intent(inout) :: line
271 integer(I4B),
intent(inout) :: icol
272 integer(I4B),
intent(in) :: ilen
273 integer(I4B),
intent(in) :: ncode
274 character(len=*),
intent(in) :: c
275 integer(I4B),
intent(in) :: n
276 real(dp),
intent(in) :: r
277 character(len=*),
optional,
intent(in) :: fmt
278 integer(I4B),
optional,
intent(in) :: alignment
279 character(len=*),
optional,
intent(in) :: sep
281 character(len=16) :: cfmt
282 character(len=16) :: cffmt
283 character(len=ILEN) :: cval
284 integer(I4B) :: ialign
286 integer(I4B) :: ispace
287 integer(I4B) :: istop
289 integer(I4B) :: ireal
296 if (
present(fmt))
then
301 write (cfmt,
'(a,I0,a)')
'(a', ilen,
')'
303 write (cfmt,
'(a,I0,a)')
'(I', ilen,
')'
307 write (cfmt,
'(a,I0,a,I0,a)')
'(1PG', ilen,
'.', i,
')'
313 write (cffmt,
'(a,I0,a)')
'(a', ilen,
')'
315 if (
present(alignment))
then
328 else if (ncode ==
tabreal)
then
333 if (len_trim(adjustl(cval)) > ilen)
then
336 cval = trim(adjustl(cval))
340 ispace = (ilen - i) / 2
343 cval =
' '//trim(adjustl(cval))
345 cval = trim(adjustl(cval))
348 cval = repeat(
' ', ispace)//trim(cval)
350 else if (ialign ==
tableft)
then
351 cval = trim(adjustl(cval))
353 cval =
' '//trim(adjustl(cval))
363 istop = icol + ilen - 1
366 write (line(icol:istop), cffmt) cval
370 if (
present(sep))
then
373 write (line(icol:istop),
'(a)') sep
405 subroutine urword(line, icol, istart, istop, ncode, n, r, iout, in)
407 character(len=*) :: line
408 integer(I4B),
intent(inout) :: icol
409 integer(I4B),
intent(inout) :: istart
410 integer(I4B),
intent(inout) :: istop
411 integer(I4B),
intent(in) :: ncode
412 integer(I4B),
intent(inout) :: n
413 real(dp),
intent(inout) :: r
414 integer(I4B),
intent(in) :: iout
415 integer(I4B),
intent(in) :: in
417 character(len=20) string
420 character(len=1) charend
421 character(len=200) :: msg
422 character(len=linelength) :: msg_line
424 character(len=*),
parameter :: fmtmsgout1 = &
425 "(1X,'FILE UNIT ',I4,' : ERROR CONVERTING ""',A, &
426 & '"" TO ',A,' IN LINE:')"
427 character(len=*),
parameter :: fmtmsgout2 =
"(1x, &
428 & 'KEYBOARD INPUT : ERROR CONVERTING ""',a,'"" TO ',a,' IN LINE:')"
429 character(len=*),
parameter :: fmtmsgout3 =
"('File unit ', &
430 & I0,': Error converting ""',a,'"" to ',A,' in following line:')"
431 character(len=*),
parameter :: fmtmsgout4 = &
432 "('Keyboard input: Error converting ""',a, &
433 & '"" to ',A,' in following line:')"
441 line(linlen:linlen) =
' '
445 if (icol < 1 .or. icol > linlen)
go to 100
450 if (line(i:i) /=
' ' .and. line(i:i) /=
',' .and. &
451 line(i:i) /= tab)
go to 20
459 20
if (line(i:i) == char(34) .or. line(i:i) == char(39))
then
460 if (line(i:i) == char(34))
then
466 if (i <= linlen)
then
468 if (line(j:j) == charend)
go to 40
475 if (line(j:j) ==
' ' .or. line(j:j) ==
',' .or. &
476 line(j:j) == tab)
go to 40
494 idiff = ichar(
'a') - ichar(
'A')
496 if (line(k:k) >=
'a' .and. line(k:k) <=
'z') &
497 line(k:k) = char(ichar(line(k:k)) - idiff)
503 100
if (ncode == 2 .or. ncode == 3)
then
505 l = 30 - istop + istart
507 rw(l:30) = line(istart:istop)
508 if (ncode == 2)
read (rw,
'(i30)', err=200) n
509 if (ncode == 3)
read (rw,
'(f30.0)', err=200) r
514 200
if (ncode == 3)
then
515 string =
'a real number'
518 string =
'an integer'
526 line(linlen + 1:linlen + 1) =
'E'
530 else if (iout > 0)
then
532 write (msg_line, fmtmsgout1) in, line(istart:istop), string(1:l)
534 write (msg_line, fmtmsgout2) line(istart:istop), string(1:l)
542 write (msg_line, fmtmsgout1) in, line(istart:istop), string(1:l)
544 write (msg_line, fmtmsgout2) line(istart:istop), string(1:l)
553 write (msg, fmtmsgout3) in, line(istart:istop), trim(string)
555 write (msg, fmtmsgout4) line(istart:istop), trim(string)
565 subroutine ulstlb(iout, label, caux, ncaux, naux)
567 character(len=*) :: label
568 character(len=16) :: caux(ncaux)
570 character(len=400) buf
572 character(len=1) dash(400)
575 character(len=*),
parameter :: fmtmsgout1 =
"(1x, a)"
576 character(len=*),
parameter :: fmtmsgout2 =
"(1x, 400a)"
582 nbuf = len(label) + 9
587 buf(n1:nbuf) = caux(i)
592 write (iout, fmtmsgout1) buf(1:nbuf)
595 write (iout, fmtmsgout2) (dash(j), j=1, nbuf)
603 subroutine ubdsv4(kstp, kper, text, naux, auxtxt, ibdchn, &
604 & ncol, nrow, nlay, nlist, iout, delt, pertim, totim)
606 character(len=16) :: text
607 character(len=16),
dimension(:) :: auxtxt
608 real(dp),
intent(in) :: delt, pertim, totim
610 character(len=*),
parameter :: fmt = &
611 &
"(1X,'UBDSV4 SAVING ',A16,' ON UNIT',I7,' AT TIME STEP',I7,"// &
612 &
"', STRESS PERIOD',I7)"
615 if (iout > 0)
write (iout, fmt) text, ibdchn, kstp, kper
616 write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
617 write (ibdchn) 5, delt, pertim, totim
618 write (ibdchn) naux + 1
619 if (naux > 0)
write (ibdchn) (auxtxt(n), n=1, naux)
626 subroutine ubdsvb(ibdchn, icrl, q, val, nvl, naux, laux)
628 real(dp),
dimension(nvl) :: val
634 write (ibdchn) icrl, q, (val(n), n=laux, n2)
636 write (ibdchn) icrl, q
649 subroutine ucolno(nlbl1, nlbl2, nspace, ncpl, ndig, iout)
651 character(len=1) :: dot, space, dg, bf
652 dimension :: bf(1000), dg(10)
654 data dg(1), dg(2), dg(3), dg(4), dg(5), dg(6), dg(7), dg(8), dg(9), dg(10)/ &
655 &
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'/
656 data dot, space/
'.',
' '/
658 character(len=*),
parameter :: fmtmsgout1 =
"(1x)"
659 character(len=*),
parameter :: fmtmsgout2 =
"(1x, 1000a1)"
663 if (iout <= 0)
return
664 write (iout, fmtmsgout1)
666 nlbl = nlbl2 - nlbl1 + 1
669 if (nlbl < ncpl) n = ncpl
670 ntot = nspace + n * ndig
672 if (ntot > 1000)
go to 50
673 nwrap = (nlbl - 1) / ncpl + 1
689 if (j2 > nlbl2) j2 = nlbl2
697 if (i2 == 0)
go to 30
699 i2 = i2 - i3 * 10 + 1
701 if (i3 == 0)
go to 30
703 i3 = i3 - i4 * 10 + 1
705 if (i4 == 0)
go to 30
710 bf(nbf - 3) = dg(i4 + 1)
715 write (iout, fmtmsgout2) (bf(i), i=1, nbf)
721 if (ntot > 1000) ntot = 1000
722 write (iout, fmtmsgout2) (dot, i=1, ntot)
727 subroutine ulaprw(buf, text, kstp, kper, ncol, nrow, ilay, iprn, iout)
729 character(len=16) :: text
730 real(dp),
dimension(ncol, nrow) :: buf
732 character(len=*),
parameter :: fmtmsgout1 = &
733 &
"('1', /2x, a, ' IN LAYER ',I3,' AT END OF TIME STEP ',I3, &
734 & ' IN STRESS PERIOD ',I4/2x,75('-'))"
735 character(len=*),
parameter :: fmtmsgout2 = &
736 &
"('1',/1x,A,' FOR CROSS SECTION AT END OF TIME STEP',I3, &
737 & ' IN STRESS PERIOD ',I4/1x,79('-'))"
738 character(len=*),
parameter :: fmtg10 = &
739 &
"(1X,I3,2X,1PG10.3,10(1X,G10.3):/(5X,11(1X,G10.3)))"
740 character(len=*),
parameter :: fmtg13 = &
741 &
"(1x,I3,2x,1PG13.6,8(1x,G13.6):/(5x,9(1x,G13.6)))"
742 character(len=*),
parameter :: fmtf7pt1 = &
743 &
"(1x,I3,1x,15(1x,F7.1):/(5x,15(1x,F7.1)))"
744 character(len=*),
parameter :: fmtf7pt2 = &
745 &
"(1x,I3,1x,15(1x,F7.2):/(5x,15(1x,F7.2)))"
746 character(len=*),
parameter :: fmtf7pt3 = &
747 &
"(1x,I3,1x,15(1x,F7.3):/(5x,15(1x,F7.3)))"
748 character(len=*),
parameter :: fmtf7pt4 = &
749 &
"(1x,I3,1x,15(1x,F7.4):/(5x,15(1x,F7.4)))"
750 character(len=*),
parameter :: fmtf5pt0 = &
751 &
"(1x,I3,1x,20(1x,F5.0):/(5x,20(1x,F5.0)))"
752 character(len=*),
parameter :: fmtf5pt1 = &
753 &
"(1x,I3,1x,20(1x,F5.1):/(5x,20(1x,F5.1)))"
754 character(len=*),
parameter :: fmtf5pt2 = &
755 &
"(1x,I3,1x,20(1x,F5.2):/(5x,20(1x,F5.2)))"
756 character(len=*),
parameter :: fmtf5pt3 = &
757 &
"(1x,I3,1x,20(1x,F5.3):/(5x,20(1x,F5.3)))"
758 character(len=*),
parameter :: fmtf5pt4 = &
759 &
"(1x,I3,1x,20(1x,F5.4):/(5x,20(1x,F5.4)))"
760 character(len=*),
parameter :: fmtg11 = &
761 &
"(1x,I3,2x,1PG11.4,9(1x,G11.4):/(5x,10(1x,G11.4)))"
762 character(len=*),
parameter :: fmtf6pt0 = &
763 &
"(1x,I3,1x,10(1x,F6.0):/(5X,10(1x,F6.0)))"
764 character(len=*),
parameter :: fmtf6pt1 = &
765 &
"(1x,I3,1x,10(1x,F6.1):/(5x,10(1x,F6.1)))"
766 character(len=*),
parameter :: fmtf6pt2 = &
767 &
"(1x,I3,1x,10(1x,F6.2):/(5x,10(1x,F6.2)))"
768 character(len=*),
parameter :: fmtf6pt3 = &
769 &
"(1x,I3,1x,10(1x,F6.3):/(5x,10(1x,F6.3)))"
770 character(len=*),
parameter :: fmtf6pt4 = &
771 &
"(1x,I3,1x,10(1x,F6.4):/(5x,10(1x,F6.4)))"
772 character(len=*),
parameter :: fmtf6pt5 = &
773 &
"(1x,I3,1x,10(1x,F6.5):/(5x,10(1x,F6.5)))"
774 character(len=*),
parameter :: fmtg12 = &
775 &
"(1x,I3,2x,1PG12.5,4(1x,G12.5):/(5x,5(1x,G12.5)))"
776 character(len=*),
parameter :: fmtg11pt4 = &
777 &
"(1x,I3,2x,1PG11.4,5(1x,G11.4):/(5x,6(1x,G11.4)))"
778 character(len=*),
parameter :: fmtg9pt2 = &
779 &
"(1x,I3,2x,1PG9.2,6(1x,G9.2):/(5x,7(1x,G9.2)))"
781 if (iout <= 0)
return
784 write (iout, fmtmsgout1) text, ilay, kstp, kper
785 else if (ilay < 0)
then
786 write (iout, fmtmsgout2) text, kstp, kper
791 if (ip < 1 .or. ip > 21) ip = 12
794 if (ip == 1)
call ucolno(1, ncol, 0, 11, 11, iout)
795 if (ip == 2)
call ucolno(1, ncol, 0, 9, 14, iout)
796 if (ip >= 3 .and. ip <= 6)
call ucolno(1, ncol, 3, 15, 8, iout)
797 if (ip >= 7 .and. ip <= 11)
call ucolno(1, ncol, 3, 20, 6, iout)
798 if (ip == 12)
call ucolno(1, ncol, 0, 10, 12, iout)
799 if (ip >= 13 .and. ip <= 18)
call ucolno(1, ncol, 3, 10, 7, iout)
800 if (ip == 19)
call ucolno(1, ncol, 0, 5, 13, iout)
801 if (ip == 20)
call ucolno(1, ncol, 0, 6, 12, iout)
802 if (ip == 21)
call ucolno(1, ncol, 0, 7, 10, iout)
810 write (iout, fmtg10) i, (buf(j, i), j=1, ncol)
814 write (iout, fmtg13) i, (buf(j, i), j=1, ncol)
818 write (iout, fmtf7pt1) i, (buf(j, i), j=1, ncol)
822 write (iout, fmtf7pt2) i, (buf(j, i), j=1, ncol)
826 write (iout, fmtf7pt3) i, (buf(j, i), j=1, ncol)
830 write (iout, fmtf7pt4) i, (buf(j, i), j=1, ncol)
834 write (iout, fmtf5pt0) i, (buf(j, i), j=1, ncol)
838 write (iout, fmtf5pt1) i, (buf(j, i), j=1, ncol)
842 write (iout, fmtf5pt2) i, (buf(j, i), j=1, ncol)
846 write (iout, fmtf5pt3) i, (buf(j, i), j=1, ncol)
850 write (iout, fmtf5pt4) i, (buf(j, i), j=1, ncol)
854 write (iout, fmtg11) i, (buf(j, i), j=1, ncol)
858 write (iout, fmtf6pt0) i, (buf(j, i), j=1, ncol)
862 write (iout, fmtf6pt1) i, (buf(j, i), j=1, ncol)
866 write (iout, fmtf6pt2) i, (buf(j, i), j=1, ncol)
870 write (iout, fmtf6pt3) i, (buf(j, i), j=1, ncol)
874 write (iout, fmtf6pt4) i, (buf(j, i), j=1, ncol)
878 write (iout, fmtf6pt5) i, (buf(j, i), j=1, ncol)
882 write (iout, fmtg12) i, (buf(j, i), j=1, ncol)
886 write (iout, fmtg11pt4) i, (buf(j, i), j=1, ncol)
890 write (iout, fmtg9pt2) i, (buf(j, i), j=1, ncol)
901 subroutine ulasav(buf, text, kstp, kper, pertim, totim, ncol, nrow, &
904 character(len=16) :: text
905 real(dp),
dimension(ncol, nrow) :: buf
906 real(dp) :: pertim, totim
909 write (ichn) kstp, kper, pertim, totim, text, ncol, nrow, ilay
913 write (ichn) ((buf(ic, ir), ic=1, ncol), ir=1, nrow)
922 subroutine ubdsv1(kstp, kper, text, ibdchn, buff, ncol, nrow, nlay, iout, &
926 integer(I4B),
intent(in) :: kstp
927 integer(I4B),
intent(in) :: kper
928 character(len=*),
intent(in) :: text
929 integer(I4B),
intent(in) :: ibdchn
930 real(dp),
dimension(:),
intent(in) :: buff
931 integer(I4B),
intent(in) :: ncol
932 integer(I4B),
intent(in) :: nrow
933 integer(I4B),
intent(in) :: nlay
934 integer(I4B),
intent(in) :: iout
935 real(dp),
intent(in) :: delt
936 real(dp),
intent(in) :: pertim
937 real(dp),
intent(in) :: totim
939 character(len=*),
parameter :: fmt = &
940 &
"(1X,'UBDSV1 SAVING ',A16,' ON UNIT',I7,' AT TIME STEP',I7,"// &
941 &
"', STRESS PERIOD',I7)"
944 if (iout > 0)
write (iout, fmt) text, ibdchn, kstp, kper
945 write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
946 write (ibdchn) 1, delt, pertim, totim
958 subroutine ubdsv06(kstp, kper, text, modelnam1, paknam1, modelnam2, paknam2, &
959 ibdchn, naux, auxtxt, ncol, nrow, nlay, nlist, iout, &
963 integer(I4B),
intent(in) :: kstp
964 integer(I4B),
intent(in) :: kper
965 character(len=*),
intent(in) :: text
966 character(len=*),
intent(in) :: modelnam1
967 character(len=*),
intent(in) :: paknam1
968 character(len=*),
intent(in) :: modelnam2
969 character(len=*),
intent(in) :: paknam2
970 integer(I4B),
intent(in) :: naux
971 character(len=16),
dimension(:),
intent(in) :: auxtxt
972 integer(I4B),
intent(in) :: ibdchn
973 integer(I4B),
intent(in) :: ncol
974 integer(I4B),
intent(in) :: nrow
975 integer(I4B),
intent(in) :: nlay
976 integer(I4B),
intent(in) :: nlist
977 integer(I4B),
intent(in) :: iout
978 real(dp),
intent(in) :: delt
979 real(dp),
intent(in) :: pertim
980 real(dp),
intent(in) :: totim
984 character(len=*),
parameter :: fmt = &
985 &
"(1X,'UBDSV06 SAVING ',A16,' IN MODEL ',A16,' PACKAGE ',A16,"// &
986 &
"'CONNECTED TO MODEL ',A16,' PACKAGE ',A16,"// &
987 &
"' ON UNIT',I7,' AT TIME STEP',I7,', STRESS PERIOD',I7)"
990 if (iout > 0)
write (iout, fmt) text, modelnam1, paknam1, modelnam2, &
991 paknam2, ibdchn, kstp, kper
992 write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
993 write (ibdchn) 6, delt, pertim, totim
994 write (ibdchn) modelnam1
995 write (ibdchn) paknam1
996 write (ibdchn) modelnam2
997 write (ibdchn) paknam2
998 write (ibdchn) naux + 1
999 if (naux > 0)
write (ibdchn) (auxtxt(n), n=1, naux)
1000 write (ibdchn) nlist
1010 integer(I4B),
intent(in) :: ibdchn
1011 integer(I4B),
intent(in) :: n
1012 real(dp),
intent(in) :: q
1013 integer(I4B),
intent(in) :: naux
1014 real(dp),
dimension(naux),
intent(in) :: aux
1020 write (ibdchn) n, q, (aux(nn), nn=1, naux)
1030 subroutine ubdsvd(ibdchn, n, n2, q, naux, aux)
1033 integer(I4B),
intent(in) :: ibdchn
1034 integer(I4B),
intent(in) :: n
1035 integer(I4B),
intent(in) :: n2
1036 real(dp),
intent(in) :: q
1037 integer(I4B),
intent(in) :: naux
1038 real(dp),
dimension(naux),
intent(in) :: aux
1044 write (ibdchn) n, n2, q, (aux(nn), nn=1, naux)
1046 write (ibdchn) n, n2, q
1055 character(len=*),
intent(in) :: word1, word2
1057 character(len=200) :: upword1, upword2
1070 character(len=*),
intent(in) :: str
1071 integer,
intent(in) :: width
1073 character(len=max(len_trim(str), width)) :: res
1083 character(len=LINELENGTH) :: line
1084 character(len=100) :: fname, ac, act, fm, frm, seq, unf
1086 character(len=*),
parameter :: fmta = &
1087 &
"('unit:',i4,' name:',a,' access:',a,' action:',a)"
1088 character(len=*),
parameter :: fmtb = &
1089 &
"(' formatted:',a,' sequential:',a,' unformatted:',a,' form:',a)"
1092 inquire (unit=iu, name=fname, access=ac, action=act, formatted=fm, &
1093 sequential=seq, unformatted=unf, form=frm)
1096 write (line, fmta) iu, trim(fname), trim(ac), trim(act)
1098 write (line, fmtb) trim(fm), trim(seq), trim(unf), trim(frm)
1113 character(len=*),
intent(in) :: line
1114 integer(I4B),
intent(inout) :: nwords
1115 character(len=*),
allocatable,
dimension(:),
intent(inout) :: words
1116 integer(I4B),
intent(in),
optional :: inunit
1117 character(len=*),
intent(in),
optional :: filename
1119 integer(I4B) :: i, idum, istart, istop, linelen, lloc
1123 if (
allocated(words))
then
1130 allocate (words(nwords))
1135 call urword(line, lloc, istart, istop, 0, idum, rdum, 0, 0)
1136 words(i) = line(istart:istop)
1142 subroutine ulaprufw(ncol, nrow, kstp, kper, ilay, iout, buf, text, userfmt, &
1143 nvalues, nwidth, editdesc)
1146 integer(I4B),
intent(in) :: ncol, nrow, kstp, kper, ilay, iout
1147 real(dp),
dimension(ncol, nrow),
intent(in) :: buf
1148 character(len=*),
intent(in) :: text
1149 character(len=*),
intent(in) :: userfmt
1150 integer(I4B),
intent(in) :: nvalues, nwidth
1151 character(len=1),
intent(in) :: editdesc
1153 integer(I4B) :: i, j, nspaces
1155 character(len=*),
parameter :: fmtmsgout1 = &
1156 "('1',/2X,A,' IN LAYER ',I3,' AT END OF TIME STEP ',I3, &
1157 & ' IN STRESS PERIOD ',I4/2X,75('-'))"
1158 character(len=*),
parameter :: fmtmsgout2 = &
1159 "('1',/1X,A,' FOR CROSS SECTION AT END OF TIME STEP',I3, &
1160 & ' IN STRESS PERIOD ',I4/1X,79('-'))"
1162 if (iout <= 0)
return
1165 write (iout, fmtmsgout1) trim(text), ilay, kstp, kper
1166 else if (ilay < 0)
then
1167 write (iout, fmtmsgout2) trim(text), kstp, kper
1172 if (editdesc ==
'F') nspaces = 3
1173 call ucolno(1, ncol, nspaces, nvalues, nwidth + 1, iout)
1177 write (iout, userfmt) i, (buf(j, i), j=1, ncol)
1200 integer(I4B),
intent(in) :: iu
1201 logical,
intent(out) :: eof
1202 character(len=:),
allocatable :: astring
1204 integer(I4B) :: isize, istat
1205 character(len=256) :: buffer
1206 character(len=1000) :: ermsg, fname
1207 character(len=7) :: fmtd
1210 character(len=*),
parameter :: fmterrmsg1 = &
1211 &
"('Error in read_line: File ',i0,' is not open.')"
1212 character(len=*),
parameter :: fmterrmsg2 = &
1213 &
"('Error in read_line: Attempting to read text ' // &
1214 & 'from unformatted file: ""',a,'""')"
1215 character(len=*),
parameter :: fmterrmsg3 = &
1216 &
"('Error reading from file ""',a,'"" opened on unit ',i0, &
1217 & ' in read_line.')"
1222 read (iu,
'(a)', advance=
'NO', iostat=istat, size=isize,
end=99) buffer
1226 ermsg =
'Programming error in call to read_line: '// &
1227 'Attempt to read from unit number <= 0'
1229 inquire (unit=iu, opened=lop, name=fname, formatted=fmtd)
1231 write (ermsg, fmterrmsg1) iu
1232 elseif (fmtd ==
'NO' .or. fmtd ==
'UNKNOWN')
then
1233 write (ermsg, fmterrmsg2) trim(fname)
1235 write (ermsg, fmterrmsg3) trim(fname), iu
1241 astring = astring//buffer(:isize)
1258 character(len=*),
intent(in) :: pathname
1259 character(len=*),
intent(out) :: filename
1261 integer(I4B) :: i, istart, istop, lenpath
1262 character(len=1) :: fs =
'/'
1263 character(len=1) :: bs =
'\'
1266 lenpath = len_trim(pathname)
1269 loop:
do i = lenpath, 1, -1
1270 if (pathname(i:i) == fs .or. pathname(i:i) == bs)
then
1271 if (i == istop)
then
1279 if (istop >= istart)
then
1280 filename = pathname(istart:istop)
1294 character(len=*),
intent(inout) :: line
1295 integer(I4B),
intent(inout) :: icol, istart, istop
1296 integer(I4B),
intent(out) :: idnum
1297 character(len=LENBOUNDNAME),
intent(out) :: bndname
1299 integer(I4B) :: istat, ndum, ncode = 0
1302 call urword(line, icol, istart, istop, ncode, ndum, rdum, 0, 0)
1303 read (line(istart:istop), *, iostat=istat) ndum
1304 if (istat == 0)
then
1308 idnum = namedboundflag
1309 bndname = line(istart:istop)
1316 subroutine urdaux(naux, inunit, iout, lloc, istart, istop, auxname, line, text)
1323 integer(I4B),
intent(inout) :: naux
1324 integer(I4B),
intent(in) :: inunit
1325 integer(I4B),
intent(in) :: iout
1326 integer(I4B),
intent(inout) :: lloc
1327 integer(I4B),
intent(inout) :: istart
1328 integer(I4B),
intent(inout) :: istop
1329 character(len=LENAUXNAME),
allocatable,
dimension(:),
intent(inout) :: auxname
1330 character(len=*),
intent(inout) :: line
1331 character(len=*),
intent(in) :: text
1333 integer(I4B) :: n, linelen
1334 integer(I4B) :: iauxlen
1339 write (errmsg,
'(a)')
'Auxiliary variables already specified. '// &
1340 &
'Auxiliary variables must be specified on one line in the '// &
1342 call store_error(errmsg)
1343 call store_error_unit(inunit)
1346 call urword(line, lloc, istart, istop, 1, n, rval, iout, inunit)
1347 if (istart >= linelen)
exit auxloop
1348 iauxlen = istop - istart + 1
1350 write (errmsg,
'(a, a, a, i0, a, i0, a)') &
1351 'Found auxiliary variable (', line(istart:istop), &
1352 ') with a name of size ', iauxlen, &
1353 '. Auxiliary variable names must be len than or equal&
1355 call store_error(errmsg)
1356 call store_error_unit(inunit)
1360 auxname(naux) = line(istart:istop)
1362 write (iout,
"(4X,'AUXILIARY ',a,' VARIABLE: ',A)") &
1363 trim(adjustl(text)), auxname(naux)
1386 subroutine print_format(linein, cdatafmp, editdesc, nvaluesp, nwidthp, inunit)
1388 character(len=*),
intent(in) :: linein
1389 character(len=*),
intent(inout) :: cdatafmp
1390 character(len=*),
intent(inout) :: editdesc
1391 integer(I4B),
intent(inout) :: nvaluesp
1392 integer(I4B),
intent(inout) :: nwidthp
1393 integer(I4B),
intent(in) :: inunit
1395 character(len=len(linein)) :: line
1396 character(len=20),
dimension(:),
allocatable :: words
1397 character(len=100) :: ermsg
1398 integer(I4B) :: ndigits = 0, nwords = 0
1399 integer(I4B) :: i, ierr
1404 call parseline(line, nwords, words, inunit)
1408 if (editdesc ==
'I') isint = .true.
1411 if (nwords < 1)
then
1412 ermsg =
'Could not build PRINT_FORMAT from line'//trim(line)
1413 call store_error(trim(ermsg))
1414 ermsg =
'Syntax is: COLUMNS <columns> WIDTH <width> DIGITS &
1416 call store_error(trim(ermsg))
1417 call store_error_unit(inunit)
1420 ermsg =
'Error setting PRINT_FORMAT. Syntax is incorrect in line:'
1421 if (nwords >= 4)
then
1422 if (.not.
same_word(words(1),
'COLUMNS')) ierr = 1
1423 if (.not.
same_word(words(3),
'WIDTH')) ierr = 1
1426 read (words(2), *, iostat=ierr) nvaluesp
1429 read (words(4), *, iostat=ierr) nwidthp
1435 call store_error(ermsg)
1436 call store_error(line)
1437 ermsg =
'Syntax is: COLUMNS <columns> WIDTH <width> &
1438 &DIGITS <digits> <format>'
1439 call store_error(trim(ermsg))
1440 call store_error_unit(inunit)
1444 if (.not. isint)
then
1446 if (nwords >= 5)
then
1447 if (.not.
same_word(words(5),
'DIGITS')) ierr = 1
1449 read (words(6), *, iostat=ierr) ndigits
1460 if (i <= nwords)
then
1462 select case (words(i))
1463 case (
'EXPONENTIAL')
1476 ermsg =
'Error in format specification. Unrecognized option: '//words(i)
1477 call store_error(ermsg)
1478 ermsg =
'Valid values are EXPONENTIAL, FIXED, GENERAL, or SCIENTIFIC.'
1479 call store_error(ermsg)
1480 call store_error_unit(inunit)
1487 call store_error(ermsg)
1488 call store_error(line)
1489 call store_error_unit(inunit)
1493 select case (editdesc)
1498 case (
'E',
'G',
'S')
1508 integer(I4B),
intent(in) :: nvalsp, nwidp, ndig
1509 character(len=*),
intent(inout) :: outfmt
1510 logical,
intent(in),
optional :: prowcolnum
1512 character(len=8) :: cvalues, cwidth, cdigits
1513 character(len=60) :: ufmt
1514 logical :: prowcolnumlocal
1516 character(len=*),
parameter :: fmtndig =
"(i8)"
1518 if (
present(prowcolnum))
then
1519 prowcolnumlocal = prowcolnum
1521 prowcolnumlocal = .true.
1525 write (cdigits, fmtndig) ndig
1526 cdigits = adjustl(cdigits)
1529 write (cvalues, fmtndig) nvalsp
1530 cvalues = adjustl(cvalues)
1531 write (cwidth, fmtndig) nwidp
1532 cwidth = adjustl(cwidth)
1533 if (prowcolnumlocal)
then
1539 ufmt = trim(ufmt)//cvalues
1540 ufmt = trim(ufmt)//
'(1x,f'
1541 ufmt = trim(ufmt)//cwidth
1542 ufmt = trim(ufmt)//
'.'
1543 ufmt = trim(ufmt)//cdigits
1544 ufmt = trim(ufmt)//
'):/(5x,'
1545 ufmt = trim(ufmt)//cvalues
1546 ufmt = trim(ufmt)//
'(1x,f'
1547 ufmt = trim(ufmt)//cwidth
1548 ufmt = trim(ufmt)//
'.'
1549 ufmt = trim(ufmt)//cdigits
1550 ufmt = trim(ufmt)//
')))'
1559 integer(I4B),
intent(in) :: nvalsp, nwidp, ndig
1560 character(len=*),
intent(in) :: editdesc
1561 character(len=*),
intent(inout) :: outfmt
1562 logical,
intent(in),
optional :: prowcolnum
1564 character(len=8) :: cvalues, cwidth, cdigits
1565 character(len=60) :: ufmt
1566 logical :: prowcolnumlocal
1568 character(len=*),
parameter :: fmtndig =
"(i8)"
1570 if (
present(prowcolnum))
then
1571 prowcolnumlocal = prowcolnum
1573 prowcolnumlocal = .true.
1577 write (cdigits, fmtndig) ndig
1578 cdigits = adjustl(cdigits)
1580 write (cwidth, fmtndig) nwidp
1581 cwidth = adjustl(cwidth)
1583 write (cvalues, fmtndig) (nvalsp - 1)
1584 cvalues = adjustl(cvalues)
1585 if (prowcolnumlocal)
then
1586 ufmt =
'(1x,i3,2x,1p,'//editdesc
1588 ufmt =
'(6x,1p,'//editdesc
1590 ufmt = trim(ufmt)//cwidth
1591 ufmt = trim(ufmt)//
'.'
1592 ufmt = trim(ufmt)//cdigits
1593 if (nvalsp > 1)
then
1594 ufmt = trim(ufmt)//
','
1595 ufmt = trim(ufmt)//cvalues
1596 ufmt = trim(ufmt)//
'(1x,'
1597 ufmt = trim(ufmt)//editdesc
1598 ufmt = trim(ufmt)//cwidth
1599 ufmt = trim(ufmt)//
'.'
1600 ufmt = trim(ufmt)//cdigits
1601 ufmt = trim(ufmt)//
')'
1604 ufmt = trim(ufmt)//
':/(5x,'
1605 write (cvalues, fmtndig) nvalsp
1606 cvalues = adjustl(cvalues)
1607 ufmt = trim(ufmt)//cvalues
1608 ufmt = trim(ufmt)//
'(1x,'
1609 ufmt = trim(ufmt)//editdesc
1610 ufmt = trim(ufmt)//cwidth
1611 ufmt = trim(ufmt)//
'.'
1612 ufmt = trim(ufmt)//cdigits
1613 ufmt = trim(ufmt)//
')))'
1622 integer(I4B),
intent(in) :: nvalsp, nwidp
1623 character(len=*),
intent(inout) :: outfmt
1624 logical,
intent(in),
optional :: prowcolnum
1626 character(len=8) :: cvalues, cwidth
1627 character(len=60) :: ufmt
1628 logical :: prowcolnumlocal
1630 character(len=*),
parameter :: fmtndig =
"(i8)"
1632 if (
present(prowcolnum))
then
1633 prowcolnumlocal = prowcolnum
1635 prowcolnumlocal = .true.
1639 write (cvalues, fmtndig) nvalsp
1640 cvalues = adjustl(cvalues)
1641 write (cwidth, fmtndig) nwidp
1642 cwidth = adjustl(cwidth)
1643 if (prowcolnumlocal)
then
1648 ufmt = trim(ufmt)//cvalues
1649 ufmt = trim(ufmt)//
'(1x,i'
1650 ufmt = trim(ufmt)//cwidth
1651 ufmt = trim(ufmt)//
'):/(5x,'
1652 ufmt = trim(ufmt)//cvalues
1653 ufmt = trim(ufmt)//
'(1x,i'
1654 ufmt = trim(ufmt)//cwidth
1655 ufmt = trim(ufmt)//
')))'
1665 character(len=*),
intent(in) :: line
1667 integer(I4B) :: linelen
1668 integer(I4B) :: lloc
1669 integer(I4B) :: istart
1670 integer(I4B) :: istop
1671 integer(I4B) :: idum
1681 call urword(line, lloc, istart, istop, 0, idum, rdum, 0, 0)
1682 if (istart == linelen)
exit
1695 integer(I4B),
intent(in) :: iu
1696 integer(I4B),
intent(in) :: offset
1697 integer(I4B),
intent(in) :: whence
1698 integer(I4B),
intent(inout) :: status
1700 integer(I8B) :: ipos
1702 inquire (unit=iu, size=ipos)
1704 select case (whence)
1712 inquire (unit=iu, pos=ipos)
1713 ipos = ipos + offset
1717 inquire (unit=iu, size=ipos)
1718 ipos = ipos + offset
1722 write (iu, pos=ipos, iostat=status)
1723 inquire (unit=iu, pos=ipos)
1733 use,
intrinsic :: iso_fortran_env, only: iostat_end
1736 integer(I4B),
intent(in) :: iin
1737 integer(I4B),
intent(in) :: iout
1738 character(len=:),
allocatable,
intent(inout) :: line
1739 integer(I4B),
intent(out) :: ierr
1741 character(len=:),
allocatable :: linetemp
1742 character(len=2),
parameter :: comment =
'//'
1743 character(len=1),
parameter :: tab = char(9)
1744 logical :: iscomment
1745 integer(I4B) :: i, j, l, istart, lsize
1751 if (ierr == iostat_end)
then
1756 elseif (ierr /= 0)
then
1759 write (errmsg, *)
'u9rdcom: Could not read from unit: ', iin
1760 call store_error(errmsg, terminate=.true.)
1762 if (len_trim(line) < 1)
then
1773 allocate (
character(len=lsize) :: linetemp)
1775 if (line(j:j) /=
' ' .and. line(j:j) /=
',' .and. &
1776 line(j:j) /= char(9))
then
1782 linetemp(:) = line(istart:)
1783 line(:) = linetemp(:)
1784 deallocate (linetemp)
1788 select case (line(1:1))
1799 if (line(1:2) == comment) iscomment = .true.
1800 if (len_trim(line) < 1) iscomment = .true.
1805 if (.not. iscomment)
then
1812 if (line(i:i) /=
' ')
then
1817 write (iout,
'(1x,a)') line(1:i)
1831 integer(I4B),
intent(in) :: lun
1832 character(len=:),
intent(out),
allocatable :: line
1833 integer(I4B),
intent(out) :: iostat
1835 integer(I4B),
parameter :: buffer_len = maxcharlen
1836 character(len=buffer_len) :: buffer
1837 character(len=:),
allocatable :: linetemp
1838 integer(I4B) :: size_read, linesize
1839 character(len=1),
parameter :: cr = char(13)
1840 character(len=1),
parameter :: lf = char(10)
1848 read (lun,
'(A)', iostat=iostat, advance=
'no', size=size_read) buffer
1849 if (is_iostat_eor(iostat))
then
1850 linesize = len(line)
1851 deallocate (linetemp)
1852 allocate (
character(len=linesize) :: linetemp)
1853 linetemp(:) = line(:)
1855 allocate (
character(len=linesize + size_read + 1) :: line)
1856 line(:) = linetemp(:)
1857 line(linesize + 1:) = buffer(:size_read)
1858 linesize = len(line)
1859 line(linesize:linesize) =
' '
1862 else if (iostat == 0)
then
1863 linesize = len(line)
1864 deallocate (linetemp)
1865 allocate (
character(len=linesize) :: linetemp)
1866 linetemp(:) = line(:)
1868 allocate (
character(len=linesize + size_read) :: line)
1869 line(:) = linetemp(:)
1870 line(linesize + 1:) = buffer(:size_read)
1877 linesize = len(line)
1878 crlfcheck:
do i = 1, linesize
1879 if (line(i:i) .eq. cr .or. line(i:i) .eq. lf)
then
1880 if (line(i:i) .eq. cr)
then
1881 write (errmsg,
'(a)') &
1882 'get_line: Found an isolated Carriage Return.'
1884 if (line(i:i) .eq. lf)
then
1885 write (errmsg,
'(a)') &
1886 'get_line: Found an isolated Line Feed.'
1888 write (errmsg,
'(a,1x,a,a)') trim(errmsg), &
1889 'Replace with Carriage Return and Line Feed to', &
1890 ' read as two separate lines.'
1891 write (errmsg,
'(a,1x,5a)') trim(errmsg), &
1892 'Line: "', line(1:i - 1),
'|', line(i + 1:linesize),
'"'
1893 call store_error(errmsg, terminate=.false.)
1894 call store_error_unit(lun, terminate=.true.)
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
@ tabcenter
centered table column
@ tabright
right justified table column
@ tableft
left justified table column
@ tabucstring
upper case string table data
@ tabstring
string table data
@ tabinteger
integer table data
integer(i4b), parameter iulast
maximum file unit number (this allows for 9000 open files)
integer(i4b), parameter namedboundflag
named bound flag
integer(i4b), parameter iustart
starting file unit number
integer(i4b), parameter lenbigline
maximum length of a big line
integer(i4b), parameter lenauxname
maximum length of a aux variable
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
This module defines variable data types.
Store and issue logging messages to output units.
subroutine, public write_message(text, iunit, fmt, skipbefore, skipafter, advance)
Write a message to an output unit.
character(len=20), dimension(2) action
This module contains simulation methods.
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
integer(i4b) iunext
next file unit number to assign
integer(i4b) isim_mode
simulation mode