29 subroutine openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, &
30 filstat_opt, mode_opt)
35 integer(I4B),
intent(inout) :: iu
36 integer(I4B),
intent(in) ::
iout
37 character(len=*),
intent(in) :: fname
38 character(len=*),
intent(in) :: ftype
39 character(len=*),
intent(in),
optional :: fmtarg_opt
40 character(len=*),
intent(in),
optional :: accarg_opt
41 character(len=*),
intent(in),
optional :: filstat_opt
42 integer(I4B),
intent(in),
optional :: mode_opt
44 character(len=20) :: fmtarg
45 character(len=20) :: accarg
46 character(len=20) :: filstat
47 character(len=20) :: filact
53 character(len=*),
parameter :: fmtmsg = &
54 "(1x,/1x,'OPENED ',a,/1x,'FILE TYPE:',a,' UNIT ',I4,3x,'STATUS:',a,/ &
55 & 1x,'FORMAT:',a,3x,'ACCESS:',a/1x,'ACTION:',a/)"
56 character(len=*),
parameter :: fmtmsg2 = &
57 "(1x,/1x,'DID NOT OPEN ',a,/)"
60 if (
present(mode_opt))
then
69 write (
iout, fmtmsg2) trim(fname)
79 if (
present(fmtarg_opt))
then
83 if (
present(accarg_opt))
then
87 if (
present(filstat_opt))
then
91 if (filstat ==
'OLD')
then
98 iflen = len_trim(fname)
106 inquire (file=fname(1:iflen), number=iuop)
107 open (unit=iu, file=fname(1:iflen),
form=fmtarg,
access=accarg, &
108 status=filstat,
action=filact, iostat=ivar)
112 write (
errmsg,
'(3a,1x,i0,a)') &
113 'Could not open "', fname(1:iflen),
'" on unit', iu,
'.'
115 write (
errmsg,
'(a,1x,a,1x,i0,a)') &
116 trim(
errmsg),
'File already open on unit', iuop,
'.'
118 write (
errmsg,
'(a,1x,a,1x,a,a)') &
119 trim(
errmsg),
'Specified file status', trim(filstat),
'.'
120 write (
errmsg,
'(a,1x,a,1x,a,a)') &
121 trim(
errmsg),
'Specified file format', trim(fmtarg),
'.'
122 write (
errmsg,
'(a,1x,a,1x,a,a)') &
123 trim(
errmsg),
'Specified file access', trim(accarg),
'.'
124 write (
errmsg,
'(a,1x,a,1x,a,a)') &
125 trim(
errmsg),
'Specified file action', trim(filact),
'.'
126 write (
errmsg,
'(a,1x,a,1x,i0,a)') &
127 trim(
errmsg),
'IOSTAT error number', ivar,
'.'
128 write (
errmsg,
'(a,1x,a)') &
129 trim(
errmsg),
'STOP EXECUTION in subroutine openfile().'
135 write (
iout, fmtmsg) fname(1:iflen), ftype, iu, filstat, fmtarg, &
149 integer(I4B),
intent(inout) :: iu
155 inquire (unit=i, opened=opened)
156 if (.not. opened)
exit
172 integer(I4B) :: iunit
186 integer(I4B),
intent(inout) :: iounit
187 integer(I4B),
intent(in) :: errunit
188 character(len=*),
intent(in) :: description
190 write (
errmsg,
'(a,1x,i0)') &
191 trim(description)//
' already assigned at unit: ', iounit
205 character(len=*),
intent(inout) :: word
208 integer(I4B) :: idiff
213 idiff = ichar(
'a') - ichar(
'A')
217 IF (word(k:k) >=
'a' .and. word(k:k) <=
'z') &
218 word(k:k) = char(ichar(word(k:k)) - idiff)
229 character(len=*) :: word
231 integer(I4B) :: idiff, k, l
235 idiff = ichar(
'a') - ichar(
'A')
239 if (word(k:k) >=
'A' .and. word(k:k) <=
'Z')
then
240 word(k:k) = char(ichar(word(k:k)) + idiff)
253 character(len=LINELENGTH),
intent(inout) :: name
254 integer(I4B),
intent(in) ::
proc_id
256 character(len=LINELENGTH) :: name_local
257 character(len=LINELENGTH) :: name_processor
258 character(len=LINELENGTH) :: extension_local
259 integer(I4B) :: ipos0
260 integer(I4B) :: ipos1
264 ipos0 = index(name_local,
".", back=.true.)
265 ipos1 = len_trim(name)
267 write (extension_local,
'(a)') name(ipos0:ipos1)
272 write (name_processor,
'(a,a,i0,a)') &
273 name(1:ipos0 - 1),
'.p',
proc_id, trim(adjustl(extension_local))
274 name = name_processor
283 subroutine uwword(line, icol, ilen, ncode, c, n, r, fmt, alignment, sep)
286 character(len=*),
intent(inout) :: line
287 integer(I4B),
intent(inout) :: icol
288 integer(I4B),
intent(in) :: ilen
289 integer(I4B),
intent(in) :: ncode
290 character(len=*),
intent(in) :: c
291 integer(I4B),
intent(in) :: n
292 real(dp),
intent(in) :: r
293 character(len=*),
optional,
intent(in) :: fmt
294 integer(I4B),
optional,
intent(in) :: alignment
295 character(len=*),
optional,
intent(in) :: sep
297 character(len=16) :: cfmt
298 character(len=16) :: cffmt
299 character(len=ILEN) :: cval
300 integer(I4B) :: ialign
302 integer(I4B) :: ispace
303 integer(I4B) :: istop
305 integer(I4B) :: ireal
312 if (
present(fmt))
then
317 write (cfmt,
'(a,I0,a)')
'(a', ilen,
')'
319 write (cfmt,
'(a,I0,a)')
'(I', ilen,
')'
323 write (cfmt,
'(a,I0,a,I0,a)')
'(1PG', ilen,
'.', i,
')'
329 write (cffmt,
'(a,I0,a)')
'(a', ilen,
')'
331 if (
present(alignment))
then
344 else if (ncode ==
tabreal)
then
349 if (len_trim(adjustl(cval)) > ilen)
then
352 cval = trim(adjustl(cval))
356 ispace = (ilen - i) / 2
359 cval =
' '//trim(adjustl(cval))
361 cval = trim(adjustl(cval))
364 cval = repeat(
' ', ispace)//trim(cval)
366 else if (ialign ==
tableft)
then
367 cval = trim(adjustl(cval))
369 cval =
' '//trim(adjustl(cval))
379 istop = icol + ilen - 1
382 write (line(icol:istop), cffmt) cval
386 if (
present(sep))
then
389 write (line(icol:istop),
'(a)') sep
422 subroutine urword(line, icol, istart, istop, ncode, n, r, iout, in)
424 character(len=*) :: line
425 integer(I4B),
intent(inout) :: icol
426 integer(I4B),
intent(inout) :: istart
427 integer(I4B),
intent(inout) :: istop
428 integer(I4B),
intent(in) :: ncode
429 integer(I4B),
intent(inout) :: n
430 real(dp),
intent(inout) :: r
431 integer(I4B),
intent(in) ::
iout
432 integer(I4B),
intent(in) :: in
434 character(len=20) string
436 character(len=1) charend
437 character(len=200) :: msg
438 character(len=linelength) :: msg_line
440 character(len=*),
parameter :: fmtmsgout1 = &
441 "(1X,'FILE UNIT ',I4,' : ERROR CONVERTING ""',A, &
442 & '"" TO ',A,' IN LINE:')"
443 character(len=*),
parameter :: fmtmsgout2 =
"(1x, &
444 & 'KEYBOARD INPUT : ERROR CONVERTING ""',a,'"" TO ',a,' IN LINE:')"
445 character(len=*),
parameter :: fmtmsgout3 =
"('File unit ', &
446 & I0,': Error converting ""',a,'"" to ',A,' in following line:')"
447 character(len=*),
parameter :: fmtmsgout4 = &
448 "('Keyboard input: Error converting ""',a, &
449 & '"" to ',A,' in following line:')"
457 line(linlen:linlen) =
' '
461 if (icol < 1 .or. icol > linlen)
go to 100
466 if (line(i:i) /=
' ' .and. line(i:i) /=
',' .and. &
467 line(i:i) /= tab)
go to 20
47520
if (line(i:i) == char(34) .or. line(i:i) == char(39))
then
476 if (line(i:i) == char(34))
then
482 if (i <= linlen)
then
484 if (line(j:j) == charend)
go to 40
491 if (line(j:j) ==
' ' .or. line(j:j) ==
',' .or. &
492 line(j:j) == tab)
go to 40
510 idiff = ichar(
'a') - ichar(
'A')
512 if (line(k:k) >=
'a' .and. line(k:k) <=
'z') &
513 line(k:k) = char(ichar(line(k:k)) - idiff)
519100
if (ncode == 2 .or. ncode == 3)
then
520 l = istop - istart + 1
522 if (istart > linlen)
then
525 if (ncode == 2) n = 0
526 if (ncode == 3) r =
dzero
528 if (ncode == 2)
read (line(istart:istop), *, err=200) n
529 if (ncode == 3)
read (line(istart:istop), *, err=200) r
535200
if (ncode == 3)
then
536 string =
'a real number'
539 string =
'an integer'
547 line(linlen + 1:linlen + 1) =
'E'
551 else if (
iout > 0)
then
553 write (msg_line, fmtmsgout1) in, line(istart:istop), string(1:l)
555 write (msg_line, fmtmsgout2) line(istart:istop), string(1:l)
563 write (msg_line, fmtmsgout1) in, line(istart:istop), string(1:l)
565 write (msg_line, fmtmsgout2) line(istart:istop), string(1:l)
574 write (msg, fmtmsgout3) in, line(istart:istop), trim(string)
576 write (msg, fmtmsgout4) line(istart:istop), trim(string)
586 subroutine ulstlb(iout, label, caux, ncaux, naux)
588 character(len=*) :: label
589 character(len=16) :: caux(ncaux)
591 character(len=400) buf
593 character(len=1) dash(400)
596 character(len=*),
parameter :: fmtmsgout1 =
"(1x, a)"
597 character(len=*),
parameter :: fmtmsgout2 =
"(1x, 400a)"
603 nbuf = len(label) + 9
608 buf(n1:nbuf) = caux(i)
613 write (
iout, fmtmsgout1) buf(1:nbuf)
616 write (
iout, fmtmsgout2) (dash(j), j=1, nbuf)
624 subroutine ubdsv4(kstp, kper, text, naux, auxtxt, ibdchn, &
625 & ncol, nrow, nlay, nlist, iout, delt, pertim, totim)
627 character(len=16) :: text
628 character(len=16),
dimension(:) :: auxtxt
629 real(dp),
intent(in) :: delt, pertim, totim
631 character(len=*),
parameter :: fmt = &
632 &
"(1X,'UBDSV4 SAVING ',A16,' ON UNIT',I7,' AT TIME STEP',I7,"// &
633 &
"', STRESS PERIOD',I7)"
636 if (
iout > 0)
write (
iout, fmt) text, ibdchn, kstp, kper
637 write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
638 write (ibdchn) 5, delt, pertim, totim
639 write (ibdchn) naux + 1
640 if (naux > 0)
write (ibdchn) (auxtxt(n), n=1, naux)
647 subroutine ubdsvb(ibdchn, icrl, q, val, nvl, naux, laux)
649 real(dp),
dimension(nvl) :: val
655 write (ibdchn) icrl, q, (val(n), n=laux, n2)
657 write (ibdchn) icrl, q
670 subroutine ucolno(nlbl1, nlbl2, nspace, ncpl, ndig, iout)
672 character(len=1) :: dot, space, dg, bf
673 dimension :: bf(1000), dg(10)
675 data dg(1), dg(2), dg(3), dg(4), dg(5), dg(6), dg(7), dg(8), dg(9), dg(10)/ &
676 &
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'/
677 data dot, space/
'.',
' '/
679 character(len=*),
parameter :: fmtmsgout1 =
"(1x)"
680 character(len=*),
parameter :: fmtmsgout2 =
"(1x, 1000a1)"
684 if (
iout <= 0)
return
685 write (
iout, fmtmsgout1)
687 nlbl = nlbl2 - nlbl1 + 1
690 if (nlbl < ncpl) n = ncpl
691 ntot = nspace + n * ndig
693 if (ntot > 1000)
go to 50
694 nwrap = (nlbl - 1) / ncpl + 1
710 if (j2 > nlbl2) j2 = nlbl2
718 if (i2 == 0)
go to 30
720 i2 = i2 - i3 * 10 + 1
722 if (i3 == 0)
go to 30
724 i3 = i3 - i4 * 10 + 1
726 if (i4 == 0)
go to 30
731 bf(nbf - 3) = dg(i4 + 1)
736 write (
iout, fmtmsgout2) (bf(i), i=1, nbf)
742 if (ntot > 1000) ntot = 1000
743 write (
iout, fmtmsgout2) (dot, i=1, ntot)
748 subroutine ulaprw(buf, text, kstp, kper, ncol, nrow, ilay, iprn, iout)
750 character(len=16) :: text
751 real(dp),
dimension(ncol, nrow) :: buf
753 character(len=*),
parameter :: fmtmsgout1 = &
754 &
"('1', /2x, a, ' IN LAYER ',I3,' AT END OF TIME STEP ',I3, &
755 & ' IN STRESS PERIOD ',I4/2x,75('-'))"
756 character(len=*),
parameter :: fmtmsgout2 = &
757 &
"('1',/1x,A,' FOR CROSS SECTION AT END OF TIME STEP',I3, &
758 & ' IN STRESS PERIOD ',I4/1x,79('-'))"
759 character(len=*),
parameter :: fmtg10 = &
760 &
"(1X,I3,2X,1PG10.3,10(1X,G10.3):/(5X,11(1X,G10.3)))"
761 character(len=*),
parameter :: fmtg13 = &
762 &
"(1x,I3,2x,1PG13.6,8(1x,G13.6):/(5x,9(1x,G13.6)))"
763 character(len=*),
parameter :: fmtf7pt1 = &
764 &
"(1x,I3,1x,15(1x,F7.1):/(5x,15(1x,F7.1)))"
765 character(len=*),
parameter :: fmtf7pt2 = &
766 &
"(1x,I3,1x,15(1x,F7.2):/(5x,15(1x,F7.2)))"
767 character(len=*),
parameter :: fmtf7pt3 = &
768 &
"(1x,I3,1x,15(1x,F7.3):/(5x,15(1x,F7.3)))"
769 character(len=*),
parameter :: fmtf7pt4 = &
770 &
"(1x,I3,1x,15(1x,F7.4):/(5x,15(1x,F7.4)))"
771 character(len=*),
parameter :: fmtf5pt0 = &
772 &
"(1x,I3,1x,20(1x,F5.0):/(5x,20(1x,F5.0)))"
773 character(len=*),
parameter :: fmtf5pt1 = &
774 &
"(1x,I3,1x,20(1x,F5.1):/(5x,20(1x,F5.1)))"
775 character(len=*),
parameter :: fmtf5pt2 = &
776 &
"(1x,I3,1x,20(1x,F5.2):/(5x,20(1x,F5.2)))"
777 character(len=*),
parameter :: fmtf5pt3 = &
778 &
"(1x,I3,1x,20(1x,F5.3):/(5x,20(1x,F5.3)))"
779 character(len=*),
parameter :: fmtf5pt4 = &
780 &
"(1x,I3,1x,20(1x,F5.4):/(5x,20(1x,F5.4)))"
781 character(len=*),
parameter :: fmtg11 = &
782 &
"(1x,I3,2x,1PG11.4,9(1x,G11.4):/(5x,10(1x,G11.4)))"
783 character(len=*),
parameter :: fmtf6pt0 = &
784 &
"(1x,I3,1x,10(1x,F6.0):/(5X,10(1x,F6.0)))"
785 character(len=*),
parameter :: fmtf6pt1 = &
786 &
"(1x,I3,1x,10(1x,F6.1):/(5x,10(1x,F6.1)))"
787 character(len=*),
parameter :: fmtf6pt2 = &
788 &
"(1x,I3,1x,10(1x,F6.2):/(5x,10(1x,F6.2)))"
789 character(len=*),
parameter :: fmtf6pt3 = &
790 &
"(1x,I3,1x,10(1x,F6.3):/(5x,10(1x,F6.3)))"
791 character(len=*),
parameter :: fmtf6pt4 = &
792 &
"(1x,I3,1x,10(1x,F6.4):/(5x,10(1x,F6.4)))"
793 character(len=*),
parameter :: fmtf6pt5 = &
794 &
"(1x,I3,1x,10(1x,F6.5):/(5x,10(1x,F6.5)))"
795 character(len=*),
parameter :: fmtg12 = &
796 &
"(1x,I3,2x,1PG12.5,4(1x,G12.5):/(5x,5(1x,G12.5)))"
797 character(len=*),
parameter :: fmtg11pt4 = &
798 &
"(1x,I3,2x,1PG11.4,5(1x,G11.4):/(5x,6(1x,G11.4)))"
799 character(len=*),
parameter :: fmtg9pt2 = &
800 &
"(1x,I3,2x,1PG9.2,6(1x,G9.2):/(5x,7(1x,G9.2)))"
802 if (
iout <= 0)
return
805 write (
iout, fmtmsgout1) text, ilay, kstp, kper
806 else if (ilay < 0)
then
807 write (
iout, fmtmsgout2) text, kstp, kper
812 if (ip < 1 .or. ip > 21) ip = 12
815 if (ip == 1)
call ucolno(1, ncol, 0, 11, 11,
iout)
816 if (ip == 2)
call ucolno(1, ncol, 0, 9, 14,
iout)
817 if (ip >= 3 .and. ip <= 6)
call ucolno(1, ncol, 3, 15, 8,
iout)
818 if (ip >= 7 .and. ip <= 11)
call ucolno(1, ncol, 3, 20, 6,
iout)
819 if (ip == 12)
call ucolno(1, ncol, 0, 10, 12,
iout)
820 if (ip >= 13 .and. ip <= 18)
call ucolno(1, ncol, 3, 10, 7,
iout)
821 if (ip == 19)
call ucolno(1, ncol, 0, 5, 13,
iout)
822 if (ip == 20)
call ucolno(1, ncol, 0, 6, 12,
iout)
823 if (ip == 21)
call ucolno(1, ncol, 0, 7, 10,
iout)
831 write (
iout, fmtg10) i, (buf(j, i), j=1, ncol)
835 write (
iout, fmtg13) i, (buf(j, i), j=1, ncol)
839 write (
iout, fmtf7pt1) i, (buf(j, i), j=1, ncol)
843 write (
iout, fmtf7pt2) i, (buf(j, i), j=1, ncol)
847 write (
iout, fmtf7pt3) i, (buf(j, i), j=1, ncol)
851 write (
iout, fmtf7pt4) i, (buf(j, i), j=1, ncol)
855 write (
iout, fmtf5pt0) i, (buf(j, i), j=1, ncol)
859 write (
iout, fmtf5pt1) i, (buf(j, i), j=1, ncol)
863 write (
iout, fmtf5pt2) i, (buf(j, i), j=1, ncol)
867 write (
iout, fmtf5pt3) i, (buf(j, i), j=1, ncol)
871 write (
iout, fmtf5pt4) i, (buf(j, i), j=1, ncol)
875 write (
iout, fmtg11) i, (buf(j, i), j=1, ncol)
879 write (
iout, fmtf6pt0) i, (buf(j, i), j=1, ncol)
883 write (
iout, fmtf6pt1) i, (buf(j, i), j=1, ncol)
887 write (
iout, fmtf6pt2) i, (buf(j, i), j=1, ncol)
891 write (
iout, fmtf6pt3) i, (buf(j, i), j=1, ncol)
895 write (
iout, fmtf6pt4) i, (buf(j, i), j=1, ncol)
899 write (
iout, fmtf6pt5) i, (buf(j, i), j=1, ncol)
903 write (
iout, fmtg12) i, (buf(j, i), j=1, ncol)
907 write (
iout, fmtg11pt4) i, (buf(j, i), j=1, ncol)
911 write (
iout, fmtg9pt2) i, (buf(j, i), j=1, ncol)
922 subroutine ulasav(buf, text, kstp, kper, pertim, totim, ncol, nrow, &
925 character(len=16) :: text
926 real(dp),
dimension(ncol, nrow) :: buf
927 real(dp) :: pertim, totim
930 write (ichn) kstp, kper, pertim, totim, text, ncol, nrow, ilay
934 write (ichn) ((buf(ic, ir), ic=1, ncol), ir=1, nrow)
943 subroutine ubdsv1(kstp, kper, text, ibdchn, buff, ncol, nrow, nlay, iout, &
947 integer(I4B),
intent(in) :: kstp
948 integer(I4B),
intent(in) :: kper
949 character(len=*),
intent(in) :: text
950 integer(I4B),
intent(in) :: ibdchn
951 real(dp),
dimension(:),
intent(in) :: buff
952 integer(I4B),
intent(in) :: ncol
953 integer(I4B),
intent(in) :: nrow
954 integer(I4B),
intent(in) :: nlay
955 integer(I4B),
intent(in) ::
iout
956 real(dp),
intent(in) :: delt
957 real(dp),
intent(in) :: pertim
958 real(dp),
intent(in) :: totim
960 character(len=*),
parameter :: fmt = &
961 &
"(1X,'UBDSV1 SAVING ',A16,' ON UNIT',I7,' AT TIME STEP',I7,"// &
962 &
"', STRESS PERIOD',I7)"
965 if (
iout > 0)
write (
iout, fmt) text, ibdchn, kstp, kper
966 write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
967 write (ibdchn) 1, delt, pertim, totim
979 subroutine ubdsv06(kstp, kper, text, modelnam1, paknam1, modelnam2, paknam2, &
980 ibdchn, naux, auxtxt, ncol, nrow, nlay, nlist, iout, &
984 integer(I4B),
intent(in) :: kstp
985 integer(I4B),
intent(in) :: kper
986 character(len=*),
intent(in) :: text
987 character(len=*),
intent(in) :: modelnam1
988 character(len=*),
intent(in) :: paknam1
989 character(len=*),
intent(in) :: modelnam2
990 character(len=*),
intent(in) :: paknam2
991 integer(I4B),
intent(in) :: naux
992 character(len=16),
dimension(:),
intent(in) :: auxtxt
993 integer(I4B),
intent(in) :: ibdchn
994 integer(I4B),
intent(in) :: ncol
995 integer(I4B),
intent(in) :: nrow
996 integer(I4B),
intent(in) :: nlay
997 integer(I4B),
intent(in) :: nlist
998 integer(I4B),
intent(in) ::
iout
999 real(dp),
intent(in) :: delt
1000 real(dp),
intent(in) :: pertim
1001 real(dp),
intent(in) :: totim
1005 character(len=*),
parameter :: fmt = &
1006 &
"(1X,'UBDSV06 SAVING ',A16,' IN MODEL ',A16,' PACKAGE ',A16,"// &
1007 &
"'CONNECTED TO MODEL ',A16,' PACKAGE ',A16,"// &
1008 &
"' ON UNIT',I7,' AT TIME STEP',I7,', STRESS PERIOD',I7)"
1011 if (
iout > 0)
write (
iout, fmt) text, modelnam1, paknam1, modelnam2, &
1012 paknam2, ibdchn, kstp, kper
1013 write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
1014 write (ibdchn) 6, delt, pertim, totim
1015 write (ibdchn) modelnam1
1016 write (ibdchn) paknam1
1017 write (ibdchn) modelnam2
1018 write (ibdchn) paknam2
1019 write (ibdchn) naux + 1
1020 if (naux > 0)
write (ibdchn) (auxtxt(n), n=1, naux)
1021 write (ibdchn) nlist
1031 integer(I4B),
intent(in) :: ibdchn
1032 integer(I4B),
intent(in) :: n
1033 real(dp),
intent(in) :: q
1034 integer(I4B),
intent(in) :: naux
1035 real(dp),
dimension(naux),
intent(in) :: aux
1041 write (ibdchn) n, q, (aux(nn), nn=1, naux)
1051 subroutine ubdsvd(ibdchn, n, n2, q, naux, aux)
1054 integer(I4B),
intent(in) :: ibdchn
1055 integer(I4B),
intent(in) :: n
1056 integer(I4B),
intent(in) :: n2
1057 real(dp),
intent(in) :: q
1058 integer(I4B),
intent(in) :: naux
1059 real(dp),
dimension(naux),
intent(in) :: aux
1065 write (ibdchn) n, n2, q, (aux(nn), nn=1, naux)
1067 write (ibdchn) n, n2, q
1076 character(len=*),
intent(in) :: word1, word2
1078 character(len=200) :: upword1, upword2
1091 character(len=*),
intent(in) :: str
1092 integer,
intent(in) :: width
1094 character(len=max(len_trim(str), width)) :: res
1104 character(len=LINELENGTH) :: line
1105 character(len=100) :: fname, ac, act, fm, frm, seq, unf
1107 character(len=*),
parameter :: fmta = &
1108 &
"('unit:',i4,' name:',a,' access:',a,' action:',a)"
1109 character(len=*),
parameter :: fmtb = &
1110 &
"(' formatted:',a,' sequential:',a,' unformatted:',a,' form:',a)"
1113 inquire (unit=iu, name=fname, access=ac, action=act, formatted=fm, &
1114 sequential=seq, unformatted=unf, form=frm)
1117 write (line, fmta) iu, trim(fname), trim(ac), trim(act)
1119 write (line, fmtb) trim(fm), trim(seq), trim(unf), trim(frm)
1134 character(len=*),
intent(in) :: line
1135 integer(I4B),
intent(inout) :: nwords
1136 character(len=*),
allocatable,
dimension(:),
intent(inout) :: words
1137 integer(I4B),
intent(in),
optional :: inunit
1138 character(len=*),
intent(in),
optional :: filename
1140 integer(I4B) :: i, idum, istart, istop, linelen, lloc
1144 if (
allocated(words))
then
1151 allocate (words(nwords))
1156 call urword(line, lloc, istart, istop, 0, idum, rdum, 0, 0)
1157 words(i) = line(istart:istop)
1163 subroutine ulaprufw(ncol, nrow, kstp, kper, ilay, iout, buf, text, userfmt, &
1164 nvalues, nwidth, editdesc)
1167 integer(I4B),
intent(in) :: ncol, nrow, kstp, kper, ilay,
iout
1168 real(dp),
dimension(ncol, nrow),
intent(in) :: buf
1169 character(len=*),
intent(in) :: text
1170 character(len=*),
intent(in) :: userfmt
1171 integer(I4B),
intent(in) :: nvalues, nwidth
1172 character(len=1),
intent(in) :: editdesc
1174 integer(I4B) :: i, j, nspaces
1176 character(len=*),
parameter :: fmtmsgout1 = &
1177 "('1',/2X,A,' IN LAYER ',I3,' AT END OF TIME STEP ',I3, &
1178& ' IN STRESS PERIOD ',I4/2X,75('-'))"
1179 character(len=*),
parameter :: fmtmsgout2 = &
1180 "('1',/1X,A,' FOR CROSS SECTION AT END OF TIME STEP',I3, &
1181& ' IN STRESS PERIOD ',I4/1X,79('-'))"
1183 if (
iout <= 0)
return
1186 write (
iout, fmtmsgout1) trim(text), ilay, kstp, kper
1187 else if (ilay < 0)
then
1188 write (
iout, fmtmsgout2) trim(text), kstp, kper
1193 if (editdesc ==
'F') nspaces = 3
1194 call ucolno(1, ncol, nspaces, nvalues, nwidth + 1,
iout)
1198 write (
iout, userfmt) i, (buf(j, i), j=1, ncol)
1221 integer(I4B),
intent(in) :: iu
1222 logical,
intent(out) :: eof
1223 character(len=:),
allocatable :: astring
1225 integer(I4B) :: isize, istat
1226 character(len=256) :: buffer
1227 character(len=1000) :: ermsg, fname
1228 character(len=7) :: fmtd
1231 character(len=*),
parameter :: fmterrmsg1 = &
1232 &
"('Error in read_line: File ',i0,' is not open.')"
1233 character(len=*),
parameter :: fmterrmsg2 = &
1234 &
"('Error in read_line: Attempting to read text ' // &
1235 & 'from unformatted file: ""',a,'""')"
1236 character(len=*),
parameter :: fmterrmsg3 = &
1237 &
"('Error reading from file ""',a,'"" opened on unit ',i0, &
1238 & ' in read_line.')"
1243 read (iu,
'(a)', advance=
'NO', iostat=istat, size=isize,
end=99) buffer
1247 ermsg =
'Programming error in call to read_line: '// &
1248 'Attempt to read from unit number <= 0'
1250 inquire (unit=iu, opened=lop, name=fname, formatted=fmtd)
1252 write (ermsg, fmterrmsg1) iu
1253 elseif (fmtd ==
'NO' .or. fmtd ==
'UNKNOWN')
then
1254 write (ermsg, fmterrmsg2) trim(fname)
1256 write (ermsg, fmterrmsg3) trim(fname), iu
1262 astring = astring//buffer(:isize)
1279 character(len=*),
intent(in) :: pathname
1280 character(len=*),
intent(out) :: filename
1282 integer(I4B) :: i, istart, istop, lenpath
1283 character(len=1) :: fs =
'/'
1284 character(len=1) :: bs =
'\'
1287 lenpath = len_trim(pathname)
1290 loop:
do i = lenpath, 1, -1
1291 if (pathname(i:i) == fs .or. pathname(i:i) == bs)
then
1292 if (i == istop)
then
1300 if (istop >= istart)
then
1301 filename = pathname(istart:istop)
1315 character(len=*),
intent(inout) :: line
1316 integer(I4B),
intent(inout) :: icol, istart, istop
1317 integer(I4B),
intent(out) :: idnum
1318 character(len=LENBOUNDNAME),
intent(out) :: bndname
1320 integer(I4B) :: istat, ndum, ncode = 0
1323 call urword(line, icol, istart, istop, ncode, ndum, rdum, 0, 0)
1324 read (line(istart:istop), *, iostat=istat) ndum
1325 if (istat == 0)
then
1329 idnum = namedboundflag
1330 bndname = line(istart:istop)
1337 subroutine urdaux(naux, inunit, iout, lloc, istart, istop, auxname, line, text)
1344 integer(I4B),
intent(inout) :: naux
1345 integer(I4B),
intent(in) :: inunit
1346 integer(I4B),
intent(in) :: iout
1347 integer(I4B),
intent(inout) :: lloc
1348 integer(I4B),
intent(inout) :: istart
1349 integer(I4B),
intent(inout) :: istop
1350 character(len=LENAUXNAME),
allocatable,
dimension(:),
intent(inout) :: auxname
1351 character(len=*),
intent(inout) :: line
1352 character(len=*),
intent(in) :: text
1354 integer(I4B) :: n, linelen
1355 integer(I4B) :: iauxlen
1360 write (errmsg,
'(a)')
'Auxiliary variables already specified. '// &
1361 &
'Auxiliary variables must be specified on one line in the '// &
1363 call store_error(errmsg)
1364 call store_error_unit(inunit)
1367 call urword(line, lloc, istart, istop, 1, n, rval, iout, inunit)
1368 if (istart >= linelen)
exit auxloop
1369 iauxlen = istop - istart + 1
1371 write (errmsg,
'(a, a, a, i0, a, i0, a)') &
1372 'Found auxiliary variable (', line(istart:istop), &
1373 ') with a name of size ', iauxlen, &
1374 '. Auxiliary variable names must be len than or equal&
1376 call store_error(errmsg)
1377 call store_error_unit(inunit)
1381 auxname(naux) = line(istart:istop)
1383 write (iout,
"(4X,'AUXILIARY ',a,' VARIABLE: ',A)") &
1384 trim(adjustl(text)), auxname(naux)
1407 subroutine print_format(linein, cdatafmp, editdesc, nvaluesp, nwidthp, inunit)
1409 character(len=*),
intent(in) :: linein
1410 character(len=*),
intent(inout) :: cdatafmp
1411 character(len=*),
intent(inout) :: editdesc
1412 integer(I4B),
intent(inout) :: nvaluesp
1413 integer(I4B),
intent(inout) :: nwidthp
1414 integer(I4B),
intent(in) :: inunit
1416 character(len=len(linein)) :: line
1417 character(len=20),
dimension(:),
allocatable :: words
1418 character(len=100) :: ermsg
1419 integer(I4B) :: ndigits = 0, nwords = 0
1420 integer(I4B) :: i, ierr
1425 call parseline(line, nwords, words, inunit)
1429 if (editdesc ==
'I') isint = .true.
1432 if (nwords < 1)
then
1433 ermsg =
'Could not build PRINT_FORMAT from line'//trim(line)
1434 call store_error(trim(ermsg))
1435 ermsg =
'Syntax is: COLUMNS <columns> WIDTH <width> DIGITS &
1437 call store_error(trim(ermsg))
1438 call store_error_unit(inunit)
1441 ermsg =
'Error setting PRINT_FORMAT. Syntax is incorrect in line:'
1442 if (nwords >= 4)
then
1443 if (.not.
same_word(words(1),
'COLUMNS')) ierr = 1
1444 if (.not.
same_word(words(3),
'WIDTH')) ierr = 1
1447 read (words(2), *, iostat=ierr) nvaluesp
1450 read (words(4), *, iostat=ierr) nwidthp
1456 call store_error(ermsg)
1457 call store_error(line)
1458 ermsg =
'Syntax is: COLUMNS <columns> WIDTH <width> &
1459 &DIGITS <digits> <format>'
1460 call store_error(trim(ermsg))
1461 call store_error_unit(inunit)
1465 if (.not. isint)
then
1467 if (nwords >= 5)
then
1468 if (.not.
same_word(words(5),
'DIGITS')) ierr = 1
1470 read (words(6), *, iostat=ierr) ndigits
1481 if (i <= nwords)
then
1483 select case (words(i))
1484 case (
'EXPONENTIAL')
1497 ermsg =
'Error in format specification. Unrecognized option: '//words(i)
1498 call store_error(ermsg)
1499 ermsg =
'Valid values are EXPONENTIAL, FIXED, GENERAL, or SCIENTIFIC.'
1500 call store_error(ermsg)
1501 call store_error_unit(inunit)
1508 call store_error(ermsg)
1509 call store_error(line)
1510 call store_error_unit(inunit)
1514 select case (editdesc)
1519 case (
'E',
'G',
'S')
1529 integer(I4B),
intent(in) :: nvalsp, nwidp, ndig
1530 character(len=*),
intent(inout) :: outfmt
1531 logical,
intent(in),
optional :: prowcolnum
1533 character(len=8) :: cvalues, cwidth, cdigits
1534 character(len=60) :: ufmt
1535 logical :: prowcolnumlocal
1537 character(len=*),
parameter :: fmtndig =
"(i8)"
1539 if (
present(prowcolnum))
then
1540 prowcolnumlocal = prowcolnum
1542 prowcolnumlocal = .true.
1546 write (cdigits, fmtndig) ndig
1547 cdigits = adjustl(cdigits)
1550 write (cvalues, fmtndig) nvalsp
1551 cvalues = adjustl(cvalues)
1552 write (cwidth, fmtndig) nwidp
1553 cwidth = adjustl(cwidth)
1554 if (prowcolnumlocal)
then
1560 ufmt = trim(ufmt)//cvalues
1561 ufmt = trim(ufmt)//
'(1x,f'
1562 ufmt = trim(ufmt)//cwidth
1563 ufmt = trim(ufmt)//
'.'
1564 ufmt = trim(ufmt)//cdigits
1565 ufmt = trim(ufmt)//
'):/(5x,'
1566 ufmt = trim(ufmt)//cvalues
1567 ufmt = trim(ufmt)//
'(1x,f'
1568 ufmt = trim(ufmt)//cwidth
1569 ufmt = trim(ufmt)//
'.'
1570 ufmt = trim(ufmt)//cdigits
1571 ufmt = trim(ufmt)//
')))'
1580 integer(I4B),
intent(in) :: nvalsp, nwidp, ndig
1581 character(len=*),
intent(in) :: editdesc
1582 character(len=*),
intent(inout) :: outfmt
1583 logical,
intent(in),
optional :: prowcolnum
1585 character(len=8) :: cvalues, cwidth, cdigits
1586 character(len=60) :: ufmt
1587 logical :: prowcolnumlocal
1589 character(len=*),
parameter :: fmtndig =
"(i8)"
1591 if (
present(prowcolnum))
then
1592 prowcolnumlocal = prowcolnum
1594 prowcolnumlocal = .true.
1598 write (cdigits, fmtndig) ndig
1599 cdigits = adjustl(cdigits)
1601 write (cwidth, fmtndig) nwidp
1602 cwidth = adjustl(cwidth)
1604 write (cvalues, fmtndig) (nvalsp - 1)
1605 cvalues = adjustl(cvalues)
1606 if (prowcolnumlocal)
then
1607 ufmt =
'(1x,i3,2x,1p,'//editdesc
1609 ufmt =
'(6x,1p,'//editdesc
1611 ufmt = trim(ufmt)//cwidth
1612 ufmt = trim(ufmt)//
'.'
1613 ufmt = trim(ufmt)//cdigits
1614 if (nvalsp > 1)
then
1615 ufmt = trim(ufmt)//
','
1616 ufmt = trim(ufmt)//cvalues
1617 ufmt = trim(ufmt)//
'(1x,'
1618 ufmt = trim(ufmt)//editdesc
1619 ufmt = trim(ufmt)//cwidth
1620 ufmt = trim(ufmt)//
'.'
1621 ufmt = trim(ufmt)//cdigits
1622 ufmt = trim(ufmt)//
')'
1625 ufmt = trim(ufmt)//
':/(5x,'
1626 write (cvalues, fmtndig) nvalsp
1627 cvalues = adjustl(cvalues)
1628 ufmt = trim(ufmt)//cvalues
1629 ufmt = trim(ufmt)//
'(1x,'
1630 ufmt = trim(ufmt)//editdesc
1631 ufmt = trim(ufmt)//cwidth
1632 ufmt = trim(ufmt)//
'.'
1633 ufmt = trim(ufmt)//cdigits
1634 ufmt = trim(ufmt)//
')))'
1643 integer(I4B),
intent(in) :: nvalsp, nwidp
1644 character(len=*),
intent(inout) :: outfmt
1645 logical,
intent(in),
optional :: prowcolnum
1647 character(len=8) :: cvalues, cwidth
1648 character(len=60) :: ufmt
1649 logical :: prowcolnumlocal
1651 character(len=*),
parameter :: fmtndig =
"(i8)"
1653 if (
present(prowcolnum))
then
1654 prowcolnumlocal = prowcolnum
1656 prowcolnumlocal = .true.
1660 write (cvalues, fmtndig) nvalsp
1661 cvalues = adjustl(cvalues)
1662 write (cwidth, fmtndig) nwidp
1663 cwidth = adjustl(cwidth)
1664 if (prowcolnumlocal)
then
1669 ufmt = trim(ufmt)//cvalues
1670 ufmt = trim(ufmt)//
'(1x,i'
1671 ufmt = trim(ufmt)//cwidth
1672 ufmt = trim(ufmt)//
'):/(5x,'
1673 ufmt = trim(ufmt)//cvalues
1674 ufmt = trim(ufmt)//
'(1x,i'
1675 ufmt = trim(ufmt)//cwidth
1676 ufmt = trim(ufmt)//
')))'
1686 character(len=*),
intent(in) :: line
1688 integer(I4B) :: linelen
1689 integer(I4B) :: lloc
1690 integer(I4B) :: istart
1691 integer(I4B) :: istop
1692 integer(I4B) :: idum
1702 call urword(line, lloc, istart, istop, 0, idum, rdum, 0, 0)
1703 if (istart == linelen)
exit
1716 integer(I4B),
intent(in) :: iu
1717 integer(I4B),
intent(in) :: offset
1718 integer(I4B),
intent(in) :: whence
1719 integer(I4B),
intent(inout) :: status
1721 integer(I8B) :: ipos
1722 character(len=20) :: file_action
1724 inquire (unit=iu, size=ipos)
1726 select case (whence)
1734 inquire (unit=iu, pos=ipos)
1735 ipos = ipos + offset
1739 inquire (unit=iu, size=ipos)
1740 ipos = ipos + offset
1746 inquire (unit=iu, action=file_action)
1747 if (trim(file_action) ==
'READ')
then
1748 read (iu, pos=ipos, iostat=status)
1750 write (iu, pos=ipos, iostat=status)
1752 inquire (unit=iu, pos=ipos)
1762 use,
intrinsic :: iso_fortran_env, only: iostat_end
1765 integer(I4B),
intent(in) :: iin
1766 integer(I4B),
intent(in) :: iout
1767 character(len=:),
allocatable,
intent(inout) :: line
1768 integer(I4B),
intent(out) :: ierr
1770 character(len=:),
allocatable :: linetemp
1771 character(len=2),
parameter :: comment =
'//'
1772 character(len=1),
parameter :: tab = char(9)
1773 logical :: iscomment
1774 integer(I4B) :: i, j, l, istart, lsize
1780 if (ierr == iostat_end)
then
1785 elseif (ierr /= 0)
then
1788 write (errmsg, *)
'u9rdcom: Could not read from unit: ', iin
1789 call store_error(errmsg, terminate=.true.)
1791 if (len_trim(line) < 1)
then
1802 allocate (
character(len=lsize) :: linetemp)
1804 if (line(j:j) /=
' ' .and. line(j:j) /=
',' .and. &
1805 line(j:j) /= char(9))
then
1811 linetemp(:) = line(istart:)
1812 line(:) = linetemp(:)
1813 deallocate (linetemp)
1817 select case (line(1:1))
1828 if (line(1:2) == comment) iscomment = .true.
1829 if (len_trim(line) < 1) iscomment = .true.
1834 if (.not. iscomment)
then
1841 if (line(i:i) /=
' ')
then
1846 write (iout,
'(1x,a)') line(1:i)
1860 integer(I4B),
intent(in) :: lun
1861 character(len=:),
intent(out),
allocatable :: line
1862 integer(I4B),
intent(out) :: iostat
1864 integer(I4B),
parameter :: buffer_len = maxcharlen
1865 character(len=buffer_len) :: buffer
1866 character(len=:),
allocatable :: linetemp
1867 integer(I4B) :: size_read, linesize
1868 character(len=1),
parameter :: cr = char(13)
1869 character(len=1),
parameter :: lf = char(10)
1877 read (lun,
'(A)', iostat=iostat, advance=
'no', size=size_read) buffer
1878 if (is_iostat_eor(iostat))
then
1879 linesize = len(line)
1880 deallocate (linetemp)
1881 allocate (
character(len=linesize) :: linetemp)
1882 linetemp(:) = line(:)
1884 allocate (
character(len=linesize + size_read + 1) :: line)
1885 line(:) = linetemp(:)
1886 line(linesize + 1:) = buffer(:size_read)
1887 linesize = len(line)
1888 line(linesize:linesize) =
' '
1891 else if (iostat == 0)
then
1892 linesize = len(line)
1893 deallocate (linetemp)
1894 allocate (
character(len=linesize) :: linetemp)
1895 linetemp(:) = line(:)
1897 allocate (
character(len=linesize + size_read) :: line)
1898 line(:) = linetemp(:)
1899 line(linesize + 1:) = buffer(:size_read)
1906 linesize = len(line)
1907 crlfcheck:
do i = 1, linesize
1908 if (line(i:i) .eq. cr .or. line(i:i) .eq. lf)
then
1909 if (line(i:i) .eq. cr)
then
1910 write (errmsg,
'(a)') &
1911 'get_line: Found an isolated Carriage Return.'
1913 if (line(i:i) .eq. lf)
then
1914 write (errmsg,
'(a)') &
1915 'get_line: Found an isolated Line Feed.'
1917 write (errmsg,
'(a,1x,a,a)') trim(errmsg), &
1918 'Replace with Carriage Return and Line Feed to', &
1919 ' read as two separate lines.'
1920 write (errmsg,
'(a,1x,5a)') trim(errmsg), &
1921 'Line: "', line(1:i - 1),
'|', line(i + 1:linesize),
'"'
1922 call store_error(errmsg, terminate=.false.)
1923 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) iout
file unit number for simulation output
integer(i4b) iunext
next file unit number to assign
integer(i4b) isim_mode
simulation mode