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)
106 open (unit=iu, file=fname(1:iflen), form=fmtarg, access=accarg, &
107 status=filstat,
action=filact, iostat=ivar)
111 write (
errmsg,
'(3a,1x,i0,a)') &
112 'Could not open "', fname(1:iflen),
'" on unit', iu,
'.'
114 write (
errmsg,
'(a,1x,a,1x,i0,a)') &
115 trim(
errmsg),
'File already open on unit', iuop,
'.'
117 write (
errmsg,
'(a,1x,a,1x,a,a)') &
118 trim(
errmsg),
'Specified file status', trim(filstat),
'.'
119 write (
errmsg,
'(a,1x,a,1x,a,a)') &
120 trim(
errmsg),
'Specified file format', trim(fmtarg),
'.'
121 write (
errmsg,
'(a,1x,a,1x,a,a)') &
122 trim(
errmsg),
'Specified file access', trim(accarg),
'.'
123 write (
errmsg,
'(a,1x,a,1x,a,a)') &
124 trim(
errmsg),
'Specified file action', trim(filact),
'.'
125 write (
errmsg,
'(a,1x,a,1x,i0,a)') &
126 trim(
errmsg),
'IOSTAT error number', ivar,
'.'
127 write (
errmsg,
'(a,1x,a)') &
128 trim(
errmsg),
'STOP EXECUTION in subroutine openfile().'
134 write (iout, fmtmsg) fname(1:iflen), ftype, iu, filstat, fmtarg, &
148 integer(I4B),
intent(inout) :: iu
154 inquire (unit=i, opened=opened)
155 if (.not. opened)
exit
171 integer(I4B) :: iunit
185 integer(I4B),
intent(inout) :: iounit
186 integer(I4B),
intent(in) :: errunit
187 character(len=*),
intent(in) :: description
189 write (
errmsg,
'(a,1x,i0)') &
190 trim(description)//
' already assigned at unit: ', iounit
204 character(len=*),
intent(inout) :: word
207 integer(I4B) :: idiff
212 idiff = ichar(
'a') - ichar(
'A')
216 IF (word(k:k) >=
'a' .and. word(k:k) <=
'z') &
217 word(k:k) = char(ichar(word(k:k)) - idiff)
228 character(len=*) :: word
230 integer(I4B) :: idiff, k, l
234 idiff = ichar(
'a') - ichar(
'A')
238 if (word(k:k) >=
'A' .and. word(k:k) <=
'Z')
then
239 word(k:k) = char(ichar(word(k:k)) + idiff)
252 character(len=LINELENGTH),
intent(inout) :: name
253 integer(I4B),
intent(in) :: proc_id
255 character(len=LINELENGTH) :: name_local
256 character(len=LINELENGTH) :: name_processor
257 character(len=LINELENGTH) :: extension_local
258 integer(I4B) :: ipos0
259 integer(I4B) :: ipos1
263 ipos0 = index(name_local,
".", back=.true.)
264 ipos1 = len_trim(name)
266 write (extension_local,
'(a)') name(ipos0:ipos1)
271 write (name_processor,
'(a,a,i0,a)') &
272 name(1:ipos0 - 1),
'.p', proc_id, trim(adjustl(extension_local))
273 name = name_processor
282 subroutine uwword(line, icol, ilen, ncode, c, n, r, fmt, alignment, sep)
285 character(len=*),
intent(inout) :: line
286 integer(I4B),
intent(inout) :: icol
287 integer(I4B),
intent(in) :: ilen
288 integer(I4B),
intent(in) :: ncode
289 character(len=*),
intent(in) :: c
290 integer(I4B),
intent(in) :: n
291 real(dp),
intent(in) :: r
292 character(len=*),
optional,
intent(in) :: fmt
293 integer(I4B),
optional,
intent(in) :: alignment
294 character(len=*),
optional,
intent(in) :: sep
296 character(len=16) :: cfmt
297 character(len=16) :: cffmt
298 character(len=ILEN) :: cval
299 integer(I4B) :: ialign
301 integer(I4B) :: ispace
302 integer(I4B) :: istop
304 integer(I4B) :: ireal
311 if (
present(fmt))
then
316 write (cfmt,
'(a,I0,a)')
'(a', ilen,
')'
318 write (cfmt,
'(a,I0,a)')
'(I', ilen,
')'
322 write (cfmt,
'(a,I0,a,I0,a)')
'(1PG', ilen,
'.', i,
')'
328 write (cffmt,
'(a,I0,a)')
'(a', ilen,
')'
330 if (
present(alignment))
then
343 else if (ncode ==
tabreal)
then
348 if (len_trim(adjustl(cval)) > ilen)
then
351 cval = trim(adjustl(cval))
355 ispace = (ilen - i) / 2
358 cval =
' '//trim(adjustl(cval))
360 cval = trim(adjustl(cval))
363 cval = repeat(
' ', ispace)//trim(cval)
365 else if (ialign ==
tableft)
then
366 cval = trim(adjustl(cval))
368 cval =
' '//trim(adjustl(cval))
378 istop = icol + ilen - 1
381 write (line(icol:istop), cffmt) cval
385 if (
present(sep))
then
388 write (line(icol:istop),
'(a)') sep
420 subroutine urword(line, icol, istart, istop, ncode, n, r, iout, in)
422 character(len=*) :: line
423 integer(I4B),
intent(inout) :: icol
424 integer(I4B),
intent(inout) :: istart
425 integer(I4B),
intent(inout) :: istop
426 integer(I4B),
intent(in) :: ncode
427 integer(I4B),
intent(inout) :: n
428 real(dp),
intent(inout) :: r
429 integer(I4B),
intent(in) :: iout
430 integer(I4B),
intent(in) :: in
432 character(len=20) string
434 character(len=1) charend
435 character(len=200) :: msg
436 character(len=linelength) :: msg_line
438 character(len=*),
parameter :: fmtmsgout1 = &
439 "(1X,'FILE UNIT ',I4,' : ERROR CONVERTING ""',A, &
440 & '"" TO ',A,' IN LINE:')"
441 character(len=*),
parameter :: fmtmsgout2 =
"(1x, &
442 & 'KEYBOARD INPUT : ERROR CONVERTING ""',a,'"" TO ',a,' IN LINE:')"
443 character(len=*),
parameter :: fmtmsgout3 =
"('File unit ', &
444 & I0,': Error converting ""',a,'"" to ',A,' in following line:')"
445 character(len=*),
parameter :: fmtmsgout4 = &
446 "('Keyboard input: Error converting ""',a, &
447 & '"" to ',A,' in following line:')"
455 line(linlen:linlen) =
' '
459 if (icol < 1 .or. icol > linlen)
go to 100
464 if (line(i:i) /=
' ' .and. line(i:i) /=
',' .and. &
465 line(i:i) /= tab)
go to 20
473 20
if (line(i:i) == char(34) .or. line(i:i) == char(39))
then
474 if (line(i:i) == char(34))
then
480 if (i <= linlen)
then
482 if (line(j:j) == charend)
go to 40
489 if (line(j:j) ==
' ' .or. line(j:j) ==
',' .or. &
490 line(j:j) == tab)
go to 40
508 idiff = ichar(
'a') - ichar(
'A')
510 if (line(k:k) >=
'a' .and. line(k:k) <=
'z') &
511 line(k:k) = char(ichar(line(k:k)) - idiff)
517 100
if (ncode == 2 .or. ncode == 3)
then
518 l = istop - istart + 1
520 if (istart > linlen)
then
523 if (ncode == 2) n = 0
524 if (ncode == 3) r =
dzero
526 if (ncode == 2)
read (line(istart:istop), *, err=200) n
527 if (ncode == 3)
read (line(istart:istop), *, err=200) r
533 200
if (ncode == 3)
then
534 string =
'a real number'
537 string =
'an integer'
545 line(linlen + 1:linlen + 1) =
'E'
549 else if (iout > 0)
then
551 write (msg_line, fmtmsgout1) in, line(istart:istop), string(1:l)
553 write (msg_line, fmtmsgout2) line(istart:istop), string(1:l)
561 write (msg_line, fmtmsgout1) in, line(istart:istop), string(1:l)
563 write (msg_line, fmtmsgout2) line(istart:istop), string(1:l)
572 write (msg, fmtmsgout3) in, line(istart:istop), trim(string)
574 write (msg, fmtmsgout4) line(istart:istop), trim(string)
584 subroutine ulstlb(iout, label, caux, ncaux, naux)
586 character(len=*) :: label
587 character(len=16) :: caux(ncaux)
589 character(len=400) buf
591 character(len=1) dash(400)
594 character(len=*),
parameter :: fmtmsgout1 =
"(1x, a)"
595 character(len=*),
parameter :: fmtmsgout2 =
"(1x, 400a)"
601 nbuf = len(label) + 9
606 buf(n1:nbuf) = caux(i)
611 write (iout, fmtmsgout1) buf(1:nbuf)
614 write (iout, fmtmsgout2) (dash(j), j=1, nbuf)
622 subroutine ubdsv4(kstp, kper, text, naux, auxtxt, ibdchn, &
623 & ncol, nrow, nlay, nlist, iout, delt, pertim, totim)
625 character(len=16) :: text
626 character(len=16),
dimension(:) :: auxtxt
627 real(dp),
intent(in) :: delt, pertim, totim
629 character(len=*),
parameter :: fmt = &
630 &
"(1X,'UBDSV4 SAVING ',A16,' ON UNIT',I7,' AT TIME STEP',I7,"// &
631 &
"', STRESS PERIOD',I7)"
634 if (iout > 0)
write (iout, fmt) text, ibdchn, kstp, kper
635 write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
636 write (ibdchn) 5, delt, pertim, totim
637 write (ibdchn) naux + 1
638 if (naux > 0)
write (ibdchn) (auxtxt(n), n=1, naux)
645 subroutine ubdsvb(ibdchn, icrl, q, val, nvl, naux, laux)
647 real(dp),
dimension(nvl) :: val
653 write (ibdchn) icrl, q, (val(n), n=laux, n2)
655 write (ibdchn) icrl, q
668 subroutine ucolno(nlbl1, nlbl2, nspace, ncpl, ndig, iout)
670 character(len=1) :: dot, space, dg, bf
671 dimension :: bf(1000), dg(10)
673 data dg(1), dg(2), dg(3), dg(4), dg(5), dg(6), dg(7), dg(8), dg(9), dg(10)/ &
674 &
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'/
675 data dot, space/
'.',
' '/
677 character(len=*),
parameter :: fmtmsgout1 =
"(1x)"
678 character(len=*),
parameter :: fmtmsgout2 =
"(1x, 1000a1)"
682 if (iout <= 0)
return
683 write (iout, fmtmsgout1)
685 nlbl = nlbl2 - nlbl1 + 1
688 if (nlbl < ncpl) n = ncpl
689 ntot = nspace + n * ndig
691 if (ntot > 1000)
go to 50
692 nwrap = (nlbl - 1) / ncpl + 1
708 if (j2 > nlbl2) j2 = nlbl2
716 if (i2 == 0)
go to 30
718 i2 = i2 - i3 * 10 + 1
720 if (i3 == 0)
go to 30
722 i3 = i3 - i4 * 10 + 1
724 if (i4 == 0)
go to 30
729 bf(nbf - 3) = dg(i4 + 1)
734 write (iout, fmtmsgout2) (bf(i), i=1, nbf)
740 if (ntot > 1000) ntot = 1000
741 write (iout, fmtmsgout2) (dot, i=1, ntot)
746 subroutine ulaprw(buf, text, kstp, kper, ncol, nrow, ilay, iprn, iout)
748 character(len=16) :: text
749 real(dp),
dimension(ncol, nrow) :: buf
751 character(len=*),
parameter :: fmtmsgout1 = &
752 &
"('1', /2x, a, ' IN LAYER ',I3,' AT END OF TIME STEP ',I3, &
753 & ' IN STRESS PERIOD ',I4/2x,75('-'))"
754 character(len=*),
parameter :: fmtmsgout2 = &
755 &
"('1',/1x,A,' FOR CROSS SECTION AT END OF TIME STEP',I3, &
756 & ' IN STRESS PERIOD ',I4/1x,79('-'))"
757 character(len=*),
parameter :: fmtg10 = &
758 &
"(1X,I3,2X,1PG10.3,10(1X,G10.3):/(5X,11(1X,G10.3)))"
759 character(len=*),
parameter :: fmtg13 = &
760 &
"(1x,I3,2x,1PG13.6,8(1x,G13.6):/(5x,9(1x,G13.6)))"
761 character(len=*),
parameter :: fmtf7pt1 = &
762 &
"(1x,I3,1x,15(1x,F7.1):/(5x,15(1x,F7.1)))"
763 character(len=*),
parameter :: fmtf7pt2 = &
764 &
"(1x,I3,1x,15(1x,F7.2):/(5x,15(1x,F7.2)))"
765 character(len=*),
parameter :: fmtf7pt3 = &
766 &
"(1x,I3,1x,15(1x,F7.3):/(5x,15(1x,F7.3)))"
767 character(len=*),
parameter :: fmtf7pt4 = &
768 &
"(1x,I3,1x,15(1x,F7.4):/(5x,15(1x,F7.4)))"
769 character(len=*),
parameter :: fmtf5pt0 = &
770 &
"(1x,I3,1x,20(1x,F5.0):/(5x,20(1x,F5.0)))"
771 character(len=*),
parameter :: fmtf5pt1 = &
772 &
"(1x,I3,1x,20(1x,F5.1):/(5x,20(1x,F5.1)))"
773 character(len=*),
parameter :: fmtf5pt2 = &
774 &
"(1x,I3,1x,20(1x,F5.2):/(5x,20(1x,F5.2)))"
775 character(len=*),
parameter :: fmtf5pt3 = &
776 &
"(1x,I3,1x,20(1x,F5.3):/(5x,20(1x,F5.3)))"
777 character(len=*),
parameter :: fmtf5pt4 = &
778 &
"(1x,I3,1x,20(1x,F5.4):/(5x,20(1x,F5.4)))"
779 character(len=*),
parameter :: fmtg11 = &
780 &
"(1x,I3,2x,1PG11.4,9(1x,G11.4):/(5x,10(1x,G11.4)))"
781 character(len=*),
parameter :: fmtf6pt0 = &
782 &
"(1x,I3,1x,10(1x,F6.0):/(5X,10(1x,F6.0)))"
783 character(len=*),
parameter :: fmtf6pt1 = &
784 &
"(1x,I3,1x,10(1x,F6.1):/(5x,10(1x,F6.1)))"
785 character(len=*),
parameter :: fmtf6pt2 = &
786 &
"(1x,I3,1x,10(1x,F6.2):/(5x,10(1x,F6.2)))"
787 character(len=*),
parameter :: fmtf6pt3 = &
788 &
"(1x,I3,1x,10(1x,F6.3):/(5x,10(1x,F6.3)))"
789 character(len=*),
parameter :: fmtf6pt4 = &
790 &
"(1x,I3,1x,10(1x,F6.4):/(5x,10(1x,F6.4)))"
791 character(len=*),
parameter :: fmtf6pt5 = &
792 &
"(1x,I3,1x,10(1x,F6.5):/(5x,10(1x,F6.5)))"
793 character(len=*),
parameter :: fmtg12 = &
794 &
"(1x,I3,2x,1PG12.5,4(1x,G12.5):/(5x,5(1x,G12.5)))"
795 character(len=*),
parameter :: fmtg11pt4 = &
796 &
"(1x,I3,2x,1PG11.4,5(1x,G11.4):/(5x,6(1x,G11.4)))"
797 character(len=*),
parameter :: fmtg9pt2 = &
798 &
"(1x,I3,2x,1PG9.2,6(1x,G9.2):/(5x,7(1x,G9.2)))"
800 if (iout <= 0)
return
803 write (iout, fmtmsgout1) text, ilay, kstp, kper
804 else if (ilay < 0)
then
805 write (iout, fmtmsgout2) text, kstp, kper
810 if (ip < 1 .or. ip > 21) ip = 12
813 if (ip == 1)
call ucolno(1, ncol, 0, 11, 11, iout)
814 if (ip == 2)
call ucolno(1, ncol, 0, 9, 14, iout)
815 if (ip >= 3 .and. ip <= 6)
call ucolno(1, ncol, 3, 15, 8, iout)
816 if (ip >= 7 .and. ip <= 11)
call ucolno(1, ncol, 3, 20, 6, iout)
817 if (ip == 12)
call ucolno(1, ncol, 0, 10, 12, iout)
818 if (ip >= 13 .and. ip <= 18)
call ucolno(1, ncol, 3, 10, 7, iout)
819 if (ip == 19)
call ucolno(1, ncol, 0, 5, 13, iout)
820 if (ip == 20)
call ucolno(1, ncol, 0, 6, 12, iout)
821 if (ip == 21)
call ucolno(1, ncol, 0, 7, 10, iout)
829 write (iout, fmtg10) i, (buf(j, i), j=1, ncol)
833 write (iout, fmtg13) i, (buf(j, i), j=1, ncol)
837 write (iout, fmtf7pt1) i, (buf(j, i), j=1, ncol)
841 write (iout, fmtf7pt2) i, (buf(j, i), j=1, ncol)
845 write (iout, fmtf7pt3) i, (buf(j, i), j=1, ncol)
849 write (iout, fmtf7pt4) i, (buf(j, i), j=1, ncol)
853 write (iout, fmtf5pt0) i, (buf(j, i), j=1, ncol)
857 write (iout, fmtf5pt1) i, (buf(j, i), j=1, ncol)
861 write (iout, fmtf5pt2) i, (buf(j, i), j=1, ncol)
865 write (iout, fmtf5pt3) i, (buf(j, i), j=1, ncol)
869 write (iout, fmtf5pt4) i, (buf(j, i), j=1, ncol)
873 write (iout, fmtg11) i, (buf(j, i), j=1, ncol)
877 write (iout, fmtf6pt0) i, (buf(j, i), j=1, ncol)
881 write (iout, fmtf6pt1) i, (buf(j, i), j=1, ncol)
885 write (iout, fmtf6pt2) i, (buf(j, i), j=1, ncol)
889 write (iout, fmtf6pt3) i, (buf(j, i), j=1, ncol)
893 write (iout, fmtf6pt4) i, (buf(j, i), j=1, ncol)
897 write (iout, fmtf6pt5) i, (buf(j, i), j=1, ncol)
901 write (iout, fmtg12) i, (buf(j, i), j=1, ncol)
905 write (iout, fmtg11pt4) i, (buf(j, i), j=1, ncol)
909 write (iout, fmtg9pt2) i, (buf(j, i), j=1, ncol)
920 subroutine ulasav(buf, text, kstp, kper, pertim, totim, ncol, nrow, &
923 character(len=16) :: text
924 real(dp),
dimension(ncol, nrow) :: buf
925 real(dp) :: pertim, totim
928 write (ichn) kstp, kper, pertim, totim, text, ncol, nrow, ilay
932 write (ichn) ((buf(ic, ir), ic=1, ncol), ir=1, nrow)
941 subroutine ubdsv1(kstp, kper, text, ibdchn, buff, ncol, nrow, nlay, iout, &
945 integer(I4B),
intent(in) :: kstp
946 integer(I4B),
intent(in) :: kper
947 character(len=*),
intent(in) :: text
948 integer(I4B),
intent(in) :: ibdchn
949 real(dp),
dimension(:),
intent(in) :: buff
950 integer(I4B),
intent(in) :: ncol
951 integer(I4B),
intent(in) :: nrow
952 integer(I4B),
intent(in) :: nlay
953 integer(I4B),
intent(in) :: iout
954 real(dp),
intent(in) :: delt
955 real(dp),
intent(in) :: pertim
956 real(dp),
intent(in) :: totim
958 character(len=*),
parameter :: fmt = &
959 &
"(1X,'UBDSV1 SAVING ',A16,' ON UNIT',I7,' AT TIME STEP',I7,"// &
960 &
"', STRESS PERIOD',I7)"
963 if (iout > 0)
write (iout, fmt) text, ibdchn, kstp, kper
964 write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
965 write (ibdchn) 1, delt, pertim, totim
977 subroutine ubdsv06(kstp, kper, text, modelnam1, paknam1, modelnam2, paknam2, &
978 ibdchn, naux, auxtxt, ncol, nrow, nlay, nlist, iout, &
982 integer(I4B),
intent(in) :: kstp
983 integer(I4B),
intent(in) :: kper
984 character(len=*),
intent(in) :: text
985 character(len=*),
intent(in) :: modelnam1
986 character(len=*),
intent(in) :: paknam1
987 character(len=*),
intent(in) :: modelnam2
988 character(len=*),
intent(in) :: paknam2
989 integer(I4B),
intent(in) :: naux
990 character(len=16),
dimension(:),
intent(in) :: auxtxt
991 integer(I4B),
intent(in) :: ibdchn
992 integer(I4B),
intent(in) :: ncol
993 integer(I4B),
intent(in) :: nrow
994 integer(I4B),
intent(in) :: nlay
995 integer(I4B),
intent(in) :: nlist
996 integer(I4B),
intent(in) :: iout
997 real(dp),
intent(in) :: delt
998 real(dp),
intent(in) :: pertim
999 real(dp),
intent(in) :: totim
1003 character(len=*),
parameter :: fmt = &
1004 &
"(1X,'UBDSV06 SAVING ',A16,' IN MODEL ',A16,' PACKAGE ',A16,"// &
1005 &
"'CONNECTED TO MODEL ',A16,' PACKAGE ',A16,"// &
1006 &
"' ON UNIT',I7,' AT TIME STEP',I7,', STRESS PERIOD',I7)"
1009 if (iout > 0)
write (iout, fmt) text, modelnam1, paknam1, modelnam2, &
1010 paknam2, ibdchn, kstp, kper
1011 write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
1012 write (ibdchn) 6, delt, pertim, totim
1013 write (ibdchn) modelnam1
1014 write (ibdchn) paknam1
1015 write (ibdchn) modelnam2
1016 write (ibdchn) paknam2
1017 write (ibdchn) naux + 1
1018 if (naux > 0)
write (ibdchn) (auxtxt(n), n=1, naux)
1019 write (ibdchn) nlist
1029 integer(I4B),
intent(in) :: ibdchn
1030 integer(I4B),
intent(in) :: n
1031 real(dp),
intent(in) :: q
1032 integer(I4B),
intent(in) :: naux
1033 real(dp),
dimension(naux),
intent(in) :: aux
1039 write (ibdchn) n, q, (aux(nn), nn=1, naux)
1049 subroutine ubdsvd(ibdchn, n, n2, q, naux, aux)
1052 integer(I4B),
intent(in) :: ibdchn
1053 integer(I4B),
intent(in) :: n
1054 integer(I4B),
intent(in) :: n2
1055 real(dp),
intent(in) :: q
1056 integer(I4B),
intent(in) :: naux
1057 real(dp),
dimension(naux),
intent(in) :: aux
1063 write (ibdchn) n, n2, q, (aux(nn), nn=1, naux)
1065 write (ibdchn) n, n2, q
1074 character(len=*),
intent(in) :: word1, word2
1076 character(len=200) :: upword1, upword2
1089 character(len=*),
intent(in) :: str
1090 integer,
intent(in) :: width
1092 character(len=max(len_trim(str), width)) :: res
1102 character(len=LINELENGTH) :: line
1103 character(len=100) :: fname, ac, act, fm, frm, seq, unf
1105 character(len=*),
parameter :: fmta = &
1106 &
"('unit:',i4,' name:',a,' access:',a,' action:',a)"
1107 character(len=*),
parameter :: fmtb = &
1108 &
"(' formatted:',a,' sequential:',a,' unformatted:',a,' form:',a)"
1111 inquire (unit=iu, name=fname, access=ac, action=act, formatted=fm, &
1112 sequential=seq, unformatted=unf, form=frm)
1115 write (line, fmta) iu, trim(fname), trim(ac), trim(act)
1117 write (line, fmtb) trim(fm), trim(seq), trim(unf), trim(frm)
1132 character(len=*),
intent(in) :: line
1133 integer(I4B),
intent(inout) :: nwords
1134 character(len=*),
allocatable,
dimension(:),
intent(inout) :: words
1135 integer(I4B),
intent(in),
optional :: inunit
1136 character(len=*),
intent(in),
optional :: filename
1138 integer(I4B) :: i, idum, istart, istop, linelen, lloc
1142 if (
allocated(words))
then
1149 allocate (words(nwords))
1154 call urword(line, lloc, istart, istop, 0, idum, rdum, 0, 0)
1155 words(i) = line(istart:istop)
1161 subroutine ulaprufw(ncol, nrow, kstp, kper, ilay, iout, buf, text, userfmt, &
1162 nvalues, nwidth, editdesc)
1165 integer(I4B),
intent(in) :: ncol, nrow, kstp, kper, ilay, iout
1166 real(dp),
dimension(ncol, nrow),
intent(in) :: buf
1167 character(len=*),
intent(in) :: text
1168 character(len=*),
intent(in) :: userfmt
1169 integer(I4B),
intent(in) :: nvalues, nwidth
1170 character(len=1),
intent(in) :: editdesc
1172 integer(I4B) :: i, j, nspaces
1174 character(len=*),
parameter :: fmtmsgout1 = &
1175 "('1',/2X,A,' IN LAYER ',I3,' AT END OF TIME STEP ',I3, &
1176 & ' IN STRESS PERIOD ',I4/2X,75('-'))"
1177 character(len=*),
parameter :: fmtmsgout2 = &
1178 "('1',/1X,A,' FOR CROSS SECTION AT END OF TIME STEP',I3, &
1179 & ' IN STRESS PERIOD ',I4/1X,79('-'))"
1181 if (iout <= 0)
return
1184 write (iout, fmtmsgout1) trim(text), ilay, kstp, kper
1185 else if (ilay < 0)
then
1186 write (iout, fmtmsgout2) trim(text), kstp, kper
1191 if (editdesc ==
'F') nspaces = 3
1192 call ucolno(1, ncol, nspaces, nvalues, nwidth + 1, iout)
1196 write (iout, userfmt) i, (buf(j, i), j=1, ncol)
1219 integer(I4B),
intent(in) :: iu
1220 logical,
intent(out) :: eof
1221 character(len=:),
allocatable :: astring
1223 integer(I4B) :: isize, istat
1224 character(len=256) :: buffer
1225 character(len=1000) :: ermsg, fname
1226 character(len=7) :: fmtd
1229 character(len=*),
parameter :: fmterrmsg1 = &
1230 &
"('Error in read_line: File ',i0,' is not open.')"
1231 character(len=*),
parameter :: fmterrmsg2 = &
1232 &
"('Error in read_line: Attempting to read text ' // &
1233 & 'from unformatted file: ""',a,'""')"
1234 character(len=*),
parameter :: fmterrmsg3 = &
1235 &
"('Error reading from file ""',a,'"" opened on unit ',i0, &
1236 & ' in read_line.')"
1241 read (iu,
'(a)', advance=
'NO', iostat=istat, size=isize,
end=99) buffer
1245 ermsg =
'Programming error in call to read_line: '// &
1246 'Attempt to read from unit number <= 0'
1248 inquire (unit=iu, opened=lop, name=fname, formatted=fmtd)
1250 write (ermsg, fmterrmsg1) iu
1251 elseif (fmtd ==
'NO' .or. fmtd ==
'UNKNOWN')
then
1252 write (ermsg, fmterrmsg2) trim(fname)
1254 write (ermsg, fmterrmsg3) trim(fname), iu
1260 astring = astring//buffer(:isize)
1277 character(len=*),
intent(in) :: pathname
1278 character(len=*),
intent(out) :: filename
1280 integer(I4B) :: i, istart, istop, lenpath
1281 character(len=1) :: fs =
'/'
1282 character(len=1) :: bs =
'\'
1285 lenpath = len_trim(pathname)
1288 loop:
do i = lenpath, 1, -1
1289 if (pathname(i:i) == fs .or. pathname(i:i) == bs)
then
1290 if (i == istop)
then
1298 if (istop >= istart)
then
1299 filename = pathname(istart:istop)
1313 character(len=*),
intent(inout) :: line
1314 integer(I4B),
intent(inout) :: icol, istart, istop
1315 integer(I4B),
intent(out) :: idnum
1316 character(len=LENBOUNDNAME),
intent(out) :: bndname
1318 integer(I4B) :: istat, ndum, ncode = 0
1321 call urword(line, icol, istart, istop, ncode, ndum, rdum, 0, 0)
1322 read (line(istart:istop), *, iostat=istat) ndum
1323 if (istat == 0)
then
1327 idnum = namedboundflag
1328 bndname = line(istart:istop)
1335 subroutine urdaux(naux, inunit, iout, lloc, istart, istop, auxname, line, text)
1342 integer(I4B),
intent(inout) :: naux
1343 integer(I4B),
intent(in) :: inunit
1344 integer(I4B),
intent(in) :: iout
1345 integer(I4B),
intent(inout) :: lloc
1346 integer(I4B),
intent(inout) :: istart
1347 integer(I4B),
intent(inout) :: istop
1348 character(len=LENAUXNAME),
allocatable,
dimension(:),
intent(inout) :: auxname
1349 character(len=*),
intent(inout) :: line
1350 character(len=*),
intent(in) :: text
1352 integer(I4B) :: n, linelen
1353 integer(I4B) :: iauxlen
1358 write (errmsg,
'(a)')
'Auxiliary variables already specified. '// &
1359 &
'Auxiliary variables must be specified on one line in the '// &
1361 call store_error(errmsg)
1362 call store_error_unit(inunit)
1365 call urword(line, lloc, istart, istop, 1, n, rval, iout, inunit)
1366 if (istart >= linelen)
exit auxloop
1367 iauxlen = istop - istart + 1
1369 write (errmsg,
'(a, a, a, i0, a, i0, a)') &
1370 'Found auxiliary variable (', line(istart:istop), &
1371 ') with a name of size ', iauxlen, &
1372 '. Auxiliary variable names must be len than or equal&
1374 call store_error(errmsg)
1375 call store_error_unit(inunit)
1379 auxname(naux) = line(istart:istop)
1381 write (iout,
"(4X,'AUXILIARY ',a,' VARIABLE: ',A)") &
1382 trim(adjustl(text)), auxname(naux)
1405 subroutine print_format(linein, cdatafmp, editdesc, nvaluesp, nwidthp, inunit)
1407 character(len=*),
intent(in) :: linein
1408 character(len=*),
intent(inout) :: cdatafmp
1409 character(len=*),
intent(inout) :: editdesc
1410 integer(I4B),
intent(inout) :: nvaluesp
1411 integer(I4B),
intent(inout) :: nwidthp
1412 integer(I4B),
intent(in) :: inunit
1414 character(len=len(linein)) :: line
1415 character(len=20),
dimension(:),
allocatable :: words
1416 character(len=100) :: ermsg
1417 integer(I4B) :: ndigits = 0, nwords = 0
1418 integer(I4B) :: i, ierr
1423 call parseline(line, nwords, words, inunit)
1427 if (editdesc ==
'I') isint = .true.
1430 if (nwords < 1)
then
1431 ermsg =
'Could not build PRINT_FORMAT from line'//trim(line)
1432 call store_error(trim(ermsg))
1433 ermsg =
'Syntax is: COLUMNS <columns> WIDTH <width> DIGITS &
1435 call store_error(trim(ermsg))
1436 call store_error_unit(inunit)
1439 ermsg =
'Error setting PRINT_FORMAT. Syntax is incorrect in line:'
1440 if (nwords >= 4)
then
1441 if (.not.
same_word(words(1),
'COLUMNS')) ierr = 1
1442 if (.not.
same_word(words(3),
'WIDTH')) ierr = 1
1445 read (words(2), *, iostat=ierr) nvaluesp
1448 read (words(4), *, iostat=ierr) nwidthp
1454 call store_error(ermsg)
1455 call store_error(line)
1456 ermsg =
'Syntax is: COLUMNS <columns> WIDTH <width> &
1457 &DIGITS <digits> <format>'
1458 call store_error(trim(ermsg))
1459 call store_error_unit(inunit)
1463 if (.not. isint)
then
1465 if (nwords >= 5)
then
1466 if (.not.
same_word(words(5),
'DIGITS')) ierr = 1
1468 read (words(6), *, iostat=ierr) ndigits
1479 if (i <= nwords)
then
1481 select case (words(i))
1482 case (
'EXPONENTIAL')
1495 ermsg =
'Error in format specification. Unrecognized option: '//words(i)
1496 call store_error(ermsg)
1497 ermsg =
'Valid values are EXPONENTIAL, FIXED, GENERAL, or SCIENTIFIC.'
1498 call store_error(ermsg)
1499 call store_error_unit(inunit)
1506 call store_error(ermsg)
1507 call store_error(line)
1508 call store_error_unit(inunit)
1512 select case (editdesc)
1517 case (
'E',
'G',
'S')
1527 integer(I4B),
intent(in) :: nvalsp, nwidp, ndig
1528 character(len=*),
intent(inout) :: outfmt
1529 logical,
intent(in),
optional :: prowcolnum
1531 character(len=8) :: cvalues, cwidth, cdigits
1532 character(len=60) :: ufmt
1533 logical :: prowcolnumlocal
1535 character(len=*),
parameter :: fmtndig =
"(i8)"
1537 if (
present(prowcolnum))
then
1538 prowcolnumlocal = prowcolnum
1540 prowcolnumlocal = .true.
1544 write (cdigits, fmtndig) ndig
1545 cdigits = adjustl(cdigits)
1548 write (cvalues, fmtndig) nvalsp
1549 cvalues = adjustl(cvalues)
1550 write (cwidth, fmtndig) nwidp
1551 cwidth = adjustl(cwidth)
1552 if (prowcolnumlocal)
then
1558 ufmt = trim(ufmt)//cvalues
1559 ufmt = trim(ufmt)//
'(1x,f'
1560 ufmt = trim(ufmt)//cwidth
1561 ufmt = trim(ufmt)//
'.'
1562 ufmt = trim(ufmt)//cdigits
1563 ufmt = trim(ufmt)//
'):/(5x,'
1564 ufmt = trim(ufmt)//cvalues
1565 ufmt = trim(ufmt)//
'(1x,f'
1566 ufmt = trim(ufmt)//cwidth
1567 ufmt = trim(ufmt)//
'.'
1568 ufmt = trim(ufmt)//cdigits
1569 ufmt = trim(ufmt)//
')))'
1578 integer(I4B),
intent(in) :: nvalsp, nwidp, ndig
1579 character(len=*),
intent(in) :: editdesc
1580 character(len=*),
intent(inout) :: outfmt
1581 logical,
intent(in),
optional :: prowcolnum
1583 character(len=8) :: cvalues, cwidth, cdigits
1584 character(len=60) :: ufmt
1585 logical :: prowcolnumlocal
1587 character(len=*),
parameter :: fmtndig =
"(i8)"
1589 if (
present(prowcolnum))
then
1590 prowcolnumlocal = prowcolnum
1592 prowcolnumlocal = .true.
1596 write (cdigits, fmtndig) ndig
1597 cdigits = adjustl(cdigits)
1599 write (cwidth, fmtndig) nwidp
1600 cwidth = adjustl(cwidth)
1602 write (cvalues, fmtndig) (nvalsp - 1)
1603 cvalues = adjustl(cvalues)
1604 if (prowcolnumlocal)
then
1605 ufmt =
'(1x,i3,2x,1p,'//editdesc
1607 ufmt =
'(6x,1p,'//editdesc
1609 ufmt = trim(ufmt)//cwidth
1610 ufmt = trim(ufmt)//
'.'
1611 ufmt = trim(ufmt)//cdigits
1612 if (nvalsp > 1)
then
1613 ufmt = trim(ufmt)//
','
1614 ufmt = trim(ufmt)//cvalues
1615 ufmt = trim(ufmt)//
'(1x,'
1616 ufmt = trim(ufmt)//editdesc
1617 ufmt = trim(ufmt)//cwidth
1618 ufmt = trim(ufmt)//
'.'
1619 ufmt = trim(ufmt)//cdigits
1620 ufmt = trim(ufmt)//
')'
1623 ufmt = trim(ufmt)//
':/(5x,'
1624 write (cvalues, fmtndig) nvalsp
1625 cvalues = adjustl(cvalues)
1626 ufmt = trim(ufmt)//cvalues
1627 ufmt = trim(ufmt)//
'(1x,'
1628 ufmt = trim(ufmt)//editdesc
1629 ufmt = trim(ufmt)//cwidth
1630 ufmt = trim(ufmt)//
'.'
1631 ufmt = trim(ufmt)//cdigits
1632 ufmt = trim(ufmt)//
')))'
1641 integer(I4B),
intent(in) :: nvalsp, nwidp
1642 character(len=*),
intent(inout) :: outfmt
1643 logical,
intent(in),
optional :: prowcolnum
1645 character(len=8) :: cvalues, cwidth
1646 character(len=60) :: ufmt
1647 logical :: prowcolnumlocal
1649 character(len=*),
parameter :: fmtndig =
"(i8)"
1651 if (
present(prowcolnum))
then
1652 prowcolnumlocal = prowcolnum
1654 prowcolnumlocal = .true.
1658 write (cvalues, fmtndig) nvalsp
1659 cvalues = adjustl(cvalues)
1660 write (cwidth, fmtndig) nwidp
1661 cwidth = adjustl(cwidth)
1662 if (prowcolnumlocal)
then
1667 ufmt = trim(ufmt)//cvalues
1668 ufmt = trim(ufmt)//
'(1x,i'
1669 ufmt = trim(ufmt)//cwidth
1670 ufmt = trim(ufmt)//
'):/(5x,'
1671 ufmt = trim(ufmt)//cvalues
1672 ufmt = trim(ufmt)//
'(1x,i'
1673 ufmt = trim(ufmt)//cwidth
1674 ufmt = trim(ufmt)//
')))'
1684 character(len=*),
intent(in) :: line
1686 integer(I4B) :: linelen
1687 integer(I4B) :: lloc
1688 integer(I4B) :: istart
1689 integer(I4B) :: istop
1690 integer(I4B) :: idum
1700 call urword(line, lloc, istart, istop, 0, idum, rdum, 0, 0)
1701 if (istart == linelen)
exit
1714 integer(I4B),
intent(in) :: iu
1715 integer(I4B),
intent(in) :: offset
1716 integer(I4B),
intent(in) :: whence
1717 integer(I4B),
intent(inout) :: status
1719 integer(I8B) :: ipos
1720 character(len=20) :: file_action
1722 inquire (unit=iu, size=ipos)
1724 select case (whence)
1732 inquire (unit=iu, pos=ipos)
1733 ipos = ipos + offset
1737 inquire (unit=iu, size=ipos)
1738 ipos = ipos + offset
1744 inquire (unit=iu, action=file_action)
1745 if (trim(file_action) ==
'READ')
then
1746 read (iu, pos=ipos, iostat=status)
1748 write (iu, pos=ipos, iostat=status)
1750 inquire (unit=iu, pos=ipos)
1760 use,
intrinsic :: iso_fortran_env, only: iostat_end
1763 integer(I4B),
intent(in) :: iin
1764 integer(I4B),
intent(in) :: iout
1765 character(len=:),
allocatable,
intent(inout) :: line
1766 integer(I4B),
intent(out) :: ierr
1768 character(len=:),
allocatable :: linetemp
1769 character(len=2),
parameter :: comment =
'//'
1770 character(len=1),
parameter :: tab = char(9)
1771 logical :: iscomment
1772 integer(I4B) :: i, j, l, istart, lsize
1778 if (ierr == iostat_end)
then
1783 elseif (ierr /= 0)
then
1786 write (errmsg, *)
'u9rdcom: Could not read from unit: ', iin
1787 call store_error(errmsg, terminate=.true.)
1789 if (len_trim(line) < 1)
then
1800 allocate (
character(len=lsize) :: linetemp)
1802 if (line(j:j) /=
' ' .and. line(j:j) /=
',' .and. &
1803 line(j:j) /= char(9))
then
1809 linetemp(:) = line(istart:)
1810 line(:) = linetemp(:)
1811 deallocate (linetemp)
1815 select case (line(1:1))
1826 if (line(1:2) == comment) iscomment = .true.
1827 if (len_trim(line) < 1) iscomment = .true.
1832 if (.not. iscomment)
then
1839 if (line(i:i) /=
' ')
then
1844 write (iout,
'(1x,a)') line(1:i)
1858 integer(I4B),
intent(in) :: lun
1859 character(len=:),
intent(out),
allocatable :: line
1860 integer(I4B),
intent(out) :: iostat
1862 integer(I4B),
parameter :: buffer_len = maxcharlen
1863 character(len=buffer_len) :: buffer
1864 character(len=:),
allocatable :: linetemp
1865 integer(I4B) :: size_read, linesize
1866 character(len=1),
parameter :: cr = char(13)
1867 character(len=1),
parameter :: lf = char(10)
1875 read (lun,
'(A)', iostat=iostat, advance=
'no', size=size_read) buffer
1876 if (is_iostat_eor(iostat))
then
1877 linesize = len(line)
1878 deallocate (linetemp)
1879 allocate (
character(len=linesize) :: linetemp)
1880 linetemp(:) = line(:)
1882 allocate (
character(len=linesize + size_read + 1) :: line)
1883 line(:) = linetemp(:)
1884 line(linesize + 1:) = buffer(:size_read)
1885 linesize = len(line)
1886 line(linesize:linesize) =
' '
1889 else if (iostat == 0)
then
1890 linesize = len(line)
1891 deallocate (linetemp)
1892 allocate (
character(len=linesize) :: linetemp)
1893 linetemp(:) = line(:)
1895 allocate (
character(len=linesize + size_read) :: line)
1896 line(:) = linetemp(:)
1897 line(linesize + 1:) = buffer(:size_read)
1904 linesize = len(line)
1905 crlfcheck:
do i = 1, linesize
1906 if (line(i:i) .eq. cr .or. line(i:i) .eq. lf)
then
1907 if (line(i:i) .eq. cr)
then
1908 write (errmsg,
'(a)') &
1909 'get_line: Found an isolated Carriage Return.'
1911 if (line(i:i) .eq. lf)
then
1912 write (errmsg,
'(a)') &
1913 'get_line: Found an isolated Line Feed.'
1915 write (errmsg,
'(a,1x,a,a)') trim(errmsg), &
1916 'Replace with Carriage Return and Line Feed to', &
1917 ' read as two separate lines.'
1918 write (errmsg,
'(a,1x,5a)') trim(errmsg), &
1919 'Line: "', line(1:i - 1),
'|', line(i + 1:linesize),
'"'
1920 call store_error(errmsg, terminate=.false.)
1921 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