MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
inputoutputmodule Module Reference

Functions/Subroutines

subroutine, public openfile (iu, iout, fname, ftype, fmtarg_opt, accarg_opt, filstat_opt, mode_opt)
 Open a file. More...
 
subroutine freeunitnumber (iu)
 Assign a free unopened unit number. More...
 
integer(i4b) function, public getunit ()
 Get a free unit number. More...
 
subroutine, public upcase (word)
 Convert to upper case. More...
 
subroutine, public lowcase (word)
 Convert to lower case. More...
 
subroutine, public append_processor_id (name, proc_id)
 Append processor id to a string. More...
 
subroutine, public uwword (line, icol, ilen, ncode, c, n, r, fmt, alignment, sep)
 Create a formatted line. More...
 
subroutine, public urword (line, icol, istart, istop, ncode, n, r, iout, in)
 Extract a word from a string. More...
 
subroutine, public ulstlb (iout, label, caux, ncaux, naux)
 Print a label for a list. More...
 
subroutine, public ubdsv4 (kstp, kper, text, naux, auxtxt, ibdchn, ncol, nrow, nlay, nlist, iout, delt, pertim, totim)
 Write header records for cell-by-cell flow terms for one component of flow plus auxiliary data using a list structure. More...
 
subroutine, public ubdsvb (ibdchn, icrl, q, val, nvl, naux, laux)
 Write one value of cell-by-cell flow plus auxiliary data using a list structure. More...
 
subroutine, public ucolno (nlbl1, nlbl2, nspace, ncpl, ndig, iout)
 Output column numbers above a matrix printout. More...
 
subroutine, public ulaprw (buf, text, kstp, kper, ncol, nrow, ilay, iprn, iout)
 Print 1 layer array. More...
 
subroutine, public ulasav (buf, text, kstp, kper, pertim, totim, ncol, nrow, ilay, ichn)
 Save 1 layer array on disk. More...
 
subroutine, public ubdsv1 (kstp, kper, text, ibdchn, buff, ncol, nrow, nlay, iout, delt, pertim, totim)
 Record cell-by-cell flow terms for one component of flow as a 3-D array with extra record to indicate delt, pertim, and totim. More...
 
subroutine, public ubdsv06 (kstp, kper, text, modelnam1, paknam1, modelnam2, paknam2, ibdchn, naux, auxtxt, ncol, nrow, nlay, nlist, iout, delt, pertim, totim)
 Write header records for cell-by-cell flow terms for one component of flow. More...
 
subroutine, public ubdsvc (ibdchn, n, q, naux, aux)
 Write one value of cell-by-cell flow using a list structure. More...
 
subroutine, public ubdsvd (ibdchn, n, n2, q, naux, aux)
 Write one value of cell-by-cell flow using a list structure. More...
 
logical function, public same_word (word1, word2)
 Perform a case-insensitive comparison of two words. More...
 
character(len=max(len_trim(str), width)) function, public str_pad_left (str, width)
 Function for string manipulation. More...
 
subroutine, public unitinquire (iu)
 
subroutine, public parseline (line, nwords, words, inunit, filename)
 Parse a line into words. More...
 
subroutine, public ulaprufw (ncol, nrow, kstp, kper, ilay, iout, buf, text, userfmt, nvalues, nwidth, editdesc)
 Print 1 layer array with user formatting in wrap format. More...
 
character(len=:) function, allocatable, public read_line (iu, eof)
 This function reads a line of arbitrary length and returns it. More...
 
subroutine, public getfilefrompath (pathname, filename)
 
subroutine, public extract_idnum_or_bndname (line, icol, istart, istop, idnum, bndname)
 Starting at position icol, define string as line(istart:istop). More...
 
subroutine, public urdaux (naux, inunit, iout, lloc, istart, istop, auxname, line, text)
 Read auxiliary variables from an input line. More...
 
subroutine, public print_format (linein, cdatafmp, editdesc, nvaluesp, nwidthp, inunit)
 Define the print or save format. More...
 
subroutine, public buildfixedformat (nvalsp, nwidp, ndig, outfmt, prowcolnum)
 Build a fixed format for printing or saving a real array. More...
 
subroutine, public buildfloatformat (nvalsp, nwidp, ndig, editdesc, outfmt, prowcolnum)
 Build a floating-point format for printing or saving a real array. More...
 
subroutine, public buildintformat (nvalsp, nwidp, outfmt, prowcolnum)
 Build a format for printing or saving an integer array. More...
 
integer(i4b) function, public get_nwords (line)
 Get the number of words in a string. More...
 
subroutine, public fseek_stream (iu, offset, whence, status)
 Move the file pointer. More...
 
subroutine, public u9rdcom (iin, iout, line, ierr)
 Read until non-comment line found and then return line. More...
 
subroutine get_line (lun, line, iostat)
 Read an unlimited length line from unit number lun into a deferred- length character string (line). More...
 

Function/Subroutine Documentation

◆ append_processor_id()

subroutine, public inputoutputmodule::append_processor_id ( character(len=linelength), intent(inout)  name,
integer(i4b), intent(in)  proc_id 
)

Subroutine to append the processor id to a string before the file extension (extension is the string after the last '.' in the string. If there is no '.' in the string the processor id is appended to the end of the string.

Parameters
[in,out]namefile name
[in]proc_idprocessor id

Definition at line 235 of file InputOutput.f90.

236  ! -- dummy
237  character(len=LINELENGTH), intent(inout) :: name !< file name
238  integer(I4B), intent(in) :: proc_id !< processor id
239  ! -- local
240  character(len=LINELENGTH) :: name_local
241  character(len=LINELENGTH) :: name_processor
242  character(len=LINELENGTH) :: extension_local
243  integer(I4B) :: ipos0
244  integer(I4B) :: ipos1
245  !
246  name_local = name
247  call lowcase(name_local)
248  ipos0 = index(name_local, ".", back=.true.)
249  ipos1 = len_trim(name)
250  if (ipos0 > 0) then
251  write (extension_local, '(a)') name(ipos0:ipos1)
252  else
253  ipos0 = ipos1
254  extension_local = ''
255  end if
256  write (name_processor, '(a,a,i0,a)') &
257  name(1:ipos0 - 1), '.p', proc_id, trim(adjustl(extension_local))
258  name = name_processor
Here is the call graph for this function:
Here is the caller graph for this function:

◆ buildfixedformat()

subroutine, public inputoutputmodule::buildfixedformat ( integer(i4b), intent(in)  nvalsp,
integer(i4b), intent(in)  nwidp,
integer(i4b), intent(in)  ndig,
character(len=*), intent(inout)  outfmt,
logical, intent(in), optional  prowcolnum 
)

Definition at line 1505 of file InputOutput.f90.

1506  implicit none
1507  ! -- dummy
1508  integer(I4B), intent(in) :: nvalsp, nwidp, ndig
1509  character(len=*), intent(inout) :: outfmt
1510  logical, intent(in), optional :: prowcolnum ! default true
1511  ! -- local
1512  character(len=8) :: cvalues, cwidth, cdigits
1513  character(len=60) :: ufmt
1514  logical :: prowcolnumlocal
1515  ! -- formats
1516  character(len=*), parameter :: fmtndig = "(i8)"
1517  !
1518  if (present(prowcolnum)) then
1519  prowcolnumlocal = prowcolnum
1520  else
1521  prowcolnumlocal = .true.
1522  end if
1523  !
1524  ! -- Convert integers to characters and left-adjust
1525  write (cdigits, fmtndig) ndig
1526  cdigits = adjustl(cdigits)
1527  !
1528  ! -- Build format for printing to the list file in wrap format
1529  write (cvalues, fmtndig) nvalsp
1530  cvalues = adjustl(cvalues)
1531  write (cwidth, fmtndig) nwidp
1532  cwidth = adjustl(cwidth)
1533  if (prowcolnumlocal) then
1534  ufmt = '(1x,i3,1x,'
1535  else
1536  ufmt = '(5x,'
1537  end if
1538  !
1539  ufmt = trim(ufmt)//cvalues
1540  ufmt = trim(ufmt)//'(1x,f'
1541  ufmt = trim(ufmt)//cwidth
1542  ufmt = trim(ufmt)//'.'
1543  ufmt = trim(ufmt)//cdigits
1544  ufmt = trim(ufmt)//'):/(5x,'
1545  ufmt = trim(ufmt)//cvalues
1546  ufmt = trim(ufmt)//'(1x,f'
1547  ufmt = trim(ufmt)//cwidth
1548  ufmt = trim(ufmt)//'.'
1549  ufmt = trim(ufmt)//cdigits
1550  ufmt = trim(ufmt)//')))'
1551  outfmt = ufmt
Here is the caller graph for this function:

◆ buildfloatformat()

subroutine, public inputoutputmodule::buildfloatformat ( integer(i4b), intent(in)  nvalsp,
integer(i4b), intent(in)  nwidp,
integer(i4b), intent(in)  ndig,
character(len=*), intent(in)  editdesc,
character(len=*), intent(inout)  outfmt,
logical, intent(in), optional  prowcolnum 
)

Definition at line 1556 of file InputOutput.f90.

1557  implicit none
1558  ! -- dummy
1559  integer(I4B), intent(in) :: nvalsp, nwidp, ndig
1560  character(len=*), intent(in) :: editdesc
1561  character(len=*), intent(inout) :: outfmt
1562  logical, intent(in), optional :: prowcolnum ! default true
1563  ! -- local
1564  character(len=8) :: cvalues, cwidth, cdigits
1565  character(len=60) :: ufmt
1566  logical :: prowcolnumlocal
1567  ! -- formats
1568  character(len=*), parameter :: fmtndig = "(i8)"
1569  !
1570  if (present(prowcolnum)) then
1571  prowcolnumlocal = prowcolnum
1572  else
1573  prowcolnumlocal = .true.
1574  end if
1575  !
1576  ! -- Build the format
1577  write (cdigits, fmtndig) ndig
1578  cdigits = adjustl(cdigits)
1579  ! -- Convert integers to characters and left-adjust
1580  write (cwidth, fmtndig) nwidp
1581  cwidth = adjustl(cwidth)
1582  ! -- Build format for printing to the list file
1583  write (cvalues, fmtndig) (nvalsp - 1)
1584  cvalues = adjustl(cvalues)
1585  if (prowcolnumlocal) then
1586  ufmt = '(1x,i3,2x,1p,'//editdesc
1587  else
1588  ufmt = '(6x,1p,'//editdesc
1589  end if
1590  ufmt = trim(ufmt)//cwidth
1591  ufmt = trim(ufmt)//'.'
1592  ufmt = trim(ufmt)//cdigits
1593  if (nvalsp > 1) then
1594  ufmt = trim(ufmt)//','
1595  ufmt = trim(ufmt)//cvalues
1596  ufmt = trim(ufmt)//'(1x,'
1597  ufmt = trim(ufmt)//editdesc
1598  ufmt = trim(ufmt)//cwidth
1599  ufmt = trim(ufmt)//'.'
1600  ufmt = trim(ufmt)//cdigits
1601  ufmt = trim(ufmt)//')'
1602  end if
1603  !
1604  ufmt = trim(ufmt)//':/(5x,'
1605  write (cvalues, fmtndig) nvalsp
1606  cvalues = adjustl(cvalues)
1607  ufmt = trim(ufmt)//cvalues
1608  ufmt = trim(ufmt)//'(1x,'
1609  ufmt = trim(ufmt)//editdesc
1610  ufmt = trim(ufmt)//cwidth
1611  ufmt = trim(ufmt)//'.'
1612  ufmt = trim(ufmt)//cdigits
1613  ufmt = trim(ufmt)//')))'
1614  outfmt = ufmt
Here is the caller graph for this function:

◆ buildintformat()

subroutine, public inputoutputmodule::buildintformat ( integer(i4b), intent(in)  nvalsp,
integer(i4b), intent(in)  nwidp,
character(len=*), intent(inout)  outfmt,
logical, intent(in), optional  prowcolnum 
)

Definition at line 1619 of file InputOutput.f90.

1620  implicit none
1621  ! -- dummy
1622  integer(I4B), intent(in) :: nvalsp, nwidp
1623  character(len=*), intent(inout) :: outfmt
1624  logical, intent(in), optional :: prowcolnum ! default true
1625  ! -- local
1626  character(len=8) :: cvalues, cwidth
1627  character(len=60) :: ufmt
1628  logical :: prowcolnumlocal
1629  ! -- formats
1630  character(len=*), parameter :: fmtndig = "(i8)"
1631  !
1632  if (present(prowcolnum)) then
1633  prowcolnumlocal = prowcolnum
1634  else
1635  prowcolnumlocal = .true.
1636  end if
1637  !
1638  ! -- Build format for printing to the list file in wrap format
1639  write (cvalues, fmtndig) nvalsp
1640  cvalues = adjustl(cvalues)
1641  write (cwidth, fmtndig) nwidp
1642  cwidth = adjustl(cwidth)
1643  if (prowcolnumlocal) then
1644  ufmt = '(1x,i3,1x,'
1645  else
1646  ufmt = '(5x,'
1647  end if
1648  ufmt = trim(ufmt)//cvalues
1649  ufmt = trim(ufmt)//'(1x,i'
1650  ufmt = trim(ufmt)//cwidth
1651  ufmt = trim(ufmt)//'):/(5x,'
1652  ufmt = trim(ufmt)//cvalues
1653  ufmt = trim(ufmt)//'(1x,i'
1654  ufmt = trim(ufmt)//cwidth
1655  ufmt = trim(ufmt)//')))'
1656  outfmt = ufmt
Here is the caller graph for this function:

◆ extract_idnum_or_bndname()

subroutine, public inputoutputmodule::extract_idnum_or_bndname ( character(len=*), intent(inout)  line,
integer(i4b), intent(inout)  icol,
integer(i4b), intent(inout)  istart,
integer(i4b), intent(inout)  istop,
integer(i4b), intent(out)  idnum,
character(len=lenboundname), intent(out)  bndname 
)

If string can be interpreted as an integer(I4B), return integer in idnum argument. If token is not an integer(I4B), assume it is a boundary name, return NAMEDBOUNDFLAG in idnum, convert string to uppercase and return it in bndname.

Definition at line 1291 of file InputOutput.f90.

1292  implicit none
1293  ! -- dummy
1294  character(len=*), intent(inout) :: line
1295  integer(I4B), intent(inout) :: icol, istart, istop
1296  integer(I4B), intent(out) :: idnum
1297  character(len=LENBOUNDNAME), intent(out) :: bndname
1298  ! -- local
1299  integer(I4B) :: istat, ndum, ncode = 0
1300  real(DP) :: rdum
1301  !
1302  call urword(line, icol, istart, istop, ncode, ndum, rdum, 0, 0)
1303  read (line(istart:istop), *, iostat=istat) ndum
1304  if (istat == 0) then
1305  idnum = ndum
1306  bndname = ''
1307  else
1308  idnum = namedboundflag
1309  bndname = line(istart:istop)
1310  call upcase(bndname)
1311  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freeunitnumber()

subroutine inputoutputmodule::freeunitnumber ( integer(i4b), intent(inout)  iu)

Subroutine to assign a free unopened unit number to the iu dummy argument

Parameters
[in,out]iunext free file unit number

Definition at line 148 of file InputOutput.f90.

149  ! -- modules
150  implicit none
151  ! -- dummy
152  integer(I4B), intent(inout) :: iu !< next free file unit number
153  ! -- local
154  integer(I4B) :: i
155  logical :: opened
156  !
157  do i = iunext, iulast
158  inquire (unit=i, opened=opened)
159  if (.not. opened) exit
160  end do
161  iu = i
162  iunext = iu + 1
Here is the caller graph for this function:

◆ fseek_stream()

subroutine, public inputoutputmodule::fseek_stream ( integer(i4b), intent(in)  iu,
integer(i4b), intent(in)  offset,
integer(i4b), intent(in)  whence,
integer(i4b), intent(inout)  status 
)

Patterned after fseek, which is not supported as part of the fortran standard. For this subroutine to work the file must have been opened with access='stream' and action='readwrite'.

Definition at line 1693 of file InputOutput.f90.

1694  ! -- dummy
1695  integer(I4B), intent(in) :: iu
1696  integer(I4B), intent(in) :: offset
1697  integer(I4B), intent(in) :: whence
1698  integer(I4B), intent(inout) :: status
1699  ! -- local
1700  integer(I8B) :: ipos
1701  !
1702  inquire (unit=iu, size=ipos)
1703  !
1704  select case (whence)
1705  case (0)
1706  !
1707  ! -- whence = 0, offset is relative to start of file
1708  ipos = 0 + offset
1709  case (1)
1710  !
1711  ! -- whence = 1, offset is relative to current pointer position
1712  inquire (unit=iu, pos=ipos)
1713  ipos = ipos + offset
1714  case (2)
1715  !
1716  ! -- whence = 2, offset is relative to end of file
1717  inquire (unit=iu, size=ipos)
1718  ipos = ipos + offset
1719  end select
1720  !
1721  ! -- position the file pointer to ipos
1722  write (iu, pos=ipos, iostat=status)
1723  inquire (unit=iu, pos=ipos)
Here is the caller graph for this function:

◆ get_line()

subroutine inputoutputmodule::get_line ( integer(i4b), intent(in)  lun,
character(len=:), intent(out), allocatable  line,
integer(i4b), intent(out)  iostat 
)
private

Tack on a single space to the end so that routines like URWORD continue to function as before.

Definition at line 1829 of file InputOutput.f90.

1830  ! -- dummy
1831  integer(I4B), intent(in) :: lun
1832  character(len=:), intent(out), allocatable :: line
1833  integer(I4B), intent(out) :: iostat
1834  ! -- local
1835  integer(I4B), parameter :: buffer_len = maxcharlen
1836  character(len=buffer_len) :: buffer
1837  character(len=:), allocatable :: linetemp
1838  integer(I4B) :: size_read, linesize
1839  character(len=1), parameter :: cr = char(13)
1840  character(len=1), parameter :: lf = char(10)
1841  !
1842  ! -- initialize
1843  line = ''
1844  linetemp = ''
1845  !
1846  ! -- process
1847  do
1848  read (lun, '(A)', iostat=iostat, advance='no', size=size_read) buffer
1849  if (is_iostat_eor(iostat)) then
1850  linesize = len(line)
1851  deallocate (linetemp)
1852  allocate (character(len=linesize) :: linetemp)
1853  linetemp(:) = line(:)
1854  deallocate (line)
1855  allocate (character(len=linesize + size_read + 1) :: line)
1856  line(:) = linetemp(:)
1857  line(linesize + 1:) = buffer(:size_read)
1858  linesize = len(line)
1859  line(linesize:linesize) = ' '
1860  iostat = 0
1861  exit
1862  else if (iostat == 0) then
1863  linesize = len(line)
1864  deallocate (linetemp)
1865  allocate (character(len=linesize) :: linetemp)
1866  linetemp(:) = line(:)
1867  deallocate (line)
1868  allocate (character(len=linesize + size_read) :: line)
1869  line(:) = linetemp(:)
1870  line(linesize + 1:) = buffer(:size_read)
1871  else
1872  exit
1873  end if
1874  end do
1875  !
1876  ! -- look for undetected end-of-record with isolated CR or LF
1877  linesize = len(line)
1878  crlfcheck: do i = 1, linesize
1879  if (line(i:i) .eq. cr .or. line(i:i) .eq. lf) then
1880  if (line(i:i) .eq. cr) then
1881  write (errmsg, '(a)') &
1882  'get_line: Found an isolated Carriage Return.'
1883  end if
1884  if (line(i:i) .eq. lf) then
1885  write (errmsg, '(a)') &
1886  'get_line: Found an isolated Line Feed.'
1887  end if
1888  write (errmsg, '(a,1x,a,a)') trim(errmsg), &
1889  'Replace with Carriage Return and Line Feed to', &
1890  ' read as two separate lines.'
1891  write (errmsg, '(a,1x,5a)') trim(errmsg), &
1892  'Line: "', line(1:i - 1), '|', line(i + 1:linesize), '"'
1893  call store_error(errmsg, terminate=.false.)
1894  call store_error_unit(lun, terminate=.true.)
1895  end if
1896  end do crlfcheck
Here is the caller graph for this function:

◆ get_nwords()

integer(i4b) function, public inputoutputmodule::get_nwords ( character(len=*), intent(in)  line)
Returns
number of words in a string

Definition at line 1661 of file InputOutput.f90.

1662  ! -- return
1663  integer(I4B) :: get_nwords !< number of words in a string
1664  ! -- dummy
1665  character(len=*), intent(in) :: line !< line
1666  ! -- local
1667  integer(I4B) :: linelen
1668  integer(I4B) :: lloc
1669  integer(I4B) :: istart
1670  integer(I4B) :: istop
1671  integer(I4B) :: idum
1672  real(DP) :: rdum
1673  !
1674  ! -- initialize variables
1675  get_nwords = 0
1676  linelen = len(line)
1677  !
1678  ! -- Count words in line and allocate words array
1679  lloc = 1
1680  do
1681  call urword(line, lloc, istart, istop, 0, idum, rdum, 0, 0)
1682  if (istart == linelen) exit
1683  get_nwords = get_nwords + 1
1684  end do
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getfilefrompath()

subroutine, public inputoutputmodule::getfilefrompath ( character(len=*), intent(in)  pathname,
character(len=*), intent(out)  filename 
)

Definition at line 1255 of file InputOutput.f90.

1256  implicit none
1257  ! -- dummy
1258  character(len=*), intent(in) :: pathname
1259  character(len=*), intent(out) :: filename
1260  ! -- local
1261  integer(I4B) :: i, istart, istop, lenpath
1262  character(len=1) :: fs = '/'
1263  character(len=1) :: bs = '\'
1264  !
1265  filename = ''
1266  lenpath = len_trim(pathname)
1267  istart = 1
1268  istop = lenpath
1269  loop: do i = lenpath, 1, -1
1270  if (pathname(i:i) == fs .or. pathname(i:i) == bs) then
1271  if (i == istop) then
1272  istop = istop - 1
1273  else
1274  istart = i + 1
1275  exit loop
1276  end if
1277  end if
1278  end do loop
1279  if (istop >= istart) then
1280  filename = pathname(istart:istop)
1281  end if
Here is the caller graph for this function:

◆ getunit()

integer(i4b) function, public inputoutputmodule::getunit

Function to get a free unit number that hasn't been used

Returns
free unit number

Definition at line 169 of file InputOutput.f90.

170  ! -- modules
171  implicit none
172  ! -- return
173  integer(I4B) :: getunit !< free unit number
174  ! -- local
175  integer(I4B) :: iunit
176  !
177  ! -- code
178  call freeunitnumber(iunit)
179  getunit = iunit
Here is the call graph for this function:

◆ lowcase()

subroutine, public inputoutputmodule::lowcase ( character(len=*)  word)

Subroutine to convert a character string to lower case.

Definition at line 210 of file InputOutput.f90.

211  implicit none
212  ! -- dummy
213  character(len=*) :: word
214  ! -- local
215  integer(I4B) :: idiff, k, l
216  !
217  ! -- Compute the difference between lowercase and uppercase.
218  l = len(word)
219  idiff = ichar('a') - ichar('A')
220  !
221  ! -- Loop through the string and convert any uppercase characters.
222  do k = 1, l
223  if (word(k:k) >= 'A' .and. word(k:k) <= 'Z') then
224  word(k:k) = char(ichar(word(k:k)) + idiff)
225  end if
226  end do
Here is the caller graph for this function:

◆ openfile()

subroutine, public inputoutputmodule::openfile ( integer(i4b), intent(inout)  iu,
integer(i4b), intent(in)  iout,
character(len=*), intent(in)  fname,
character(len=*), intent(in)  ftype,
character(len=*), intent(in), optional  fmtarg_opt,
character(len=*), intent(in), optional  accarg_opt,
character(len=*), intent(in), optional  filstat_opt,
integer(i4b), intent(in), optional  mode_opt 
)

Subroutine to open a file using the specified arguments

Parameters
[in,out]iuunit number
[in]ioutoutput unit number to write a message (iout=0 does not print)
[in]fnamename of the file
[in]ftypefile type (e.g. WEL)
[in]fmtarg_optfile format, default is 'formatted'
[in]accarg_optfile access, default is 'sequential'
[in]filstat_optfile status, default is 'old'. Use 'REPLACE' for output file.
[in]mode_optsimulation mode that is evaluated to determine if the file should be opened

Definition at line 28 of file InputOutput.f90.

30  ! -- modules
31  use openspecmodule, only: action
32  implicit none
33  ! -- dummy
34  integer(I4B), intent(inout) :: iu !< unit number
35  integer(I4B), intent(in) :: iout !< output unit number to write a message (iout=0 does not print)
36  character(len=*), intent(in) :: fname !< name of the file
37  character(len=*), intent(in) :: ftype !< file type (e.g. WEL)
38  character(len=*), intent(in), optional :: fmtarg_opt !< file format, default is 'formatted'
39  character(len=*), intent(in), optional :: accarg_opt !< file access, default is 'sequential'
40  character(len=*), intent(in), optional :: filstat_opt !< file status, default is 'old'. Use 'REPLACE' for output file.
41  integer(I4B), intent(in), optional :: mode_opt !< simulation mode that is evaluated to determine if the file should be opened
42  ! -- local
43  character(len=20) :: fmtarg
44  character(len=20) :: accarg
45  character(len=20) :: filstat
46  character(len=20) :: filact
47  integer(I4B) :: imode
48  integer(I4B) :: iflen
49  integer(I4B) :: ivar
50  integer(I4B) :: iuop
51  ! -- formats
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,/)"
57  !
58  ! -- Process mode_opt
59  if (present(mode_opt)) then
60  imode = mode_opt
61  else
62  imode = isim_mode
63  end if
64  !
65  ! -- Evaluate if the file should be opened
66  if (isim_mode < imode) then
67  if (iout > 0) then
68  write (iout, fmtmsg2) trim(fname)
69  end if
70  else
71  !
72  ! -- Default is to read an existing text file
73  fmtarg = 'FORMATTED'
74  accarg = 'SEQUENTIAL'
75  filstat = 'OLD'
76  !
77  ! -- Override defaults
78  if (present(fmtarg_opt)) then
79  fmtarg = fmtarg_opt
80  call upcase(fmtarg)
81  end if
82  if (present(accarg_opt)) then
83  accarg = accarg_opt
84  call upcase(accarg)
85  end if
86  if (present(filstat_opt)) then
87  filstat = filstat_opt
88  call upcase(filstat)
89  end if
90  if (filstat == 'OLD') then
91  filact = action(1)
92  else
93  filact = action(2)
94  end if
95  !
96  ! -- size of fname
97  iflen = len_trim(fname)
98  !
99  ! -- Get a free unit number
100  if (iu <= 0) then
101  call freeunitnumber(iu)
102  end if
103  !
104  ! -- Check to see if file is already open, if not then open the file
105  inquire (file=fname(1:iflen), number=iuop)
106  if (iuop > 0) then
107  ivar = -1
108  else
109  open (unit=iu, file=fname(1:iflen), form=fmtarg, access=accarg, &
110  status=filstat, action=filact, iostat=ivar)
111  end if
112  !
113  ! -- Check for an error
114  if (ivar /= 0) then
115  write (errmsg, '(3a,1x,i0,a)') &
116  'Could not open "', fname(1:iflen), '" on unit', iu, '.'
117  if (iuop > 0) then
118  write (errmsg, '(a,1x,a,1x,i0,a)') &
119  trim(errmsg), 'File already open on unit', iuop, '.'
120  end if
121  write (errmsg, '(a,1x,a,1x,a,a)') &
122  trim(errmsg), 'Specified file status', trim(filstat), '.'
123  write (errmsg, '(a,1x,a,1x,a,a)') &
124  trim(errmsg), 'Specified file format', trim(fmtarg), '.'
125  write (errmsg, '(a,1x,a,1x,a,a)') &
126  trim(errmsg), 'Specified file access', trim(accarg), '.'
127  write (errmsg, '(a,1x,a,1x,a,a)') &
128  trim(errmsg), 'Specified file action', trim(filact), '.'
129  write (errmsg, '(a,1x,a,1x,i0,a)') &
130  trim(errmsg), 'IOSTAT error number', ivar, '.'
131  write (errmsg, '(a,1x,a)') &
132  trim(errmsg), 'STOP EXECUTION in subroutine openfile().'
133  call store_error(errmsg, terminate=.true.)
134  end if
135  !
136  ! -- Write a message
137  if (iout > 0) then
138  write (iout, fmtmsg) fname(1:iflen), ftype, iu, filstat, fmtarg, &
139  accarg, filact
140  end if
141  end if
character(len=20), dimension(2) action
Definition: OpenSpec.f90:7
Here is the call graph for this function:

◆ parseline()

subroutine, public inputoutputmodule::parseline ( character(len=*), intent(in)  line,
integer(i4b), intent(inout)  nwords,
character(len=*), dimension(:), intent(inout), allocatable  words,
integer(i4b), intent(in), optional  inunit,
character(len=*), intent(in), optional  filename 
)

Blanks and commas are recognized as delimiters. Multiple blanks between words is OK, but multiple commas between words is treated as an error. Quotation marks are not recognized as delimiters.

Definition at line 1108 of file InputOutput.f90.

1109  ! -- modules
1110  use constantsmodule, only: linelength
1111  implicit none
1112  ! -- dummy
1113  character(len=*), intent(in) :: line
1114  integer(I4B), intent(inout) :: nwords
1115  character(len=*), allocatable, dimension(:), intent(inout) :: words
1116  integer(I4B), intent(in), optional :: inunit
1117  character(len=*), intent(in), optional :: filename
1118  ! -- local
1119  integer(I4B) :: i, idum, istart, istop, linelen, lloc
1120  real(DP) :: rdum
1121  !
1122  nwords = 0
1123  if (allocated(words)) then
1124  deallocate (words)
1125  end if
1126  linelen = len(line)
1127  !
1128  ! -- get the number of words in a line and allocate words array
1129  nwords = get_nwords(line)
1130  allocate (words(nwords))
1131  !
1132  ! -- Populate words array and return
1133  lloc = 1
1134  do i = 1, nwords
1135  call urword(line, lloc, istart, istop, 0, idum, rdum, 0, 0)
1136  words(i) = line(istart:istop)
1137  end do
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:45
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_format()

subroutine, public inputoutputmodule::print_format ( character(len=*), intent(in)  linein,
character(len=*), intent(inout)  cdatafmp,
character(len=*), intent(inout)  editdesc,
integer(i4b), intent(inout)  nvaluesp,
integer(i4b), intent(inout)  nwidthp,
integer(i4b), intent(in)  inunit 
)

Define cdatafmp as a Fortran output format based on user input. Also define nvalues, nwidth, and editdesc.

Syntax for linein: COLUMNS nval WIDTH nwid [DIGITS ndig [options]]

Where: nval = Number of values per line. nwid = Number of character places to be used for each value. ndig = Number of digits to the right of the decimal point (required for real array). options are: editoption: One of [EXPONENTIAL, FIXED, GENERAL, SCIENTIFIC] A default value should be passed in for editdesc as G, I, E, F, or S. If I is passed in, then the fortran format will be for an integer variable.

Definition at line 1386 of file InputOutput.f90.

1387  ! -- dummy
1388  character(len=*), intent(in) :: linein
1389  character(len=*), intent(inout) :: cdatafmp
1390  character(len=*), intent(inout) :: editdesc
1391  integer(I4B), intent(inout) :: nvaluesp
1392  integer(I4B), intent(inout) :: nwidthp
1393  integer(I4B), intent(in) :: inunit
1394  ! -- local
1395  character(len=len(linein)) :: line
1396  character(len=20), dimension(:), allocatable :: words
1397  character(len=100) :: ermsg
1398  integer(I4B) :: ndigits = 0, nwords = 0
1399  integer(I4B) :: i, ierr
1400  logical :: isint
1401  !
1402  ! -- Parse line and initialize values
1403  line(:) = linein(:)
1404  call parseline(line, nwords, words, inunit)
1405  ierr = 0
1406  i = 0
1407  isint = .false.
1408  if (editdesc == 'I') isint = .true.
1409  !
1410  ! -- Check array name
1411  if (nwords < 1) then
1412  ermsg = 'Could not build PRINT_FORMAT from line'//trim(line)
1413  call store_error(trim(ermsg))
1414  ermsg = 'Syntax is: COLUMNS <columns> WIDTH <width> DIGITS &
1415  &<digits> <format>'
1416  call store_error(trim(ermsg))
1417  call store_error_unit(inunit)
1418  end if
1419  !
1420  ermsg = 'Error setting PRINT_FORMAT. Syntax is incorrect in line:'
1421  if (nwords >= 4) then
1422  if (.not. same_word(words(1), 'COLUMNS')) ierr = 1
1423  if (.not. same_word(words(3), 'WIDTH')) ierr = 1
1424  ! -- Read nvalues and nwidth
1425  if (ierr == 0) then
1426  read (words(2), *, iostat=ierr) nvaluesp
1427  end if
1428  if (ierr == 0) then
1429  read (words(4), *, iostat=ierr) nwidthp
1430  end if
1431  else
1432  ierr = 1
1433  end if
1434  if (ierr /= 0) then
1435  call store_error(ermsg)
1436  call store_error(line)
1437  ermsg = 'Syntax is: COLUMNS <columns> WIDTH <width> &
1438  &DIGITS <digits> <format>'
1439  call store_error(trim(ermsg))
1440  call store_error_unit(inunit)
1441  end if
1442  i = 4
1443  !
1444  if (.not. isint) then
1445  ! -- Check for DIGITS specification
1446  if (nwords >= 5) then
1447  if (.not. same_word(words(5), 'DIGITS')) ierr = 1
1448  ! -- Read ndigits
1449  read (words(6), *, iostat=ierr) ndigits
1450  else
1451  ierr = 1
1452  end if
1453  i = i + 2
1454  end if
1455  !
1456  ! -- Check for EXPONENTIAL | FIXED | GENERAL | SCIENTIFIC option.
1457  ! -- Check for LABEL, WRAP, and STRIP options.
1458  do
1459  i = i + 1
1460  if (i <= nwords) then
1461  call upcase(words(i))
1462  select case (words(i))
1463  case ('EXPONENTIAL')
1464  editdesc = 'E'
1465  if (isint) ierr = 1
1466  case ('FIXED')
1467  editdesc = 'F'
1468  if (isint) ierr = 1
1469  case ('GENERAL')
1470  editdesc = 'G'
1471  if (isint) ierr = 1
1472  case ('SCIENTIFIC')
1473  editdesc = 'S'
1474  if (isint) ierr = 1
1475  case default
1476  ermsg = 'Error in format specification. Unrecognized option: '//words(i)
1477  call store_error(ermsg)
1478  ermsg = 'Valid values are EXPONENTIAL, FIXED, GENERAL, or SCIENTIFIC.'
1479  call store_error(ermsg)
1480  call store_error_unit(inunit)
1481  end select
1482  else
1483  exit
1484  end if
1485  end do
1486  if (ierr /= 0) then
1487  call store_error(ermsg)
1488  call store_error(line)
1489  call store_error_unit(inunit)
1490  end if
1491  !
1492  ! -- Build the output format.
1493  select case (editdesc)
1494  case ('I')
1495  call buildintformat(nvaluesp, nwidthp, cdatafmp)
1496  case ('F')
1497  call buildfixedformat(nvaluesp, nwidthp, ndigits, cdatafmp)
1498  case ('E', 'G', 'S')
1499  call buildfloatformat(nvaluesp, nwidthp, ndigits, editdesc, cdatafmp)
1500  end select
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_line()

character(len=:) function, allocatable, public inputoutputmodule::read_line ( integer(i4b), intent(in)  iu,
logical, intent(out)  eof 
)

The returned string can be stored in a deferred-length character variable, for example:

integer(I4B) :: iu character(len=:), allocatable :: my_string logical :: eof iu = 8 open(iu,file='my_file') my_string = read_line(iu, eof)

Definition at line 1196 of file InputOutput.f90.

1197  !
1198  implicit none
1199  ! -- dummy
1200  integer(I4B), intent(in) :: iu
1201  logical, intent(out) :: eof
1202  character(len=:), allocatable :: astring
1203  ! -- local
1204  integer(I4B) :: isize, istat
1205  character(len=256) :: buffer
1206  character(len=1000) :: ermsg, fname
1207  character(len=7) :: fmtd
1208  logical :: lop
1209  ! -- formats
1210  character(len=*), parameter :: fmterrmsg1 = &
1211  & "('Error in read_line: File ',i0,' is not open.')"
1212  character(len=*), parameter :: fmterrmsg2 = &
1213  & "('Error in read_line: Attempting to read text ' // &
1214  & 'from unformatted file: ""',a,'""')"
1215  character(len=*), parameter :: fmterrmsg3 = &
1216  & "('Error reading from file ""',a,'"" opened on unit ',i0, &
1217  & ' in read_line.')"
1218  !
1219  astring = ''
1220  eof = .false.
1221  do
1222  read (iu, '(a)', advance='NO', iostat=istat, size=isize, end=99) buffer
1223  if (istat > 0) then
1224  ! Determine error if possible, report it, and stop.
1225  if (iu <= 0) then
1226  ermsg = 'Programming error in call to read_line: '// &
1227  'Attempt to read from unit number <= 0'
1228  else
1229  inquire (unit=iu, opened=lop, name=fname, formatted=fmtd)
1230  if (.not. lop) then
1231  write (ermsg, fmterrmsg1) iu
1232  elseif (fmtd == 'NO' .or. fmtd == 'UNKNOWN') then
1233  write (ermsg, fmterrmsg2) trim(fname)
1234  else
1235  write (ermsg, fmterrmsg3) trim(fname), iu
1236  end if
1237  end if
1238  call store_error(ermsg)
1239  call store_error_unit(iu)
1240  end if
1241  astring = astring//buffer(:isize)
1242  ! -- An end-of-record condition stops the loop.
1243  if (istat < 0) then
1244  return
1245  end if
1246  end do
1247  !
1248  return
1249 99 continue
1250  !
1251  ! An end-of-file condition returns an empty string.
1252  eof = .true.
Here is the call graph for this function:

◆ same_word()

logical function, public inputoutputmodule::same_word ( character(len=*), intent(in)  word1,
character(len=*), intent(in)  word2 
)

Definition at line 1052 of file InputOutput.f90.

1053  implicit none
1054  ! -- dummy
1055  character(len=*), intent(in) :: word1, word2
1056  ! -- local
1057  character(len=200) :: upword1, upword2
1058  !
1059  upword1 = word1
1060  call upcase(upword1)
1061  upword2 = word2
1062  call upcase(upword2)
1063  same_word = (upword1 == upword2)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_pad_left()

character(len=max(len_trim(str), width)) function, public inputoutputmodule::str_pad_left ( character(len=*), intent(in)  str,
integer, intent(in)  width 
)

Definition at line 1068 of file InputOutput.f90.

1069  ! -- local
1070  character(len=*), intent(in) :: str
1071  integer, intent(in) :: width
1072  ! -- Return
1073  character(len=max(len_trim(str), width)) :: res
1074  !
1075  res = str
1076  res = adjustr(res)
Here is the caller graph for this function:

◆ u9rdcom()

subroutine, public inputoutputmodule::u9rdcom ( integer(i4b), intent(in)  iin,
integer(i4b), intent(in)  iout,
character(len=:), intent(inout), allocatable  line,
integer(i4b), intent(out)  ierr 
)

Different from u8rdcom in that line is a deferred length character string, which allows any length lines to be read using the get_line subroutine.

Definition at line 1731 of file InputOutput.f90.

1732  ! -- module
1733  use, intrinsic :: iso_fortran_env, only: iostat_end
1734  implicit none
1735  ! -- dummy
1736  integer(I4B), intent(in) :: iin
1737  integer(I4B), intent(in) :: iout
1738  character(len=:), allocatable, intent(inout) :: line
1739  integer(I4B), intent(out) :: ierr
1740  ! -- local
1741  character(len=:), allocatable :: linetemp
1742  character(len=2), parameter :: comment = '//'
1743  character(len=1), parameter :: tab = char(9)
1744  logical :: iscomment
1745  integer(I4B) :: i, j, l, istart, lsize
1746  !
1747  !readerrmsg = ''
1748  line = comment
1749  pcomments: do
1750  call get_line(iin, line, ierr)
1751  if (ierr == iostat_end) then
1752  ! -- End of file reached. Return with ierr = IOSTAT_END
1753  ! and line as an empty string
1754  line = ' '
1755  exit pcomments
1756  elseif (ierr /= 0) then
1757  ! -- Other error...report it
1758  call unitinquire(iin)
1759  write (errmsg, *) 'u9rdcom: Could not read from unit: ', iin
1760  call store_error(errmsg, terminate=.true.)
1761  end if
1762  if (len_trim(line) < 1) then
1763  line = comment
1764  cycle
1765  end if
1766  !
1767  ! -- Ensure that any initial tab characters are treated as spaces
1768  cleartabs: do
1769  !
1770  ! -- adjustl manually to avoid stack overflow
1771  lsize = len(line)
1772  istart = 1
1773  allocate (character(len=lsize) :: linetemp)
1774  do j = 1, lsize
1775  if (line(j:j) /= ' ' .and. line(j:j) /= ',' .and. &
1776  line(j:j) /= char(9)) then
1777  istart = j
1778  exit
1779  end if
1780  end do
1781  linetemp(:) = ' '
1782  linetemp(:) = line(istart:)
1783  line(:) = linetemp(:)
1784  deallocate (linetemp)
1785  !
1786  ! -- check for comment
1787  iscomment = .false.
1788  select case (line(1:1))
1789  case ('#')
1790  iscomment = .true.
1791  exit cleartabs
1792  case ('!')
1793  iscomment = .true.
1794  exit cleartabs
1795  case (tab)
1796  line(1:1) = ' '
1797  cycle cleartabs
1798  case default
1799  if (line(1:2) == comment) iscomment = .true.
1800  if (len_trim(line) < 1) iscomment = .true.
1801  exit cleartabs
1802  end select
1803  end do cleartabs
1804  !
1805  if (.not. iscomment) then
1806  exit pcomments
1807  else
1808  if (iout > 0) then
1809  !find the last non-blank character.
1810  l = len(line)
1811  do i = l, 1, -1
1812  if (line(i:i) /= ' ') then
1813  exit
1814  end if
1815  end do
1816  ! -- print the line up to the last non-blank character.
1817  write (iout, '(1x,a)') line(1:i)
1818  end if
1819  end if
1820  end do pcomments
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ubdsv06()

subroutine, public inputoutputmodule::ubdsv06 ( integer(i4b), intent(in)  kstp,
integer(i4b), intent(in)  kper,
character(len=*), intent(in)  text,
character(len=*), intent(in)  modelnam1,
character(len=*), intent(in)  paknam1,
character(len=*), intent(in)  modelnam2,
character(len=*), intent(in)  paknam2,
integer(i4b), intent(in)  ibdchn,
integer(i4b), intent(in)  naux,
character(len=16), dimension(:), intent(in)  auxtxt,
integer(i4b), intent(in)  ncol,
integer(i4b), intent(in)  nrow,
integer(i4b), intent(in)  nlay,
integer(i4b), intent(in)  nlist,
integer(i4b), intent(in)  iout,
real(dp), intent(in)  delt,
real(dp), intent(in)  pertim,
real(dp), intent(in)  totim 
)

Each item in the list is written by module ubdsvc

Definition at line 958 of file InputOutput.f90.

961  implicit none
962  ! -- dummy
963  integer(I4B), intent(in) :: kstp
964  integer(I4B), intent(in) :: kper
965  character(len=*), intent(in) :: text
966  character(len=*), intent(in) :: modelnam1
967  character(len=*), intent(in) :: paknam1
968  character(len=*), intent(in) :: modelnam2
969  character(len=*), intent(in) :: paknam2
970  integer(I4B), intent(in) :: naux
971  character(len=16), dimension(:), intent(in) :: auxtxt
972  integer(I4B), intent(in) :: ibdchn
973  integer(I4B), intent(in) :: ncol
974  integer(I4B), intent(in) :: nrow
975  integer(I4B), intent(in) :: nlay
976  integer(I4B), intent(in) :: nlist
977  integer(I4B), intent(in) :: iout
978  real(DP), intent(in) :: delt
979  real(DP), intent(in) :: pertim
980  real(DP), intent(in) :: totim
981  ! -- local
982  integer(I4B) :: n
983  ! -- format
984  character(len=*), parameter :: fmt = &
985  & "(1X,'UBDSV06 SAVING ',A16,' IN MODEL ',A16,' PACKAGE ',A16,"// &
986  & "'CONNECTED TO MODEL ',A16,' PACKAGE ',A16,"// &
987  & "' ON UNIT',I7,' AT TIME STEP',I7,', STRESS PERIOD',I7)"
988  !
989  ! -- Write unformatted records identifying data.
990  if (iout > 0) write (iout, fmt) text, modelnam1, paknam1, modelnam2, &
991  paknam2, ibdchn, kstp, kper
992  write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
993  write (ibdchn) 6, delt, pertim, totim
994  write (ibdchn) modelnam1
995  write (ibdchn) paknam1
996  write (ibdchn) modelnam2
997  write (ibdchn) paknam2
998  write (ibdchn) naux + 1
999  if (naux > 0) write (ibdchn) (auxtxt(n), n=1, naux)
1000  write (ibdchn) nlist
Here is the caller graph for this function:

◆ ubdsv1()

subroutine, public inputoutputmodule::ubdsv1 ( integer(i4b), intent(in)  kstp,
integer(i4b), intent(in)  kper,
character(len=*), intent(in)  text,
integer(i4b), intent(in)  ibdchn,
real(dp), dimension(:), intent(in)  buff,
integer(i4b), intent(in)  ncol,
integer(i4b), intent(in)  nrow,
integer(i4b), intent(in)  nlay,
integer(i4b), intent(in)  iout,
real(dp), intent(in)  delt,
real(dp), intent(in)  pertim,
real(dp), intent(in)  totim 
)

Definition at line 922 of file InputOutput.f90.

924  implicit none
925  ! -- dummy
926  integer(I4B), intent(in) :: kstp
927  integer(I4B), intent(in) :: kper
928  character(len=*), intent(in) :: text
929  integer(I4B), intent(in) :: ibdchn
930  real(DP), dimension(:), intent(in) :: buff
931  integer(I4B), intent(in) :: ncol
932  integer(I4B), intent(in) :: nrow
933  integer(I4B), intent(in) :: nlay
934  integer(I4B), intent(in) :: iout
935  real(DP), intent(in) :: delt
936  real(DP), intent(in) :: pertim
937  real(DP), intent(in) :: totim
938  ! -- format
939  character(len=*), parameter :: fmt = &
940  & "(1X,'UBDSV1 SAVING ',A16,' ON UNIT',I7,' AT TIME STEP',I7,"// &
941  & "', STRESS PERIOD',I7)"
942  !
943  ! -- Write records
944  if (iout > 0) write (iout, fmt) text, ibdchn, kstp, kper
945  write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
946  write (ibdchn) 1, delt, pertim, totim
947  write (ibdchn) buff
948  !
949  ! -- flush file
950  flush (ibdchn)
Here is the caller graph for this function:

◆ ubdsv4()

subroutine, public inputoutputmodule::ubdsv4 (   kstp,
  kper,
character(len=16)  text,
  naux,
character(len=16), dimension(:)  auxtxt,
  ibdchn,
  ncol,
  nrow,
  nlay,
  nlist,
  iout,
real(dp), intent(in)  delt,
real(dp), intent(in)  pertim,
real(dp), intent(in)  totim 
)

Each item in the list is written by module UBDSVB

Definition at line 603 of file InputOutput.f90.

605  ! -- dummy
606  character(len=16) :: text
607  character(len=16), dimension(:) :: auxtxt
608  real(DP), intent(in) :: delt, pertim, totim
609  ! -- formats
610  character(len=*), parameter :: fmt = &
611  & "(1X,'UBDSV4 SAVING ',A16,' ON UNIT',I7,' AT TIME STEP',I7,"// &
612  & "', STRESS PERIOD',I7)"
613  !
614  ! -- Write unformatted records identifying data
615  if (iout > 0) write (iout, fmt) text, ibdchn, kstp, kper
616  write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
617  write (ibdchn) 5, delt, pertim, totim
618  write (ibdchn) naux + 1
619  if (naux > 0) write (ibdchn) (auxtxt(n), n=1, naux)
620  write (ibdchn) nlist

◆ ubdsvb()

subroutine, public inputoutputmodule::ubdsvb (   ibdchn,
  icrl,
real(dp)  q,
real(dp), dimension(nvl)  val,
  nvl,
  naux,
  laux 
)

Definition at line 626 of file InputOutput.f90.

627  ! -- dummy
628  real(DP), dimension(nvl) :: val
629  real(DP) :: q
630  !
631  ! -- Write cell number and flow rate
632  IF (naux > 0) then
633  n2 = laux + naux - 1
634  write (ibdchn) icrl, q, (val(n), n=laux, n2)
635  else
636  write (ibdchn) icrl, q
637  end if

◆ ubdsvc()

subroutine, public inputoutputmodule::ubdsvc ( integer(i4b), intent(in)  ibdchn,
integer(i4b), intent(in)  n,
real(dp), intent(in)  q,
integer(i4b), intent(in)  naux,
real(dp), dimension(naux), intent(in)  aux 
)

From node (n) and to node (n2) are written to the file

Definition at line 1007 of file InputOutput.f90.

1008  implicit none
1009  ! -- dummy
1010  integer(I4B), intent(in) :: ibdchn
1011  integer(I4B), intent(in) :: n
1012  real(DP), intent(in) :: q
1013  integer(I4B), intent(in) :: naux
1014  real(DP), dimension(naux), intent(in) :: aux
1015  ! -- local
1016  integer(I4B) :: nn
1017  !
1018  ! -- Write record
1019  if (naux > 0) then
1020  write (ibdchn) n, q, (aux(nn), nn=1, naux)
1021  else
1022  write (ibdchn) n, q
1023  end if

◆ ubdsvd()

subroutine, public inputoutputmodule::ubdsvd ( integer(i4b), intent(in)  ibdchn,
integer(i4b), intent(in)  n,
integer(i4b), intent(in)  n2,
real(dp), intent(in)  q,
integer(i4b), intent(in)  naux,
real(dp), dimension(naux), intent(in)  aux 
)

From node (n) and to node (n2) are written to the file

Definition at line 1030 of file InputOutput.f90.

1031  implicit none
1032  ! -- dummy
1033  integer(I4B), intent(in) :: ibdchn
1034  integer(I4B), intent(in) :: n
1035  integer(I4B), intent(in) :: n2
1036  real(DP), intent(in) :: q
1037  integer(I4B), intent(in) :: naux
1038  real(DP), dimension(naux), intent(in) :: aux
1039  ! -- local
1040  integer(I4B) :: nn
1041  !
1042  ! -- Write record
1043  if (naux > 0) then
1044  write (ibdchn) n, n2, q, (aux(nn), nn=1, naux)
1045  else
1046  write (ibdchn) n, n2, q
1047  end if
Here is the caller graph for this function:

◆ ucolno()

subroutine, public inputoutputmodule::ucolno (   nlbl1,
  nlbl2,
  nspace,
  ncpl,
  ndig,
  iout 
)

nlbl1 is the start column label (number) nlbl2 is the stop column label (number) nspace is number of blank spaces to leave at start of line ncpl is number of column numbers per line ndig is number of characters in each column field iout is output channel

Definition at line 649 of file InputOutput.f90.

650  ! -- local
651  character(len=1) :: DOT, SPACE, DG, BF
652  dimension :: bf(1000), dg(10)
653  ! -- constants
654  data dg(1), dg(2), dg(3), dg(4), dg(5), dg(6), dg(7), dg(8), dg(9), dg(10)/ &
655  & '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'/
656  data dot, space/'.', ' '/
657  ! -- formats
658  character(len=*), parameter :: fmtmsgout1 = "(1x)"
659  character(len=*), parameter :: fmtmsgout2 = "(1x, 1000a1)"
660  !
661  ! -- Calculate # of columns to be printed (nlbl), width
662  ! of a line (ntot), number of lines (nwrap).
663  if (iout <= 0) return
664  write (iout, fmtmsgout1)
665  !
666  nlbl = nlbl2 - nlbl1 + 1
667  n = nlbl
668  !
669  if (nlbl < ncpl) n = ncpl
670  ntot = nspace + n * ndig
671  !
672  if (ntot > 1000) go to 50
673  nwrap = (nlbl - 1) / ncpl + 1
674  j1 = nlbl1 - ncpl
675  j2 = nlbl1 - 1
676  !
677  ! -- Build and print each line
678  do n = 1, nwrap
679  !
680  ! -- Clear the buffer (BF)
681  do i = 1, 1000
682  bf(i) = space
683  end do
684  nbf = nspace
685  !
686  ! -- Determine first (j1) and last (j2) column # for this line.
687  j1 = j1 + ncpl
688  j2 = j2 + ncpl
689  if (j2 > nlbl2) j2 = nlbl2
690  !
691  ! -- Load the column #'s into the buffer.
692  do j = j1, j2
693  nbf = nbf + ndig
694  i2 = j / 10
695  i1 = j - i2 * 10 + 1
696  bf(nbf) = dg(i1)
697  if (i2 == 0) go to 30
698  i3 = i2 / 10
699  i2 = i2 - i3 * 10 + 1
700  bf(nbf - 1) = dg(i2)
701  if (i3 == 0) go to 30
702  i4 = i3 / 10
703  i3 = i3 - i4 * 10 + 1
704  bf(nbf - 2) = dg(i3)
705  if (i4 == 0) go to 30
706  if (i4 > 9) then
707  ! -- If more than 4 digits, use "X" for 4th digit.
708  bf(nbf - 3) = 'X'
709  else
710  bf(nbf - 3) = dg(i4 + 1)
711  end if
712 30 end do
713  !
714  ! -- Print the contents of the buffer (i.e. print the line).
715  write (iout, fmtmsgout2) (bf(i), i=1, nbf)
716  !
717  end do
718  !
719  ! -- Print a line of dots (for aesthetic purposes only).
720 50 ntot = ntot
721  if (ntot > 1000) ntot = 1000
722  write (iout, fmtmsgout2) (dot, i=1, ntot)
Here is the caller graph for this function:

◆ ulaprufw()

subroutine, public inputoutputmodule::ulaprufw ( integer(i4b), intent(in)  ncol,
integer(i4b), intent(in)  nrow,
integer(i4b), intent(in)  kstp,
integer(i4b), intent(in)  kper,
integer(i4b), intent(in)  ilay,
integer(i4b), intent(in)  iout,
real(dp), dimension(ncol, nrow), intent(in)  buf,
character(len=*), intent(in)  text,
character(len=*), intent(in)  userfmt,
integer(i4b), intent(in)  nvalues,
integer(i4b), intent(in)  nwidth,
character(len=1), intent(in)  editdesc 
)

Definition at line 1142 of file InputOutput.f90.

1144  implicit none
1145  ! -- dummy
1146  integer(I4B), intent(in) :: ncol, nrow, kstp, kper, ilay, iout
1147  real(DP), dimension(ncol, nrow), intent(in) :: buf
1148  character(len=*), intent(in) :: text
1149  character(len=*), intent(in) :: userfmt
1150  integer(I4B), intent(in) :: nvalues, nwidth
1151  character(len=1), intent(in) :: editdesc
1152  ! -- local
1153  integer(I4B) :: i, j, nspaces
1154  ! -- formats
1155  character(len=*), parameter :: fmtmsgout1 = &
1156  "('1',/2X,A,' IN LAYER ',I3,' AT END OF TIME STEP ',I3, &
1157 & ' IN STRESS PERIOD ',I4/2X,75('-'))"
1158  character(len=*), parameter :: fmtmsgout2 = &
1159  "('1',/1X,A,' FOR CROSS SECTION AT END OF TIME STEP',I3, &
1160 & ' IN STRESS PERIOD ',I4/1X,79('-'))"
1161  !
1162  if (iout <= 0) return
1163  ! -- Print a header depending on ILAY
1164  if (ilay > 0) then
1165  write (iout, fmtmsgout1) trim(text), ilay, kstp, kper
1166  else if (ilay < 0) then
1167  write (iout, fmtmsgout2) trim(text), kstp, kper
1168  end if
1169  !
1170  ! -- Print column numbers.
1171  nspaces = 0
1172  if (editdesc == 'F') nspaces = 3
1173  call ucolno(1, ncol, nspaces, nvalues, nwidth + 1, iout)
1174  !
1175  ! -- Loop through the rows, printing each one in its entirety.
1176  do i = 1, nrow
1177  write (iout, userfmt) i, (buf(j, i), j=1, ncol)
1178  end do
1179  !
1180  ! -- flush file
1181  flush (iout)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ulaprw()

subroutine, public inputoutputmodule::ulaprw ( real(dp), dimension(ncol, nrow)  buf,
character(len=16)  text,
  kstp,
  kper,
  ncol,
  nrow,
  ilay,
  iprn,
  iout 
)

Definition at line 727 of file InputOutput.f90.

728  ! -- dummy
729  character(len=16) :: text
730  real(DP), dimension(ncol, nrow) :: buf
731  ! -- formats
732  character(len=*), parameter :: fmtmsgout1 = &
733  & "('1', /2x, a, ' IN LAYER ',I3,' AT END OF TIME STEP ',I3, &
734  & ' IN STRESS PERIOD ',I4/2x,75('-'))"
735  character(len=*), parameter :: fmtmsgout2 = &
736  & "('1',/1x,A,' FOR CROSS SECTION AT END OF TIME STEP',I3, &
737  & ' IN STRESS PERIOD ',I4/1x,79('-'))"
738  character(len=*), parameter :: fmtg10 = &
739  & "(1X,I3,2X,1PG10.3,10(1X,G10.3):/(5X,11(1X,G10.3)))"
740  character(len=*), parameter :: fmtg13 = &
741  & "(1x,I3,2x,1PG13.6,8(1x,G13.6):/(5x,9(1x,G13.6)))"
742  character(len=*), parameter :: fmtf7pt1 = &
743  & "(1x,I3,1x,15(1x,F7.1):/(5x,15(1x,F7.1)))"
744  character(len=*), parameter :: fmtf7pt2 = &
745  & "(1x,I3,1x,15(1x,F7.2):/(5x,15(1x,F7.2)))"
746  character(len=*), parameter :: fmtf7pt3 = &
747  & "(1x,I3,1x,15(1x,F7.3):/(5x,15(1x,F7.3)))"
748  character(len=*), parameter :: fmtf7pt4 = &
749  & "(1x,I3,1x,15(1x,F7.4):/(5x,15(1x,F7.4)))"
750  character(len=*), parameter :: fmtf5pt0 = &
751  & "(1x,I3,1x,20(1x,F5.0):/(5x,20(1x,F5.0)))"
752  character(len=*), parameter :: fmtf5pt1 = &
753  & "(1x,I3,1x,20(1x,F5.1):/(5x,20(1x,F5.1)))"
754  character(len=*), parameter :: fmtf5pt2 = &
755  & "(1x,I3,1x,20(1x,F5.2):/(5x,20(1x,F5.2)))"
756  character(len=*), parameter :: fmtf5pt3 = &
757  & "(1x,I3,1x,20(1x,F5.3):/(5x,20(1x,F5.3)))"
758  character(len=*), parameter :: fmtf5pt4 = &
759  & "(1x,I3,1x,20(1x,F5.4):/(5x,20(1x,F5.4)))"
760  character(len=*), parameter :: fmtg11 = &
761  & "(1x,I3,2x,1PG11.4,9(1x,G11.4):/(5x,10(1x,G11.4)))"
762  character(len=*), parameter :: fmtf6pt0 = &
763  & "(1x,I3,1x,10(1x,F6.0):/(5X,10(1x,F6.0)))"
764  character(len=*), parameter :: fmtf6pt1 = &
765  & "(1x,I3,1x,10(1x,F6.1):/(5x,10(1x,F6.1)))"
766  character(len=*), parameter :: fmtf6pt2 = &
767  & "(1x,I3,1x,10(1x,F6.2):/(5x,10(1x,F6.2)))"
768  character(len=*), parameter :: fmtf6pt3 = &
769  & "(1x,I3,1x,10(1x,F6.3):/(5x,10(1x,F6.3)))"
770  character(len=*), parameter :: fmtf6pt4 = &
771  & "(1x,I3,1x,10(1x,F6.4):/(5x,10(1x,F6.4)))"
772  character(len=*), parameter :: fmtf6pt5 = &
773  & "(1x,I3,1x,10(1x,F6.5):/(5x,10(1x,F6.5)))"
774  character(len=*), parameter :: fmtg12 = &
775  & "(1x,I3,2x,1PG12.5,4(1x,G12.5):/(5x,5(1x,G12.5)))"
776  character(len=*), parameter :: fmtg11pt4 = &
777  & "(1x,I3,2x,1PG11.4,5(1x,G11.4):/(5x,6(1x,G11.4)))"
778  character(len=*), parameter :: fmtg9pt2 = &
779  & "(1x,I3,2x,1PG9.2,6(1x,G9.2):/(5x,7(1x,G9.2)))"
780  !
781  if (iout <= 0) return
782  ! -- Print a header depending on ilay
783  if (ilay > 0) then
784  write (iout, fmtmsgout1) text, ilay, kstp, kper
785  else if (ilay < 0) then
786  write (iout, fmtmsgout2) text, kstp, kper
787  end if
788  !
789  ! -- Make sure the format code (ip or iprn) is between 1 and 21
790  ip = iprn
791  if (ip < 1 .or. ip > 21) ip = 12
792  !
793  ! -- Call the utility module ucolno to print column numbers.
794  if (ip == 1) call ucolno(1, ncol, 0, 11, 11, iout)
795  if (ip == 2) call ucolno(1, ncol, 0, 9, 14, iout)
796  if (ip >= 3 .and. ip <= 6) call ucolno(1, ncol, 3, 15, 8, iout)
797  if (ip >= 7 .and. ip <= 11) call ucolno(1, ncol, 3, 20, 6, iout)
798  if (ip == 12) call ucolno(1, ncol, 0, 10, 12, iout)
799  if (ip >= 13 .and. ip <= 18) call ucolno(1, ncol, 3, 10, 7, iout)
800  if (ip == 19) call ucolno(1, ncol, 0, 5, 13, iout)
801  if (ip == 20) call ucolno(1, ncol, 0, 6, 12, iout)
802  if (ip == 21) call ucolno(1, ncol, 0, 7, 10, iout)
803  !
804  ! -- Loop through the rows printing each one in its entirety.
805  do i = 1, nrow
806  select case (ip)
807  !
808  case (1)
809  ! -- format 11G10.3
810  write (iout, fmtg10) i, (buf(j, i), j=1, ncol)
811  !
812  case (2)
813  ! -- format 9G13.6
814  write (iout, fmtg13) i, (buf(j, i), j=1, ncol)
815  !
816  case (3)
817  ! -- format 15F7.1
818  write (iout, fmtf7pt1) i, (buf(j, i), j=1, ncol)
819  !
820  case (4)
821  ! -- format 15F7.2
822  write (iout, fmtf7pt2) i, (buf(j, i), j=1, ncol)
823  !
824  case (5)
825  ! -- format 15F7.3
826  write (iout, fmtf7pt3) i, (buf(j, i), j=1, ncol)
827  !
828  case (6)
829  ! -- format 15F7.4
830  write (iout, fmtf7pt4) i, (buf(j, i), j=1, ncol)
831  !
832  case (7)
833  ! -- format 20F5.0
834  write (iout, fmtf5pt0) i, (buf(j, i), j=1, ncol)
835  !
836  case (8)
837  ! -- format 20F5.1
838  write (iout, fmtf5pt1) i, (buf(j, i), j=1, ncol)
839  !
840  case (9)
841  ! -- format 20F5.2
842  write (iout, fmtf5pt2) i, (buf(j, i), j=1, ncol)
843  !
844  case (10)
845  ! -- format 20F5.3
846  write (iout, fmtf5pt3) i, (buf(j, i), j=1, ncol)
847  !
848  case (11)
849  ! -- format 20F5.4
850  write (iout, fmtf5pt4) i, (buf(j, i), j=1, ncol)
851  !
852  case (12)
853  ! -- format 10G11.4
854  write (iout, fmtg11) i, (buf(j, i), j=1, ncol)
855  !
856  case (13)
857  ! -- format 10F6.0
858  write (iout, fmtf6pt0) i, (buf(j, i), j=1, ncol)
859  !
860  case (14)
861  ! -- format 10F6.1
862  write (iout, fmtf6pt1) i, (buf(j, i), j=1, ncol)
863  !
864  case (15)
865  ! -- format 10F6.2
866  write (iout, fmtf6pt2) i, (buf(j, i), j=1, ncol)
867  !
868  case (16)
869  ! -- format 10F6.3
870  write (iout, fmtf6pt3) i, (buf(j, i), j=1, ncol)
871  !
872  case (17)
873  ! -- format 10F6.4
874  write (iout, fmtf6pt4) i, (buf(j, i), j=1, ncol)
875  !
876  case (18)
877  ! -- format 10F6.5
878  write (iout, fmtf6pt5) i, (buf(j, i), j=1, ncol)
879  !
880  case (19)
881  ! -- format 5G12.5
882  write (iout, fmtg12) i, (buf(j, i), j=1, ncol)
883  !
884  case (20)
885  ! -- format 6G11.4
886  write (iout, fmtg11pt4) i, (buf(j, i), j=1, ncol)
887  !
888  case (21)
889  ! -- format 7G9.2
890  write (iout, fmtg9pt2) i, (buf(j, i), j=1, ncol)
891  !
892  end select
893  end do
894  !
895  ! -- Flush file
896  flush (iout)
Here is the call graph for this function:

◆ ulasav()

subroutine, public inputoutputmodule::ulasav ( real(dp), dimension(ncol, nrow)  buf,
character(len=16)  text,
  kstp,
  kper,
real(dp)  pertim,
real(dp)  totim,
  ncol,
  nrow,
  ilay,
  ichn 
)

Definition at line 901 of file InputOutput.f90.

903  ! -- dummy
904  character(len=16) :: text
905  real(DP), dimension(ncol, nrow) :: buf
906  real(DP) :: pertim, totim
907  !
908  ! -- Write an unformatted record containing identifying information
909  write (ichn) kstp, kper, pertim, totim, text, ncol, nrow, ilay
910  !
911  ! -- Write an unformatted record containing array values. The array is
912  ! dimensioned (ncol,nrow)
913  write (ichn) ((buf(ic, ir), ic=1, ncol), ir=1, nrow)
914  !
915  ! -- flush file
916  flush (ichn)
Here is the caller graph for this function:

◆ ulstlb()

subroutine, public inputoutputmodule::ulstlb (   iout,
character(len=*)  label,
character(len=16), dimension(ncaux)  caux,
  ncaux,
  naux 
)

Definition at line 565 of file InputOutput.f90.

566  ! -- dummy
567  character(len=*) :: label
568  character(len=16) :: caux(ncaux)
569  ! -- local
570  character(len=400) buf
571  ! -- constant
572  character(len=1) DASH(400)
573  data dash/400*'-'/
574  ! -- formats
575  character(len=*), parameter :: fmtmsgout1 = "(1x, a)"
576  character(len=*), parameter :: fmtmsgout2 = "(1x, 400a)"
577  !
578  ! -- Construct the complete label in BUF. Start with BUF=LABEL.
579  buf = label
580  !
581  ! -- Add auxiliary data names if there are any.
582  nbuf = len(label) + 9
583  if (naux > 0) then
584  do i = 1, naux
585  n1 = nbuf + 1
586  nbuf = nbuf + 16
587  buf(n1:nbuf) = caux(i)
588  end do
589  end if
590  !
591  ! -- Write the label.
592  write (iout, fmtmsgout1) buf(1:nbuf)
593  !
594  ! -- Add a line of dashes.
595  write (iout, fmtmsgout2) (dash(j), j=1, nbuf)
Here is the caller graph for this function:

◆ unitinquire()

subroutine, public inputoutputmodule::unitinquire ( integer(i4b)  iu)

Definition at line 1079 of file InputOutput.f90.

1080  ! -- dummy
1081  integer(I4B) :: iu
1082  ! -- local
1083  character(len=LINELENGTH) :: line
1084  character(len=100) :: fname, ac, act, fm, frm, seq, unf
1085  ! -- format
1086  character(len=*), parameter :: fmta = &
1087  &"('unit:',i4,' name:',a,' access:',a,' action:',a)"
1088  character(len=*), parameter :: fmtb = &
1089  &"(' formatted:',a,' sequential:',a,' unformatted:',a,' form:',a)"
1090  !
1091  ! -- set strings using inquire statement
1092  inquire (unit=iu, name=fname, access=ac, action=act, formatted=fm, &
1093  sequential=seq, unformatted=unf, form=frm)
1094  !
1095  ! -- write the results of the inquire statement
1096  write (line, fmta) iu, trim(fname), trim(ac), trim(act)
1097  call write_message(line)
1098  write (line, fmtb) trim(fm), trim(seq), trim(unf), trim(frm)
1099  call write_message(line)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ upcase()

subroutine, public inputoutputmodule::upcase ( character(len=*), intent(inout)  word)

Subroutine to convert a character string to upper case.

Parameters
[in,out]wordword to convert to upper case

Definition at line 186 of file InputOutput.f90.

187  implicit none
188  ! -- dummy
189  character(len=*), intent(inout) :: word !< word to convert to upper case
190  ! -- local
191  integer(I4B) :: l
192  integer(I4B) :: idiff
193  integer(I4B) :: k
194  !
195  ! -- Compute the difference between lowercase and uppercase.
196  l = len(word)
197  idiff = ichar('a') - ichar('A')
198  !
199  ! -- Loop through the string and convert any lowercase characters.
200  do k = 1, l
201  IF (word(k:k) >= 'a' .and. word(k:k) <= 'z') &
202  word(k:k) = char(ichar(word(k:k)) - idiff)
203  end do
Here is the caller graph for this function:

◆ urdaux()

subroutine, public inputoutputmodule::urdaux ( integer(i4b), intent(inout)  naux,
integer(i4b), intent(in)  inunit,
integer(i4b), intent(in)  iout,
integer(i4b), intent(inout)  lloc,
integer(i4b), intent(inout)  istart,
integer(i4b), intent(inout)  istop,
character(len=lenauxname), dimension(:), intent(inout), allocatable  auxname,
character(len=*), intent(inout)  line,
character(len=*), intent(in)  text 
)

Definition at line 1316 of file InputOutput.f90.

1317  ! -- modules
1318  use arrayhandlersmodule, only: expandarray
1319  use constantsmodule, only: lenauxname
1320  ! -- implicit
1321  implicit none
1322  ! -- dummy
1323  integer(I4B), intent(inout) :: naux
1324  integer(I4B), intent(in) :: inunit
1325  integer(I4B), intent(in) :: iout
1326  integer(I4B), intent(inout) :: lloc
1327  integer(I4B), intent(inout) :: istart
1328  integer(I4B), intent(inout) :: istop
1329  character(len=LENAUXNAME), allocatable, dimension(:), intent(inout) :: auxname
1330  character(len=*), intent(inout) :: line
1331  character(len=*), intent(in) :: text
1332  ! -- local
1333  integer(I4B) :: n, linelen
1334  integer(I4B) :: iauxlen
1335  real(DP) :: rval
1336  !
1337  linelen = len(line)
1338  if (naux > 0) then
1339  write (errmsg, '(a)') 'Auxiliary variables already specified. '// &
1340  & 'Auxiliary variables must be specified on one line in the '// &
1341  & 'options block.'
1342  call store_error(errmsg)
1343  call store_error_unit(inunit)
1344  end if
1345  auxloop: do
1346  call urword(line, lloc, istart, istop, 1, n, rval, iout, inunit)
1347  if (istart >= linelen) exit auxloop
1348  iauxlen = istop - istart + 1
1349  if (iauxlen > lenauxname) then
1350  write (errmsg, '(a, a, a, i0, a, i0, a)') &
1351  'Found auxiliary variable (', line(istart:istop), &
1352  ') with a name of size ', iauxlen, &
1353  '. Auxiliary variable names must be len than or equal&
1354  & to ', lenauxname, ' characters.'
1355  call store_error(errmsg)
1356  call store_error_unit(inunit)
1357  end if
1358  naux = naux + 1
1359  call expandarray(auxname)
1360  auxname(naux) = line(istart:istop)
1361  if (iout > 0) then
1362  write (iout, "(4X,'AUXILIARY ',a,' VARIABLE: ',A)") &
1363  trim(adjustl(text)), auxname(naux)
1364  end if
1365  end do auxloop
integer(i4b), parameter lenauxname
maximum length of a aux variable
Definition: Constants.f90:35
Here is the call graph for this function:
Here is the caller graph for this function:

◆ urword()

subroutine, public inputoutputmodule::urword ( character(len=*)  line,
integer(i4b), intent(inout)  icol,
integer(i4b), intent(inout)  istart,
integer(i4b), intent(inout)  istop,
integer(i4b), intent(in)  ncode,
integer(i4b), intent(inout)  n,
real(dp), intent(inout)  r,
integer(i4b), intent(in)  iout,
integer(i4b), intent(in)  in 
)

Subroutine to extract a word from a line of text, and optionally convert the word to a number. The last character in the line is set to blank so that if any problems occur with finding a word, istart and istop will point to this blank character. Thus, a word will always be returned unless there is a numeric conversion error. Be sure that the last character in line is not an important character because it will always be set to blank.

A word starts with the first character that is not a space or comma, and ends when a subsequent character that is a space or comma. Note that these parsing rules do not treat two commas separated by one or more spaces as a null word.

For a word that begins with "'" or '"', the word starts with the character after the quote and ends with the character preceding a subsequent quote. Thus, a quoted word can include spaces and commas. The quoted word cannot contain a quote character of the same type within the word but can contain a different quote character. For example, "WORD'S" or 'WORD"S'.

Number conversion error is written to unit iout if iout is positive; error is written to default output if iout is 0; no error message is written if iout is negative.

Parameters
lineline to parse
[in,out]icolcurrent column in line
[in,out]istartstarting character position of the word
[in,out]istopending character position of the word
[in]ncodeword conversion flag (1) upper case, (2) integer, (3) real number
[in,out]ninteger data type
[in,out]rfloat data type
[in]ioutoutput listing file unit
[in]ininput file unit number

Definition at line 405 of file InputOutput.f90.

406  ! -- dummy
407  character(len=*) :: line !< line to parse
408  integer(I4B), intent(inout) :: icol !< current column in line
409  integer(I4B), intent(inout) :: istart !< starting character position of the word
410  integer(I4B), intent(inout) :: istop !< ending character position of the word
411  integer(I4B), intent(in) :: ncode !< word conversion flag (1) upper case, (2) integer, (3) real number
412  integer(I4B), intent(inout) :: n !< integer data type
413  real(DP), intent(inout) :: r !< float data type
414  integer(I4B), intent(in) :: iout !< output listing file unit
415  integer(I4B), intent(in) :: in !< input file unit number
416  ! -- local
417  character(len=20) string
418  character(len=30) rw
419  character(len=1) tab
420  character(len=1) charend
421  character(len=200) :: msg
422  character(len=linelength) :: msg_line
423  ! -- formats
424  character(len=*), parameter :: fmtmsgout1 = &
425  "(1X,'FILE UNIT ',I4,' : ERROR CONVERTING ""',A, &
426  & '"" TO ',A,' IN LINE:')"
427  character(len=*), parameter :: fmtmsgout2 = "(1x, &
428  & 'KEYBOARD INPUT : ERROR CONVERTING ""',a,'"" TO ',a,' IN LINE:')"
429  character(len=*), parameter :: fmtmsgout3 = "('File unit ', &
430  & I0,': Error converting ""',a,'"" to ',A,' in following line:')"
431  character(len=*), parameter :: fmtmsgout4 = &
432  "('Keyboard input: Error converting ""',a, &
433  & '"" to ',A,' in following line:')"
434  !
435  tab = char(9)
436  !
437  ! -- Set last char in LINE to blank and set ISTART and ISTOP to point
438  ! to this blank as a default situation when no word is found. If
439  ! starting location in LINE is out of bounds, do not look for a word.
440  linlen = len(line)
441  line(linlen:linlen) = ' '
442  istart = linlen
443  istop = linlen
444  linlen = linlen - 1
445  if (icol < 1 .or. icol > linlen) go to 100
446  !
447  ! -- Find start of word, which is indicated by first character that
448  ! is not a blank, a comma, or a tab.
449  do i = icol, linlen
450  if (line(i:i) /= ' ' .and. line(i:i) /= ',' .and. &
451  line(i:i) /= tab) go to 20
452  end do
453  icol = linlen + 1
454  go to 100
455  !
456  ! -- Found start of word. Look for end.
457  ! When word is quoted, only a quote can terminate it.
458  ! search for a single (char(39)) or double (char(34)) quote
459 20 if (line(i:i) == char(34) .or. line(i:i) == char(39)) then
460  if (line(i:i) == char(34)) then
461  charend = char(34)
462  else
463  charend = char(39)
464  end if
465  i = i + 1
466  if (i <= linlen) then
467  do j = i, linlen
468  if (line(j:j) == charend) go to 40
469  end do
470  end if
471  !
472  ! -- When word is not quoted, space, comma, or tab will terminate.
473  else
474  do j = i, linlen
475  if (line(j:j) == ' ' .or. line(j:j) == ',' .or. &
476  line(j:j) == tab) go to 40
477  end do
478  end if
479  !
480  ! -- End of line without finding end of word; set end of word to
481  ! end of line.
482  j = linlen + 1
483  !
484  ! -- Found end of word; set J to point to last character in WORD and
485  ! set ICOL to point to location for scanning for another word.
486 40 icol = j + 1
487  j = j - 1
488  if (j < i) go to 100
489  istart = i
490  istop = j
491  !
492  ! -- Convert word to upper case and RETURN if NCODE is 1.
493  if (ncode == 1) then
494  idiff = ichar('a') - ichar('A')
495  do k = istart, istop
496  if (line(k:k) >= 'a' .and. line(k:k) <= 'z') &
497  line(k:k) = char(ichar(line(k:k)) - idiff)
498  end do
499  return
500  end if
501  !
502  ! -- Convert word to a number if requested.
503 100 if (ncode == 2 .or. ncode == 3) then
504  rw = ' '
505  l = 30 - istop + istart
506  if (l < 1) go to 200
507  rw(l:30) = line(istart:istop)
508  if (ncode == 2) read (rw, '(i30)', err=200) n
509  if (ncode == 3) read (rw, '(f30.0)', err=200) r
510  end if
511  return
512  !
513  ! -- Number conversion error.
514 200 if (ncode == 3) then
515  string = 'a real number'
516  l = 13
517  else
518  string = 'an integer'
519  l = 10
520  end if
521  !
522  ! -- If output unit is negative, set last character of string to 'E'.
523  if (iout < 0) then
524  n = 0
525  r = 0.
526  line(linlen + 1:linlen + 1) = 'E'
527  return
528  !
529  ! -- If output unit is positive; write a message to output unit.
530  else if (iout > 0) then
531  if (in > 0) then
532  write (msg_line, fmtmsgout1) in, line(istart:istop), string(1:l)
533  else
534  write (msg_line, fmtmsgout2) line(istart:istop), string(1:l)
535  end if
536  call write_message(msg_line, iunit=iout, skipbefore=1)
537  call write_message(line, iunit=iout, fmt='(1x,a)')
538  !
539  ! -- If output unit is 0; write a message to default output.
540  else
541  if (in > 0) then
542  write (msg_line, fmtmsgout1) in, line(istart:istop), string(1:l)
543  else
544  write (msg_line, fmtmsgout2) line(istart:istop), string(1:l)
545  end if
546  call write_message(msg_line, iunit=iout, skipbefore=1)
547  call write_message(line, iunit=iout, fmt='(1x,a)')
548  end if
549  !
550  ! -- STOP after storing error message.
551  call lowcase(string)
552  if (in > 0) then
553  write (msg, fmtmsgout3) in, line(istart:istop), trim(string)
554  else
555  write (msg, fmtmsgout4) line(istart:istop), trim(string)
556  end if
557  !
558  call store_error(msg)
559  call store_error(trim(line))
560  call store_error_unit(in)
Here is the call graph for this function:

◆ uwword()

subroutine, public inputoutputmodule::uwword ( character(len=*), intent(inout)  line,
integer(i4b), intent(inout)  icol,
integer(i4b), intent(in)  ilen,
integer(i4b), intent(in)  ncode,
character(len=*), intent(in)  c,
integer(i4b), intent(in)  n,
real(dp), intent(in)  r,
character(len=*), intent(in), optional  fmt,
integer(i4b), intent(in), optional  alignment,
character(len=*), intent(in), optional  sep 
)

Subroutine to create a formatted line with specified alignment and column separators. Like URWORD, UWWORD works with strings, integers, and floats. Can pass an optional format statement, alignment, and column separator.

Parameters
[in,out]icolcolumn to write to line
[in]ilencurrent length of line
[in]ncodecode for data type to write
[in]ccharacter data type
[in]ninteger data type
[in]rfloat data type
[in]fmtformat statement
[in]alignmentalignment specifier
[in]sepcolumn separator

Definition at line 267 of file InputOutput.f90.

268  implicit none
269  ! -- dummy
270  character(len=*), intent(inout) :: line !< line
271  integer(I4B), intent(inout) :: icol !< column to write to line
272  integer(I4B), intent(in) :: ilen !< current length of line
273  integer(I4B), intent(in) :: ncode !< code for data type to write
274  character(len=*), intent(in) :: c !< character data type
275  integer(I4B), intent(in) :: n !< integer data type
276  real(DP), intent(in) :: r !< float data type
277  character(len=*), optional, intent(in) :: fmt !< format statement
278  integer(I4B), optional, intent(in) :: alignment !< alignment specifier
279  character(len=*), optional, intent(in) :: sep !< column separator
280  ! -- local
281  character(len=16) :: cfmt
282  character(len=16) :: cffmt
283  character(len=ILEN) :: cval
284  integer(I4B) :: ialign
285  integer(I4B) :: i
286  integer(I4B) :: ispace
287  integer(I4B) :: istop
288  integer(I4B) :: ipad
289  integer(I4B) :: ireal
290  !
291  ! -- initialize locals
292  ipad = 0
293  ireal = 0
294  !
295  ! -- process dummy variables
296  if (present(fmt)) then
297  cfmt = fmt
298  else
299  select case (ncode)
300  case (tabstring, tabucstring)
301  write (cfmt, '(a,I0,a)') '(a', ilen, ')'
302  case (tabinteger)
303  write (cfmt, '(a,I0,a)') '(I', ilen, ')'
304  case (tabreal)
305  ireal = 1
306  i = ilen - 7
307  write (cfmt, '(a,I0,a,I0,a)') '(1PG', ilen, '.', i, ')'
308  if (r >= dzero) then
309  ipad = 1
310  end if
311  end select
312  end if
313  write (cffmt, '(a,I0,a)') '(a', ilen, ')'
314  !
315  if (present(alignment)) then
316  ialign = alignment
317  else
318  ialign = tabright
319  end if
320  !
321  if (ncode == tabstring .or. ncode == tabucstring) then
322  cval = c
323  if (ncode == tabucstring) then
324  call upcase(cval)
325  end if
326  else if (ncode == tabinteger) then
327  write (cval, cfmt) n
328  else if (ncode == tabreal) then
329  write (cval, cfmt) r
330  end if
331  !
332  ! -- Apply alignment to cval
333  if (len_trim(adjustl(cval)) > ilen) then
334  cval = adjustl(cval)
335  else
336  cval = trim(adjustl(cval))
337  end if
338  if (ialign == tabcenter) then
339  i = len_trim(cval)
340  ispace = (ilen - i) / 2
341  if (ireal > 0) then
342  if (ipad > 0) then
343  cval = ' '//trim(adjustl(cval))
344  else
345  cval = trim(adjustl(cval))
346  end if
347  else
348  cval = repeat(' ', ispace)//trim(cval)
349  end if
350  else if (ialign == tableft) then
351  cval = trim(adjustl(cval))
352  if (ipad > 0) then
353  cval = ' '//trim(adjustl(cval))
354  end if
355  else
356  cval = adjustr(cval)
357  end if
358  if (ncode == tabucstring) then
359  call upcase(cval)
360  end if
361  !
362  ! -- Increment istop to the end of the column
363  istop = icol + ilen - 1
364  !
365  ! -- Write final string to line
366  write (line(icol:istop), cffmt) cval
367  !
368  icol = istop + 1
369  !
370  if (present(sep)) then
371  i = len(sep)
372  istop = icol + i
373  write (line(icol:istop), '(a)') sep
374  icol = istop
375  end if
Here is the call graph for this function:
Here is the caller graph for this function: