MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
listreadermodule Module Reference

Generic List Reader Module.

Data Types

type  listreadertype
 

Functions/Subroutines

subroutine read_list (this, line_reader, in, iout, nlist, inamedbound, mshape, nodelist, rlist, auxvar, auxname, boundname, label)
 Initialize the reader. More...
 
subroutine read_control_record (this)
 Check for a control record, and parse if found. More...
 
subroutine set_openclose (this)
 Set up for open/close file. More...
 
subroutine read_data (this)
 Read the data. More...
 
subroutine read_binary (this)
 Read the data from a binary file. More...
 
subroutine read_ascii (this)
 Read the data from an ascii file. More...
 
subroutine check_cellid (ii, cellid, mshape, ndim)
 Check for valid cellid. More...
 
subroutine write_list (this)
 Write input data to a list. More...
 

Function/Subroutine Documentation

◆ check_cellid()

subroutine listreadermodule::check_cellid ( integer(i4b), intent(in)  ii,
integer(i4b), dimension(:), intent(in)  cellid,
integer(i4b), dimension(:), intent(in)  mshape,
integer(i4b), intent(in)  ndim 
)
Parameters
[in]mshapemodel shape
[in]ndimsize of mshape

Definition at line 556 of file ListReader.f90.

557  ! -- dummy
558  integer(I4B), intent(in) :: ii
559  integer(I4B), dimension(:), intent(in) :: cellid !< cellid
560  integer(I4B), dimension(:), intent(in) :: mshape !< model shape
561  integer(I4B), intent(in) :: ndim !< size of mshape
562  ! -- local
563  character(len=20) :: cellstr, mshstr
564  ! -- formats
565  character(len=*), parameter :: fmterr = &
566  "('List entry ',i0,' contains cellid ',a,' but this cellid is invalid &
567  &for model with shape ', a)"
568  character(len=*), parameter :: fmtndim1 = &
569  "('(',i0,')')"
570  character(len=*), parameter :: fmtndim2 = &
571  "('(',i0,',',i0,')')"
572  character(len=*), parameter :: fmtndim3 = &
573  "('(',i0,',',i0,',',i0,')')"
574  !
575  if (ndim == 1) then
576  if (cellid(1) < 1 .or. cellid(1) > mshape(1)) then
577  write (cellstr, fmtndim1) cellid(1)
578  write (mshstr, fmtndim1) mshape(1)
579  write (errmsg, fmterr) ii, trim(adjustl(cellstr)), trim(adjustl(mshstr))
580  call store_error(errmsg)
581  end if
582  else if (ndim == 2) then
583  if (cellid(1) < 1 .or. cellid(1) > mshape(1) .or. &
584  cellid(2) < 1 .or. cellid(2) > mshape(2)) then
585  write (cellstr, fmtndim2) cellid(1), cellid(2)
586  write (mshstr, fmtndim2) mshape(1), mshape(2)
587  write (errmsg, fmterr) ii, trim(adjustl(cellstr)), trim(adjustl(mshstr))
588  call store_error(errmsg)
589  end if
590  else if (ndim == 3) then
591  if (cellid(1) < 1 .or. cellid(1) > mshape(1) .or. &
592  cellid(2) < 1 .or. cellid(2) > mshape(2) .or. &
593  cellid(3) < 1 .or. cellid(3) > mshape(3)) then
594  write (cellstr, fmtndim3) cellid(1), cellid(2), cellid(3)
595  write (mshstr, fmtndim3) mshape(1), mshape(2), mshape(3)
596  write (errmsg, fmterr) ii, trim(adjustl(cellstr)), trim(adjustl(mshstr))
597  call store_error(errmsg)
598  end if
599  end if
600  !
601  ! -- Return
602  return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_ascii()

subroutine listreadermodule::read_ascii ( class(listreadertype this)

Definition at line 371 of file ListReader.f90.

372  ! -- modules
374  use inputoutputmodule, only: urword
376  use tdismodule, only: kper
377  ! -- dummy
378  class(ListReaderType) :: this
379  ! -- local
380  integer(I4B) :: mxlist, ldim, naux
381  integer(I4B) :: ii, jj, idum, nod, istat, increment
382  real(DP) :: r
383  integer(I4B), dimension(:), allocatable :: cellid
384  character(len=LINELENGTH) :: fname
385  ! -- formats
386  character(len=*), parameter :: fmtmxlsterronly = &
387  "('Error reading list. The number of records encountered exceeds &
388  &the maximum number of records. Number of records found is ',I0,&
389  &' but MAXBOUND is ', I0, '. Try increasing MAXBOUND for this list. &
390  &Error occurred reading the following line: ', a, 5x, '>>> ', a)"
391  !
392  ! -- Determine array sizes
393  mxlist = size(this%rlist, 2)
394  ldim = size(this%rlist, 1)
395  naux = size(this%auxvar, 1)
396  this%ntxtrlist = 0
397  this%ntxtauxvar = 0
398  !
399  ! -- Allocate arrays
400  allocate (cellid(this%ndim))
401  !
402  ii = 1
403  readloop: do
404  !
405  ! -- First line was already read, so don't read again
406  if (ii /= 1) &
407  call this%line_reader%rdcom(this%inlist, 0, this%line, this%ierr)
408  !
409  ! -- If this is an unknown-length list, then check for END.
410  ! If found, then backspace, set nlist, and exit readloop.
411  if (this%nlist < 0) then
412  this%lloc = 1
413  call urword(this%line, this%lloc, this%istart, this%istop, 1, idum, r, &
414  this%iout, this%inlist)
415  if (this%line(this%istart:this%istop) == 'END' .or. this%ierr < 0) then
416  ! -- If END was found then call line_reader backspace
417  ! emulator so that caller can proceed with reading END.
418  if (this%ierr == 0) then
419  call this%line_reader%bkspc(this%inlist)
420  end if
421  this%nlist = ii - 1
422  exit readloop
423  end if
424  end if
425  !
426  ! -- Check range
427  if (ii > mxlist) then
428  inquire (unit=this%inlist, name=fname)
429  write (errmsg, fmtmxlsterronly) &
430  ii, mxlist, new_line("A"), trim(this%line)
431  call store_error(errmsg)
432  call store_error_unit(this%inlist)
433  end if
434  !
435  ! -- Initialize locator
436  this%lloc = 1
437  !
438  ! -- Read cellid
439  call urword(this%line, this%lloc, this%istart, this%istop, 2, &
440  cellid(1), r, this%iout, this%inlist)
441  if (this%ndim > 1) then
442  call urword(this%line, this%lloc, this%istart, this%istop, 2, &
443  cellid(2), r, this%iout, this%inlist)
444  end if
445  if (this%ndim > 2) then
446  call urword(this%line, this%lloc, this%istart, this%istop, 2, &
447  cellid(3), r, this%iout, this%inlist)
448  end if
449  !
450  ! -- Ensure cellid is valid, store an error otherwise
451  call check_cellid(ii, cellid, this%mshape, this%ndim)
452  !
453  ! -- Calculate user node number
454  if (this%ndim == 3) then
455  nod = get_node(cellid(1), cellid(2), cellid(3), &
456  this%mshape(1), this%mshape(2), this%mshape(3))
457  elseif (this%ndim == 2) then
458  nod = get_node(cellid(1), 1, cellid(2), &
459  this%mshape(1), 1, this%mshape(2))
460  else
461  nod = cellid(1)
462  end if
463  !
464  ! -- Assign nod to nodelist
465  this%nodelist(ii) = nod
466  !
467  ! -- Read rlist
468  do jj = 1, ldim
469  call urword(this%line, this%lloc, this%istart, this%istop, 0, idum, &
470  r, this%iout, this%inlist)
471  read (this%line(this%istart:this%istop), *, iostat=istat) r
472  !
473  ! -- If a double precision value, then store in rlist, otherwise store
474  ! the text name and location
475  if (istat == 0) then
476  this%rlist(jj, ii) = r
477  else
478  this%rlist(jj, ii) = dzero
479  this%ntxtrlist = this%ntxtrlist + 1
480  if (this%ntxtrlist > size(this%txtrlist)) then
481  increment = int(size(this%txtrlist) * 0.2)
482  increment = max(100, increment)
483  call expandarray(this%txtrlist, increment)
484  call expandarray(this%idxtxtrow, increment)
485  call expandarray(this%idxtxtcol, increment)
486  end if
487  this%txtrlist(this%ntxtrlist) = this%line(this%istart:this%istop)
488  this%idxtxtrow(this%ntxtrlist) = ii
489  this%idxtxtcol(this%ntxtrlist) = jj
490  end if
491  !
492  end do
493  !
494  ! -- Read auxvar
495  do jj = 1, naux
496  call urword(this%line, this%lloc, this%istart, this%istop, 0, idum, &
497  r, this%iout, this%inlist)
498  read (this%line(this%istart:this%istop), *, iostat=istat) r
499  !
500  ! -- If a double precision value, then store in auxvar, otherwise store
501  ! the text name and location
502  if (istat == 0) then
503  this%auxvar(jj, ii) = r
504  else
505  this%auxvar(jj, ii) = dzero
506  this%ntxtauxvar = this%ntxtauxvar + 1
507  if (this%ntxtauxvar > size(this%txtauxvar)) then
508  increment = int(size(this%txtauxvar) * 0.2)
509  increment = max(100, increment)
510  call expandarray(this%txtauxvar, increment)
511  call expandarray(this%idxtxtauxrow, increment)
512  call expandarray(this%idxtxtauxcol, increment)
513  end if
514  this%txtauxvar(this%ntxtauxvar) = this%line(this%istart:this%istop)
515  this%idxtxtauxrow(this%ntxtauxvar) = ii
516  this%idxtxtauxcol(this%ntxtauxvar) = jj
517  if (len_trim(this%txtauxvar(this%ntxtauxvar)) == 0) then
518  write (errmsg, '(a,i0,a)') 'Auxiliary data or time series name &
519  &expected but not found in period &
520  &block "', kper, '".'
521  call store_error(errmsg)
522  call store_error_unit(this%inlist)
523  end if
524  end if
525  !
526  end do
527  !
528  ! -- Read the boundary names (only supported for ascii input)
529  if (this%inamedbound > 0) then
530  call urword(this%line, this%lloc, this%istart, this%istop, 1, idum, r, &
531  this%iout, this%inlist)
532  this%boundname(ii) = this%line(this%istart:this%istop)
533  end if
534  !
535  ! -- If nlist is known, then exit when nlist values have been read
536  if (this%nlist > 0) then
537  if (ii == this%nlist) exit readloop
538  end if
539  !
540  ! -- Increment ii row counter
541  ii = ii + 1
542  !
543  end do readloop
544  !
545  ! -- Stop if errors were detected
546  if (count_errors() > 0) then
547  call store_error_unit(this%inlist)
548  end if
549  !
550  ! -- Return
551  return
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:44
integer(i4b), parameter lenboundname
maximum length of a bound name
Definition: Constants.f90:35
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:64
subroutine, public urword(line, icol, istart, istop, ncode, n, r, iout, in)
Extract a word from a string.
integer(i4b), pointer, public kper
current stress period number
Definition: tdis.f90:23
Here is the call graph for this function:

◆ read_binary()

subroutine listreadermodule::read_binary ( class(listreadertype this)
private

Definition at line 265 of file ListReader.f90.

266  ! -- modules
268  ! -- dummy
269  class(ListReaderType) :: this
270  ! -- local
271  integer(I4B) :: mxlist, ldim, naux, nod, ii, jj
272  character(len=LINELENGTH) :: fname
273  integer(I4B), dimension(:), allocatable :: cellid
274  ! -- formats
275  character(len=*), parameter :: fmtmxlsterronly = &
276  "('ERROR READING LIST FROM FILE: ',&
277  &a,' ON UNIT: ',I0,&
278  &' THE NUMBER OF RECORDS ENCOUNTERED EXCEEDS THE MAXIMUM NUMBER &
279  &OF RECORDS. TRY INCREASING MAXBOUND FOR THIS LIST.&
280  & NUMBER OF RECORDS: ',I0,' MAXBOUND: ',I0)"
281  character(len=*), parameter :: fmtlsterronly = &
282  "('ERROR READING LIST FROM FILE: ',&
283  &1x,a,1x,' ON UNIT: ',I0)"
284  !
285  ! -- Determine array sizes
286  mxlist = size(this%rlist, 2)
287  ldim = size(this%rlist, 1)
288  naux = size(this%auxvar, 1)
289  !
290  ! -- Allocate arrays
291  allocate (cellid(this%ndim))
292  !
293  ii = 1
294  readloop: do
295  !
296  ! -- Read layer, row, col, or cell number
297  read (this%inlist, iostat=this%ierr) cellid
298  !
299  ! -- If not end of record, then store nodenumber, else
300  ! calculate lstend and nlist, and exit readloop
301  select case (this%ierr)
302  case (0)
303  !
304  ! -- Ensure cellid is valid, store an error otherwise
305  call check_cellid(ii, cellid, this%mshape, this%ndim)
306  !
307  ! -- Check range
308  if (ii > mxlist) then
309  inquire (unit=this%inlist, name=fname)
310  write (errmsg, fmtmxlsterronly) fname, this%inlist, ii, mxlist
311  call store_error(errmsg, terminate=.true.)
312  end if
313  !
314  ! -- Calculate and store user node number
315  if (this%ndim == 1) then
316  nod = cellid(1)
317  elseif (this%ndim == 2) then
318  nod = get_node(cellid(1), 1, cellid(2), &
319  this%mshape(1), 1, this%mshape(2))
320  else
321  nod = get_node(cellid(1), cellid(2), cellid(3), &
322  this%mshape(1), this%mshape(2), this%mshape(3))
323  end if
324  this%nodelist(ii) = nod
325  !
326  ! -- Read remainder of record
327  read (this%inlist, iostat=this%ierr) (this%rlist(jj, ii), jj=1, ldim), &
328  (this%auxvar(jj, ii), jj=1, naux)
329  if (this%ierr /= 0) then
330  inquire (unit=this%inlist, name=fname)
331  write (errmsg, fmtlsterronly) trim(adjustl(fname)), this%inlist
332  call store_error(errmsg, terminate=.true.)
333  end if
334  !
335  case (:-1)
336  !
337  ! -- End of record was encountered
338  this%nlist = ii - 1
339  exit readloop
340  !
341  case (1:)
342  !
343  ! -- Error
344  inquire (unit=this%inlist, name=fname)
345  write (errmsg, fmtlsterronly) trim(adjustl(fname)), this%inlist
346  call store_error(errmsg, terminate=.true.)
347  !
348  end select
349  !
350  ! -- If nlist is known, then exit when nlist values have been read
351  if (this%nlist > 0) then
352  if (ii == this%nlist) exit readloop
353  end if
354  !
355  ! -- Increment ii
356  ii = ii + 1
357  !
358  end do readloop
359  !
360  ! -- Stop if errors were detected
361  if (count_errors() > 0) then
362  call store_error_unit(this%inlist)
363  end if
364  !
365  ! -- Return
366  return
integer(i4b), parameter lenbigline
maximum length of a big line
Definition: Constants.f90:15
Here is the call graph for this function:

◆ read_control_record()

subroutine listreadermodule::read_control_record ( class(listreadertype this)

Definition at line 125 of file ListReader.f90.

126  ! -- modules
127  use inputoutputmodule, only: urword
128  ! -- dummy
129  class(ListReaderType) :: this
130  ! -- local
131  integer(I4B) :: idum
132  real(DP) :: r
133  ! -- formats
134  character(len=*), parameter :: fmtlsf = &
135  "(1X,'LIST SCALING FACTOR=',1PG12.5)"
136  !
137  ! -- Set default values, which may be changed by control record
138  this%inlist = this%in
139  this%iclose = 0
140  this%ibinary = 0
141  !
142  ! -- Read to the first non-commented line
143  call this%line_reader%rdcom(this%in, this%iout, this%line, this%ierr)
144  this%lloc = 1
145  call urword(this%line, this%lloc, this%istart, this%istop, 1, idum, r, &
146  this%iout, this%in)
147  !
148  ! -- Parse record
149  select case (this%line(this%istart:this%istop))
150  case ('OPEN/CLOSE')
151  call this%set_openclose()
152  end select
153  !
154  ! -- Return
155  return
Here is the call graph for this function:

◆ read_data()

subroutine listreadermodule::read_data ( class(listreadertype this)

Definition at line 243 of file ListReader.f90.

244  ! -- dummy
245  class(ListReaderType) :: this
246  !
247  ! -- Read the list
248  if (this%ibinary == 1) then
249  call this%read_binary()
250  else
251  call this%read_ascii()
252  end if
253  !
254  ! -- If open/close, then close file
255  if (this%iclose == 1) then
256  close (this%inlist)
257  end if
258  !
259  ! -- Return
260  return

◆ read_list()

subroutine listreadermodule::read_list ( class(listreadertype this,
type(longlinereadertype), intent(inout), target  line_reader,
integer(i4b), intent(in)  in,
integer(i4b), intent(in)  iout,
integer(i4b), intent(inout)  nlist,
integer(i4b), intent(in)  inamedbound,
integer(i4b), dimension(:), intent(in), pointer, contiguous  mshape,
integer(i4b), dimension(:), intent(inout), pointer, contiguous  nodelist,
real(dp), dimension(:, :), intent(inout), pointer, contiguous  rlist,
real(dp), dimension(:, :), intent(inout), pointer, contiguous  auxvar,
character(len=lenauxname), dimension(:), intent(inout), target  auxname,
character(len=lenboundname), dimension(:), intent(inout), pointer, contiguous  boundname,
character(len=lenlistlabel), intent(in)  label 
)
private

Definition at line 64 of file ListReader.f90.

67  ! -- modules
68  use constantsmodule, only: lenboundname
69  ! -- dummy
70  class(ListReaderType) :: this
71  type(LongLineReaderType), intent(inout), target :: line_reader
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
84  !
85  ! -- Copy variables
86  this%in = in
87  this%iout = iout
88  this%nlist = nlist
89  this%inamedbound = inamedbound
90  this%ndim = size(mshape)
91  this%label = label
92  !
93  ! -- Set pointers
94  this%mshape => mshape
95  this%nodelist => nodelist
96  this%rlist => rlist
97  this%auxvar => auxvar
98  this%auxname => auxname
99  this%boundname => boundname
100  this%line_reader => line_reader
101  !
102  ! -- Allocate arrays for storing text and text locations
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))
109  !
110  ! -- Read control record
111  call this%read_control_record()
112  !
113  ! -- Read data
114  call this%read_data()
115  !
116  ! -- Set nlist for return
117  nlist = this%nlist
118  !
119  ! -- Return
120  return

◆ set_openclose()

subroutine listreadermodule::set_openclose ( class(listreadertype this)

OPEN/CLOSE fname [(BINARY)]

Definition at line 162 of file ListReader.f90.

163  ! -- modules
164  use inputoutputmodule, only: urword, openfile
165  use openspecmodule, only: form, access
166  use constantsmodule, only: linelength
167  ! -- dummy
168  class(ListReaderType) :: this
169  ! -- local
170  integer(I4B) :: idum, itmp
171  real(DP) :: r
172  logical :: exists
173  integer(I4B) :: nunopn = 99
174  character(len=LINELENGTH) :: fname
175  ! -- formats
176  character(len=*), parameter :: fmtocne = &
177  &"('Specified OPEN/CLOSE file ',(A),' does not exist')"
178  character(len=*), parameter :: fmtobf = &
179  &"(1X,/1X,'OPENING BINARY FILE ON UNIT ',I0,':',/1X,A)"
180  character(len=*), parameter :: fmtobfnlist = &
181  &"(1X, 'TO READ ', I0, ' RECORDS.')"
182  character(len=*), parameter :: fmtofnlist = &
183  &"(1x,'TO READ ', I0, ' RECORDS.')"
184  character(len=*), parameter :: fmtof = &
185  &"(1X,/1X,'OPENING FILE ON UNIT ',I0,':',/1X,A)"
186  !
187  ! -- Get filename
188  call urword(this%line, this%lloc, this%istart, this%istop, 0, idum, r, &
189  this%iout, this%in)
190  fname = this%line(this%istart:this%istop)
191  !
192  ! -- Check to see if file OPEN/CLOSE file exists
193  inquire (file=fname, exist=exists)
194  if (.not. exists) then
195  write (errmsg, fmtocne) this%line(this%istart:this%istop)
196  call store_error(errmsg)
197  call store_error('Specified OPEN/CLOSE file does not exist')
198  call store_error_unit(this%in)
199  end if
200  !
201  ! -- Check for (BINARY) keyword
202  call urword(this%line, this%lloc, this%istart, this%istop, 1, idum, r, &
203  this%iout, this%in)
204  if (this%line(this%istart:this%istop) == '(BINARY)') this%ibinary = 1
205  !
206  ! -- Open the file depending on ibinary flag
207  this%inlist = nunopn
208  if (this%ibinary == 1) then
209  itmp = this%iout
210  if (this%iout > 0) then
211  itmp = 0
212  write (this%iout, fmtobf) this%inlist, trim(adjustl(fname))
213  if (this%nlist > 0) write (this%iout, fmtobfnlist) this%nlist
214  end if
215  call openfile(this%inlist, itmp, fname, 'OPEN/CLOSE', fmtarg_opt=form, &
216  accarg_opt=access)
217  else
218  itmp = this%iout
219  if (this%iout > 0) then
220  itmp = 0
221  write (this%iout, fmtof) this%inlist, trim(adjustl(fname))
222  if (this%nlist > 0) write (this%iout, fmtofnlist) this%nlist
223  end if
224  call openfile(this%inlist, itmp, fname, 'OPEN/CLOSE')
225  end if
226  !
227  ! -- Set iclose to 1 because it is open/close, to indicate that the
228  ! file needs to be closed after the list is read
229  this%iclose = 1
230  !
231  ! -- Read the first line from inlist to be consistent with how the list is
232  ! read when it is included in the package input file
233  if (this%ibinary /= 1) &
234  call this%line_reader%rdcom(this%inlist, this%iout, this%line, &
235  this%ierr)
236  !
237  ! -- Return
238  return
subroutine, public openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, filstat_opt, mode_opt)
Open a file.
Definition: InputOutput.f90:30
character(len=20) access
Definition: OpenSpec.f90:7
character(len=20) form
Definition: OpenSpec.f90:7
Here is the call graph for this function:

◆ write_list()

subroutine listreadermodule::write_list ( class(listreadertype this)
private

Definition at line 607 of file ListReader.f90.

608  ! -- modules
611  use inputoutputmodule, only: ulstlb
612  use tablemodule, only: tabletype, table_cr
613  ! -- dummy
614  class(ListReaderType) :: this
615  ! -- local
616  character(len=10) :: cpos
617  character(len=LINELENGTH) :: tag
618  character(len=LINELENGTH), allocatable, dimension(:) :: words
619  integer(I4B) :: ntabrows
620  integer(I4B) :: ntabcols
621  integer(I4B) :: ipos
622  integer(I4B) :: ii, jj, i, j, k, nod
623  integer(I4B) :: ldim
624  integer(I4B) :: naux
625  type(TableType), pointer :: inputtab => null()
626  ! -- formats
627  character(len=LINELENGTH) :: fmtlstbn
628  !
629  ! -- Determine sizes
630  ldim = size(this%rlist, 1)
631  naux = size(this%auxvar, 1)
632  !
633  ! -- Dimension table
634  ntabrows = this%nlist
635  !
636  ! -- Start building format statement to parse this%label, which
637  ! contains the column headers (except for boundname and auxnames)
638  ipos = index(this%label, 'NO.')
639  if (ipos /= 0) then
640  write (cpos, '(i10)') ipos + 3
641  fmtlstbn = '(a'//trim(adjustl(cpos))
642  else
643  fmtlstbn = '(a7'
644  end if
645  ! -- Sequence number, layer, row, and column.
646  if (size(this%mshape) == 3) then
647  ntabcols = 4
648  fmtlstbn = trim(fmtlstbn)//',a7,a7,a7'
649  !
650  ! -- Sequence number, layer, and cell2d.
651  else if (size(this%mshape) == 2) then
652  ntabcols = 3
653  fmtlstbn = trim(fmtlstbn)//',a7,a7'
654  !
655  ! -- Sequence number and node.
656  else
657  ntabcols = 2
658  fmtlstbn = trim(fmtlstbn)//',a7'
659  end if
660  !
661  ! -- Add fields for non-optional real values
662  ntabcols = ntabcols + ldim
663  do i = 1, ldim
664  fmtlstbn = trim(fmtlstbn)//',a16'
665  end do
666  !
667  ! -- Add field for boundary name
668  if (this%inamedbound == 1) then
669  ntabcols = ntabcols + 1
670  fmtlstbn = trim(fmtlstbn)//',a16'
671  end if
672  !
673  ! -- Add fields for auxiliary variables
674  ntabcols = ntabcols + naux
675  do i = 1, naux
676  fmtlstbn = trim(fmtlstbn)//',a16'
677  end do
678  fmtlstbn = trim(fmtlstbn)//')'
679  !
680  ! -- Allocate words
681  allocate (words(ntabcols))
682  !
683  ! -- Parse this%label into words
684  read (this%label, fmtlstbn) (words(i), i=1, ntabcols)
685  !
686  ! -- Initialize the input table object
687  call table_cr(inputtab, ' ', ' ')
688  call inputtab%table_df(ntabrows, ntabcols, this%iout)
689  !
690  ! -- Add the columns
691  ipos = 1
692  call inputtab%initialize_column(words(ipos), 10, alignment=tabcenter)
693  !
694  ! -- Discretization
695  do i = 1, size(this%mshape)
696  ipos = ipos + 1
697  call inputtab%initialize_column(words(ipos), 7, alignment=tabcenter)
698  end do
699  !
700  ! -- Non-optional variables
701  do i = 1, ldim
702  ipos = ipos + 1
703  call inputtab%initialize_column(words(ipos), 16, alignment=tabcenter)
704  end do
705  !
706  ! -- Boundname
707  if (this%inamedbound == 1) then
708  ipos = ipos + 1
709  tag = 'BOUNDNAME'
710  call inputtab%initialize_column(tag, lenboundname, alignment=tableft)
711  end if
712  !
713  ! -- Aux variables
714  do i = 1, naux
715  call inputtab%initialize_column(this%auxname(i), 16, alignment=tabcenter)
716  end do
717  !
718  ! -- Write the table
719  do ii = 1, this%nlist
720  call inputtab%add_term(ii)
721  !
722  ! -- Discretization
723  if (size(this%mshape) == 3) then
724  nod = this%nodelist(ii)
725  call get_ijk(nod, this%mshape(2), this%mshape(3), this%mshape(1), &
726  i, j, k)
727  call inputtab%add_term(k)
728  call inputtab%add_term(i)
729  call inputtab%add_term(j)
730  else if (size(this%mshape) == 2) then
731  nod = this%nodelist(ii)
732  call get_ijk(nod, 1, this%mshape(2), this%mshape(1), i, j, k)
733  call inputtab%add_term(k)
734  call inputtab%add_term(j)
735  else
736  nod = this%nodelist(ii)
737  call inputtab%add_term(nod)
738  end if
739  !
740  ! -- Non-optional variables
741  do jj = 1, ldim
742  call inputtab%add_term(this%rlist(jj, ii))
743  end do
744  !
745  ! -- Boundname
746  if (this%inamedbound == 1) then
747  call inputtab%add_term(this%boundname(ii))
748  end if
749  !
750  ! -- Aux variables
751  do jj = 1, naux
752  call inputtab%add_term(this%auxvar(jj, ii))
753  end do
754  end do
755  !
756  ! -- Deallocate the local variables
757  call inputtab%table_da()
758  deallocate (inputtab)
759  nullify (inputtab)
760  deallocate (words)
761  !
762  ! -- Return
763  return
@ tabcenter
centered table column
Definition: Constants.f90:171
@ tableft
left justified table column
Definition: Constants.f90:170
subroutine, public ulstlb(iout, label, caux, ncaux, naux)
Print a label for a list.
subroutine, public table_cr(this, name, title)
Definition: Table.f90:85
Here is the call graph for this function: