18 integer(I4B) :: in = 0
19 integer(I4B) :: inlist = 0
20 integer(I4B) :: iout = 0
21 integer(I4B) :: inamedbound = 0
22 integer(I4B) :: ierr = 0
23 integer(I4B) :: nlist = 0
24 integer(I4B) :: ibinary = 0
25 integer(I4B) :: istart = 0
26 integer(I4B) :: istop = 0
27 integer(I4B) :: lloc = 0
28 integer(I4B) :: iclose = 0
29 integer(I4B) :: ndim = 0
30 integer(I4B) :: ntxtrlist = 0
31 integer(I4B) :: ntxtauxvar = 0
32 character(len=LENLISTLABEL) :: label =
''
33 character(len=:),
allocatable,
private :: line
34 integer(I4B),
dimension(:),
pointer,
contiguous :: mshape => null()
35 integer(I4B),
dimension(:),
pointer,
contiguous :: nodelist => null()
36 real(dp),
dimension(:, :),
pointer,
contiguous :: rlist => null()
37 real(dp),
dimension(:, :),
pointer,
contiguous :: auxvar => null()
38 character(len=16),
dimension(:),
pointer :: auxname => null()
39 character(len=LENBOUNDNAME),
dimension(:),
pointer, &
40 contiguous :: boundname => null()
41 integer(I4B),
dimension(:),
allocatable :: idxtxtrow
42 integer(I4B),
dimension(:),
allocatable :: idxtxtcol
43 integer(I4B),
dimension(:),
allocatable :: idxtxtauxrow
44 integer(I4B),
dimension(:),
allocatable :: idxtxtauxcol
45 character(len=LENTIMESERIESNAME),
dimension(:),
allocatable :: txtrlist
46 character(len=LENTIMESERIESNAME),
dimension(:),
allocatable :: txtauxvar
64 subroutine read_list(this, line_reader, in, iout, nlist, inamedbound, &
65 mshape, nodelist, rlist, auxvar, auxname, boundname, &
72 integer(I4B),
intent(in) :: in
73 integer(I4B),
intent(in) :: iout
74 integer(I4B),
intent(inout) :: nlist
75 integer(I4B),
intent(in) :: inamedbound
76 integer(I4B),
dimension(:),
intent(in),
contiguous,
pointer :: mshape
77 integer(I4B),
dimension(:),
intent(inout),
contiguous,
pointer :: nodelist
78 real(DP),
dimension(:, :),
intent(inout),
contiguous,
pointer :: rlist
79 real(DP),
dimension(:, :),
intent(inout),
contiguous,
pointer :: auxvar
80 character(len=LENAUXNAME),
dimension(:),
intent(inout),
target :: auxname
81 character(len=LENBOUNDNAME), &
82 dimension(:),
pointer,
contiguous,
intent(inout) :: boundname
83 character(len=LENLISTLABEL),
intent(in) :: label
89 this%inamedbound = inamedbound
90 this%ndim =
size(mshape)
95 this%nodelist => nodelist
98 this%auxname => auxname
99 this%boundname => boundname
100 this%line_reader => line_reader
103 if (.not.
allocated(this%idxtxtrow))
allocate (this%idxtxtrow(0))
104 if (.not.
allocated(this%idxtxtcol))
allocate (this%idxtxtcol(0))
105 if (.not.
allocated(this%idxtxtauxrow))
allocate (this%idxtxtauxrow(0))
106 if (.not.
allocated(this%idxtxtauxcol))
allocate (this%idxtxtauxcol(0))
107 if (.not.
allocated(this%txtrlist))
allocate (this%txtrlist(0))
108 if (.not.
allocated(this%txtauxvar))
allocate (this%txtauxvar(0))
111 call this%read_control_record()
114 call this%read_data()
131 character(len=*),
parameter :: fmtlsf = &
132 "(1X,'LIST SCALING FACTOR=',1PG12.5)"
135 this%inlist = this%in
140 call this%line_reader%rdcom(this%in, this%iout, this%line, this%ierr)
142 call urword(this%line, this%lloc, this%istart, this%istop, 1, idum, r, &
146 select case (this%line(this%istart:this%istop))
148 call this%set_openclose()
164 integer(I4B) :: idum, itmp
167 integer(I4B) :: nunopn = 99
168 character(len=LINELENGTH) :: fname
170 character(len=*),
parameter :: fmtocne = &
171 &
"('Specified OPEN/CLOSE file ',(A),' does not exist')"
172 character(len=*),
parameter :: fmtobf = &
173 &
"(1X,/1X,'OPENING BINARY FILE ON UNIT ',I0,':',/1X,A)"
174 character(len=*),
parameter :: fmtobfnlist = &
175 &
"(1X, 'TO READ ', I0, ' RECORDS.')"
176 character(len=*),
parameter :: fmtofnlist = &
177 &
"(1x,'TO READ ', I0, ' RECORDS.')"
178 character(len=*),
parameter :: fmtof = &
179 &
"(1X,/1X,'OPENING FILE ON UNIT ',I0,':',/1X,A)"
182 call urword(this%line, this%lloc, this%istart, this%istop, 0, idum, r, &
184 fname = this%line(this%istart:this%istop)
187 inquire (file=fname, exist=exists)
188 if (.not. exists)
then
189 write (
errmsg, fmtocne) this%line(this%istart:this%istop)
191 call store_error(
'Specified OPEN/CLOSE file does not exist')
196 call urword(this%line, this%lloc, this%istart, this%istop, 1, idum, r, &
198 if (this%line(this%istart:this%istop) ==
'(BINARY)') this%ibinary = 1
202 if (this%ibinary == 1)
then
204 if (this%iout > 0)
then
206 write (this%iout, fmtobf) this%inlist, trim(adjustl(fname))
207 if (this%nlist > 0)
write (this%iout, fmtobfnlist) this%nlist
209 call openfile(this%inlist, itmp, fname,
'OPEN/CLOSE', fmtarg_opt=
form, &
213 if (this%iout > 0)
then
215 write (this%iout, fmtof) this%inlist, trim(adjustl(fname))
216 if (this%nlist > 0)
write (this%iout, fmtofnlist) this%nlist
218 call openfile(this%inlist, itmp, fname,
'OPEN/CLOSE')
227 if (this%ibinary /= 1) &
228 call this%line_reader%rdcom(this%inlist, this%iout, this%line, &
239 if (this%ibinary == 1)
then
240 call this%read_binary()
242 call this%read_ascii()
246 if (this%iclose == 1)
then
259 integer(I4B) :: mxlist, ldim, naux, nod, ii, jj
260 character(len=LINELENGTH) :: fname
261 integer(I4B),
dimension(:),
allocatable :: cellid
263 character(len=*),
parameter :: fmtmxlsterronly = &
264 "('ERROR READING LIST FROM FILE: ',&
266 &' THE NUMBER OF RECORDS ENCOUNTERED EXCEEDS THE MAXIMUM NUMBER &
267 &OF RECORDS. TRY INCREASING MAXBOUND FOR THIS LIST.&
268 & NUMBER OF RECORDS: ',I0,' MAXBOUND: ',I0)"
269 character(len=*),
parameter :: fmtlsterronly = &
270 "('ERROR READING LIST FROM FILE: ',&
271 &1x,a,1x,' ON UNIT: ',I0)"
274 mxlist =
size(this%rlist, 2)
275 ldim =
size(this%rlist, 1)
276 naux =
size(this%auxvar, 1)
279 allocate (cellid(this%ndim))
285 read (this%inlist, iostat=this%ierr) cellid
289 select case (this%ierr)
296 if (ii > mxlist)
then
297 inquire (unit=this%inlist, name=fname)
298 write (
errmsg, fmtmxlsterronly) fname, this%inlist, ii, mxlist
303 if (this%ndim == 1)
then
305 elseif (this%ndim == 2)
then
306 nod =
get_node(cellid(1), 1, cellid(2), &
307 this%mshape(1), 1, this%mshape(2))
309 nod =
get_node(cellid(1), cellid(2), cellid(3), &
310 this%mshape(1), this%mshape(2), this%mshape(3))
312 this%nodelist(ii) = nod
315 read (this%inlist, iostat=this%ierr) (this%rlist(jj, ii), jj=1, ldim), &
316 (this%auxvar(jj, ii), jj=1, naux)
317 if (this%ierr /= 0)
then
318 inquire (unit=this%inlist, name=fname)
319 write (
errmsg, fmtlsterronly) trim(adjustl(fname)), this%inlist
332 inquire (unit=this%inlist, name=fname)
333 write (
errmsg, fmtlsterronly) trim(adjustl(fname)), this%inlist
339 if (this%nlist > 0)
then
340 if (ii == this%nlist)
exit readloop
365 integer(I4B) :: mxlist, ldim, naux
366 integer(I4B) :: ii, jj, idum, nod, istat, increment
368 integer(I4B),
dimension(:),
allocatable :: cellid
369 character(len=LINELENGTH) :: fname
371 character(len=*),
parameter :: fmtmxlsterronly = &
372 "('Error reading list. The number of records encountered exceeds &
373 &the maximum number of records. Number of records found is ',I0,&
374 &' but MAXBOUND is ', I0, '. Try increasing MAXBOUND for this list. &
375 &Error occurred reading the following line: ', a, 5x, '>>> ', a)"
378 mxlist =
size(this%rlist, 2)
379 ldim =
size(this%rlist, 1)
380 naux =
size(this%auxvar, 1)
385 allocate (cellid(this%ndim))
392 call this%line_reader%rdcom(this%inlist, 0, this%line, this%ierr)
396 if (this%nlist < 0)
then
398 call urword(this%line, this%lloc, this%istart, this%istop, 1, idum, r, &
399 this%iout, this%inlist)
400 if (this%line(this%istart:this%istop) ==
'END' .or. this%ierr < 0)
then
403 if (this%ierr == 0)
then
404 call this%line_reader%bkspc(this%inlist)
412 if (ii > mxlist)
then
413 inquire (unit=this%inlist, name=fname)
414 write (
errmsg, fmtmxlsterronly) &
415 ii, mxlist, new_line(
"A"), trim(this%line)
424 call urword(this%line, this%lloc, this%istart, this%istop, 2, &
425 cellid(1), r, this%iout, this%inlist)
426 if (this%ndim > 1)
then
427 call urword(this%line, this%lloc, this%istart, this%istop, 2, &
428 cellid(2), r, this%iout, this%inlist)
430 if (this%ndim > 2)
then
431 call urword(this%line, this%lloc, this%istart, this%istop, 2, &
432 cellid(3), r, this%iout, this%inlist)
439 if (this%ndim == 3)
then
440 nod =
get_node(cellid(1), cellid(2), cellid(3), &
441 this%mshape(1), this%mshape(2), this%mshape(3))
442 elseif (this%ndim == 2)
then
443 nod =
get_node(cellid(1), 1, cellid(2), &
444 this%mshape(1), 1, this%mshape(2))
450 this%nodelist(ii) = nod
454 call urword(this%line, this%lloc, this%istart, this%istop, 0, idum, &
455 r, this%iout, this%inlist)
456 read (this%line(this%istart:this%istop), *, iostat=istat) r
461 this%rlist(jj, ii) = r
463 this%rlist(jj, ii) =
dzero
464 this%ntxtrlist = this%ntxtrlist + 1
465 if (this%ntxtrlist >
size(this%txtrlist))
then
466 increment = int(
size(this%txtrlist) * 0.2)
467 increment = max(100, increment)
472 this%txtrlist(this%ntxtrlist) = this%line(this%istart:this%istop)
473 this%idxtxtrow(this%ntxtrlist) = ii
474 this%idxtxtcol(this%ntxtrlist) = jj
481 call urword(this%line, this%lloc, this%istart, this%istop, 0, idum, &
482 r, this%iout, this%inlist)
483 read (this%line(this%istart:this%istop), *, iostat=istat) r
488 this%auxvar(jj, ii) = r
490 this%auxvar(jj, ii) =
dzero
491 this%ntxtauxvar = this%ntxtauxvar + 1
492 if (this%ntxtauxvar >
size(this%txtauxvar))
then
493 increment = int(
size(this%txtauxvar) * 0.2)
494 increment = max(100, increment)
499 this%txtauxvar(this%ntxtauxvar) = this%line(this%istart:this%istop)
500 this%idxtxtauxrow(this%ntxtauxvar) = ii
501 this%idxtxtauxcol(this%ntxtauxvar) = jj
502 if (len_trim(this%txtauxvar(this%ntxtauxvar)) == 0)
then
503 write (
errmsg,
'(a,i0,a)')
'Auxiliary data or time series name &
504 &expected but not found in period &
505 &block "',
kper,
'".'
514 if (this%inamedbound > 0)
then
515 call urword(this%line, this%lloc, this%istart, this%istop, 1, idum, r, &
516 this%iout, this%inlist)
517 this%boundname(ii) = this%line(this%istart:this%istop)
521 if (this%nlist > 0)
then
522 if (ii == this%nlist)
exit readloop
540 integer(I4B),
intent(in) :: ii
541 integer(I4B),
dimension(:),
intent(in) :: cellid
542 integer(I4B),
dimension(:),
intent(in) :: mshape
543 integer(I4B),
intent(in) :: ndim
545 character(len=20) :: cellstr, mshstr
547 character(len=*),
parameter :: fmterr = &
548 "('List entry ',i0,' contains cellid ',a,' but this cellid is invalid &
549 &for model with shape ', a)"
550 character(len=*),
parameter :: fmtndim1 = &
552 character(len=*),
parameter :: fmtndim2 = &
553 "('(',i0,',',i0,')')"
554 character(len=*),
parameter :: fmtndim3 = &
555 "('(',i0,',',i0,',',i0,')')"
558 if (cellid(1) < 1 .or. cellid(1) > mshape(1))
then
559 write (cellstr, fmtndim1) cellid(1)
560 write (mshstr, fmtndim1) mshape(1)
561 write (
errmsg, fmterr) ii, trim(adjustl(cellstr)), trim(adjustl(mshstr))
564 else if (ndim == 2)
then
565 if (cellid(1) < 1 .or. cellid(1) > mshape(1) .or. &
566 cellid(2) < 1 .or. cellid(2) > mshape(2))
then
567 write (cellstr, fmtndim2) cellid(1), cellid(2)
568 write (mshstr, fmtndim2) mshape(1), mshape(2)
569 write (
errmsg, fmterr) ii, trim(adjustl(cellstr)), trim(adjustl(mshstr))
572 else if (ndim == 3)
then
573 if (cellid(1) < 1 .or. cellid(1) > mshape(1) .or. &
574 cellid(2) < 1 .or. cellid(2) > mshape(2) .or. &
575 cellid(3) < 1 .or. cellid(3) > mshape(3))
then
576 write (cellstr, fmtndim3) cellid(1), cellid(2), cellid(3)
577 write (mshstr, fmtndim3) mshape(1), mshape(2), mshape(3)
578 write (
errmsg, fmterr) ii, trim(adjustl(cellstr)), trim(adjustl(mshstr))
595 character(len=10) :: cpos
596 character(len=LINELENGTH) :: tag
597 character(len=LINELENGTH),
allocatable,
dimension(:) :: words
598 integer(I4B) :: ntabrows
599 integer(I4B) :: ntabcols
601 integer(I4B) :: ii, jj, i, j, k, nod
604 type(
tabletype),
pointer :: inputtab => null()
606 character(len=LINELENGTH) :: fmtlstbn
609 ldim =
size(this%rlist, 1)
610 naux =
size(this%auxvar, 1)
613 ntabrows = this%nlist
617 ipos = index(this%label,
'NO.')
619 write (cpos,
'(i10)') ipos + 3
620 fmtlstbn =
'(a'//trim(adjustl(cpos))
625 if (
size(this%mshape) == 3)
then
627 fmtlstbn = trim(fmtlstbn)//
',a7,a7,a7'
630 else if (
size(this%mshape) == 2)
then
632 fmtlstbn = trim(fmtlstbn)//
',a7,a7'
637 fmtlstbn = trim(fmtlstbn)//
',a7'
641 ntabcols = ntabcols + ldim
643 fmtlstbn = trim(fmtlstbn)//
',a16'
647 if (this%inamedbound == 1)
then
648 ntabcols = ntabcols + 1
649 fmtlstbn = trim(fmtlstbn)//
',a16'
653 ntabcols = ntabcols + naux
655 fmtlstbn = trim(fmtlstbn)//
',a16'
657 fmtlstbn = trim(fmtlstbn)//
')'
660 allocate (words(ntabcols))
663 read (this%label, fmtlstbn) (words(i), i=1, ntabcols)
667 call inputtab%table_df(ntabrows, ntabcols, this%iout)
671 call inputtab%initialize_column(words(ipos), 10, alignment=
tabcenter)
674 do i = 1,
size(this%mshape)
676 call inputtab%initialize_column(words(ipos), 7, alignment=
tabcenter)
682 call inputtab%initialize_column(words(ipos), 16, alignment=
tabcenter)
686 if (this%inamedbound == 1)
then
694 call inputtab%initialize_column(this%auxname(i), 16, alignment=
tabcenter)
698 do ii = 1, this%nlist
699 call inputtab%add_term(ii)
702 if (
size(this%mshape) == 3)
then
703 nod = this%nodelist(ii)
704 call get_ijk(nod, this%mshape(2), this%mshape(3), this%mshape(1), &
706 call inputtab%add_term(k)
707 call inputtab%add_term(i)
708 call inputtab%add_term(j)
709 else if (
size(this%mshape) == 2)
then
710 nod = this%nodelist(ii)
711 call get_ijk(nod, 1, this%mshape(2), this%mshape(1), i, j, k)
712 call inputtab%add_term(k)
713 call inputtab%add_term(j)
715 nod = this%nodelist(ii)
716 call inputtab%add_term(nod)
721 call inputtab%add_term(this%rlist(jj, ii))
725 if (this%inamedbound == 1)
then
726 call inputtab%add_term(this%boundname(ii))
731 call inputtab%add_term(this%auxvar(jj, ii))
736 call inputtab%table_da()
737 deallocate (inputtab)
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
@ tabcenter
centered table column
@ tableft
left justified table column
integer(i4b), parameter lenbigline
maximum length of a big line
integer(i4b), parameter lenlistlabel
maximum length of a llist label
integer(i4b), parameter lentimeseriesname
maximum length of a time series name
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
real(dp), parameter done
real constant 1
integer(i4b) function, public get_node(ilay, irow, icol, nlay, nrow, ncol)
Get node number, given layer, row, and column indices for a structured grid. If any argument is inval...
subroutine, public get_ijk(nodenumber, nrow, ncol, nlay, irow, icol, ilay)
Get row, column and layer indices from node number and grid dimensions. If nodenumber is invalid,...
subroutine, public get_jk(nodenumber, ncpl, nlay, icpl, ilay)
Get layer index and within-layer node index from node number and grid dimensions. If nodenumber is in...
This module defines variable data types.
Generic List Reader Module.
subroutine check_cellid(ii, cellid, mshape, ndim)
Check for valid cellid.
subroutine write_list(this)
Write input data to a list.
subroutine read_binary(this)
Read the data from a binary file.
subroutine read_control_record(this)
Check for a control record, and parse if found.
subroutine set_openclose(this)
Set up for open/close file.
subroutine read_data(this)
Read the data.
subroutine read_list(this, line_reader, in, iout, nlist, inamedbound, mshape, nodelist, rlist, auxvar, auxname, boundname, label)
Initialize the reader.
subroutine read_ascii(this)
Read the data from an ascii file.
This module contains the LongLineReaderType.
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
integer(i4b) function, public count_errors()
Return number of errors.
subroutine, public store_error_unit(iunit, terminate)
Store the file unit number.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
subroutine, public table_cr(this, name, title)
integer(i4b), pointer, public kper
current stress period number