MODFLOW 6  version 6.8.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 assign_iounit (iounit, errunit, description)
 @ brief assign io 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 250 of file InputOutput.f90.

251  ! -- dummy
252  character(len=LINELENGTH), intent(inout) :: name !< file name
253  integer(I4B), intent(in) :: proc_id !< processor id
254  ! -- local
255  character(len=LINELENGTH) :: name_local
256  character(len=LINELENGTH) :: name_processor
257  character(len=LINELENGTH) :: extension_local
258  integer(I4B) :: ipos0
259  integer(I4B) :: ipos1
260  !
261  name_local = name
262  call lowcase(name_local)
263  ipos0 = index(name_local, ".", back=.true.)
264  ipos1 = len_trim(name)
265  if (ipos0 > 0) then
266  write (extension_local, '(a)') name(ipos0:ipos1)
267  else
268  ipos0 = ipos1
269  extension_local = ''
270  end if
271  write (name_processor, '(a,a,i0,a)') &
272  name(1:ipos0 - 1), '.p', proc_id, trim(adjustl(extension_local))
273  name = name_processor
Here is the call graph for this function:
Here is the caller graph for this function:

◆ assign_iounit()

subroutine, public inputoutputmodule::assign_iounit ( integer(i4b), intent(inout)  iounit,
integer(i4b), intent(in)  errunit,
character(len=*), intent(in)  description 
)

Generic method to assign io unit number to unassigned integer variable (initialized less than or equal to 0). Assigns a valid number if unassigned, otherwise sets a terminating error.

Parameters
[in,out]iounitiounit variable
[in]errunitinput file inunit for error assignment
[in]descriptionusage description for iounit

Definition at line 184 of file InputOutput.f90.

185  integer(I4B), intent(inout) :: iounit !< iounit variable
186  integer(I4B), intent(in) :: errunit !< input file inunit for error assignment
187  character(len=*), intent(in) :: description !< usage description for iounit
188  if (iounit > 0) then
189  write (errmsg, '(a,1x,i0)') &
190  trim(description)//' already assigned at unit: ', iounit
191  call store_error(errmsg)
192  call store_error_unit(errunit)
193  end if
194  iounit = getunit()
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 1524 of file InputOutput.f90.

1525  implicit none
1526  ! -- dummy
1527  integer(I4B), intent(in) :: nvalsp, nwidp, ndig
1528  character(len=*), intent(inout) :: outfmt
1529  logical, intent(in), optional :: prowcolnum ! default true
1530  ! -- local
1531  character(len=8) :: cvalues, cwidth, cdigits
1532  character(len=60) :: ufmt
1533  logical :: prowcolnumlocal
1534  ! -- formats
1535  character(len=*), parameter :: fmtndig = "(i8)"
1536  !
1537  if (present(prowcolnum)) then
1538  prowcolnumlocal = prowcolnum
1539  else
1540  prowcolnumlocal = .true.
1541  end if
1542  !
1543  ! -- Convert integers to characters and left-adjust
1544  write (cdigits, fmtndig) ndig
1545  cdigits = adjustl(cdigits)
1546  !
1547  ! -- Build format for printing to the list file in wrap format
1548  write (cvalues, fmtndig) nvalsp
1549  cvalues = adjustl(cvalues)
1550  write (cwidth, fmtndig) nwidp
1551  cwidth = adjustl(cwidth)
1552  if (prowcolnumlocal) then
1553  ufmt = '(1x,i3,1x,'
1554  else
1555  ufmt = '(5x,'
1556  end if
1557  !
1558  ufmt = trim(ufmt)//cvalues
1559  ufmt = trim(ufmt)//'(1x,f'
1560  ufmt = trim(ufmt)//cwidth
1561  ufmt = trim(ufmt)//'.'
1562  ufmt = trim(ufmt)//cdigits
1563  ufmt = trim(ufmt)//'):/(5x,'
1564  ufmt = trim(ufmt)//cvalues
1565  ufmt = trim(ufmt)//'(1x,f'
1566  ufmt = trim(ufmt)//cwidth
1567  ufmt = trim(ufmt)//'.'
1568  ufmt = trim(ufmt)//cdigits
1569  ufmt = trim(ufmt)//')))'
1570  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 1575 of file InputOutput.f90.

1576  implicit none
1577  ! -- dummy
1578  integer(I4B), intent(in) :: nvalsp, nwidp, ndig
1579  character(len=*), intent(in) :: editdesc
1580  character(len=*), intent(inout) :: outfmt
1581  logical, intent(in), optional :: prowcolnum ! default true
1582  ! -- local
1583  character(len=8) :: cvalues, cwidth, cdigits
1584  character(len=60) :: ufmt
1585  logical :: prowcolnumlocal
1586  ! -- formats
1587  character(len=*), parameter :: fmtndig = "(i8)"
1588  !
1589  if (present(prowcolnum)) then
1590  prowcolnumlocal = prowcolnum
1591  else
1592  prowcolnumlocal = .true.
1593  end if
1594  !
1595  ! -- Build the format
1596  write (cdigits, fmtndig) ndig
1597  cdigits = adjustl(cdigits)
1598  ! -- Convert integers to characters and left-adjust
1599  write (cwidth, fmtndig) nwidp
1600  cwidth = adjustl(cwidth)
1601  ! -- Build format for printing to the list file
1602  write (cvalues, fmtndig) (nvalsp - 1)
1603  cvalues = adjustl(cvalues)
1604  if (prowcolnumlocal) then
1605  ufmt = '(1x,i3,2x,1p,'//editdesc
1606  else
1607  ufmt = '(6x,1p,'//editdesc
1608  end if
1609  ufmt = trim(ufmt)//cwidth
1610  ufmt = trim(ufmt)//'.'
1611  ufmt = trim(ufmt)//cdigits
1612  if (nvalsp > 1) then
1613  ufmt = trim(ufmt)//','
1614  ufmt = trim(ufmt)//cvalues
1615  ufmt = trim(ufmt)//'(1x,'
1616  ufmt = trim(ufmt)//editdesc
1617  ufmt = trim(ufmt)//cwidth
1618  ufmt = trim(ufmt)//'.'
1619  ufmt = trim(ufmt)//cdigits
1620  ufmt = trim(ufmt)//')'
1621  end if
1622  !
1623  ufmt = trim(ufmt)//':/(5x,'
1624  write (cvalues, fmtndig) nvalsp
1625  cvalues = adjustl(cvalues)
1626  ufmt = trim(ufmt)//cvalues
1627  ufmt = trim(ufmt)//'(1x,'
1628  ufmt = trim(ufmt)//editdesc
1629  ufmt = trim(ufmt)//cwidth
1630  ufmt = trim(ufmt)//'.'
1631  ufmt = trim(ufmt)//cdigits
1632  ufmt = trim(ufmt)//')))'
1633  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 1638 of file InputOutput.f90.

1639  implicit none
1640  ! -- dummy
1641  integer(I4B), intent(in) :: nvalsp, nwidp
1642  character(len=*), intent(inout) :: outfmt
1643  logical, intent(in), optional :: prowcolnum ! default true
1644  ! -- local
1645  character(len=8) :: cvalues, cwidth
1646  character(len=60) :: ufmt
1647  logical :: prowcolnumlocal
1648  ! -- formats
1649  character(len=*), parameter :: fmtndig = "(i8)"
1650  !
1651  if (present(prowcolnum)) then
1652  prowcolnumlocal = prowcolnum
1653  else
1654  prowcolnumlocal = .true.
1655  end if
1656  !
1657  ! -- Build format for printing to the list file in wrap format
1658  write (cvalues, fmtndig) nvalsp
1659  cvalues = adjustl(cvalues)
1660  write (cwidth, fmtndig) nwidp
1661  cwidth = adjustl(cwidth)
1662  if (prowcolnumlocal) then
1663  ufmt = '(1x,i3,1x,'
1664  else
1665  ufmt = '(5x,'
1666  end if
1667  ufmt = trim(ufmt)//cvalues
1668  ufmt = trim(ufmt)//'(1x,i'
1669  ufmt = trim(ufmt)//cwidth
1670  ufmt = trim(ufmt)//'):/(5x,'
1671  ufmt = trim(ufmt)//cvalues
1672  ufmt = trim(ufmt)//'(1x,i'
1673  ufmt = trim(ufmt)//cwidth
1674  ufmt = trim(ufmt)//')))'
1675  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 1310 of file InputOutput.f90.

1311  implicit none
1312  ! -- dummy
1313  character(len=*), intent(inout) :: line
1314  integer(I4B), intent(inout) :: icol, istart, istop
1315  integer(I4B), intent(out) :: idnum
1316  character(len=LENBOUNDNAME), intent(out) :: bndname
1317  ! -- local
1318  integer(I4B) :: istat, ndum, ncode = 0
1319  real(DP) :: rdum
1320  !
1321  call urword(line, icol, istart, istop, ncode, ndum, rdum, 0, 0)
1322  read (line(istart:istop), *, iostat=istat) ndum
1323  if (istat == 0) then
1324  idnum = ndum
1325  bndname = ''
1326  else
1327  idnum = namedboundflag
1328  bndname = line(istart:istop)
1329  call upcase(bndname)
1330  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 144 of file InputOutput.f90.

145  ! -- modules
146  implicit none
147  ! -- dummy
148  integer(I4B), intent(inout) :: iu !< next free file unit number
149  ! -- local
150  integer(I4B) :: i
151  logical :: opened
152  !
153  do i = iunext, iulast
154  inquire (unit=i, opened=opened)
155  if (.not. opened) exit
156  end do
157  iu = i
158  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 1712 of file InputOutput.f90.

1713  ! -- dummy
1714  integer(I4B), intent(in) :: iu
1715  integer(I4B), intent(in) :: offset
1716  integer(I4B), intent(in) :: whence
1717  integer(I4B), intent(inout) :: status
1718  ! -- local
1719  integer(I8B) :: ipos
1720  character(len=20) :: file_action
1721  !
1722  inquire (unit=iu, size=ipos)
1723  !
1724  select case (whence)
1725  case (0)
1726  !
1727  ! -- whence = 0, offset is relative to start of file
1728  ipos = 0 + offset
1729  case (1)
1730  !
1731  ! -- whence = 1, offset is relative to current pointer position
1732  inquire (unit=iu, pos=ipos)
1733  ipos = ipos + offset
1734  case (2)
1735  !
1736  ! -- whence = 2, offset is relative to end of file
1737  inquire (unit=iu, size=ipos)
1738  ipos = ipos + offset
1739  end select
1740  !
1741  ! -- position the file pointer to ipos using read or write depending
1742  ! on the file action, since write fails on read-only files and
1743  ! read fails on write-only files
1744  inquire (unit=iu, action=file_action)
1745  if (trim(file_action) == 'READ') then
1746  read (iu, pos=ipos, iostat=status)
1747  else
1748  write (iu, pos=ipos, iostat=status)
1749  end if
1750  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 1856 of file InputOutput.f90.

1857  ! -- dummy
1858  integer(I4B), intent(in) :: lun
1859  character(len=:), intent(out), allocatable :: line
1860  integer(I4B), intent(out) :: iostat
1861  ! -- local
1862  integer(I4B), parameter :: buffer_len = maxcharlen
1863  character(len=buffer_len) :: buffer
1864  character(len=:), allocatable :: linetemp
1865  integer(I4B) :: size_read, linesize
1866  character(len=1), parameter :: cr = char(13)
1867  character(len=1), parameter :: lf = char(10)
1868  !
1869  ! -- initialize
1870  line = ''
1871  linetemp = ''
1872  !
1873  ! -- process
1874  do
1875  read (lun, '(A)', iostat=iostat, advance='no', size=size_read) buffer
1876  if (is_iostat_eor(iostat)) then
1877  linesize = len(line)
1878  deallocate (linetemp)
1879  allocate (character(len=linesize) :: linetemp)
1880  linetemp(:) = line(:)
1881  deallocate (line)
1882  allocate (character(len=linesize + size_read + 1) :: line)
1883  line(:) = linetemp(:)
1884  line(linesize + 1:) = buffer(:size_read)
1885  linesize = len(line)
1886  line(linesize:linesize) = ' '
1887  iostat = 0
1888  exit
1889  else if (iostat == 0) then
1890  linesize = len(line)
1891  deallocate (linetemp)
1892  allocate (character(len=linesize) :: linetemp)
1893  linetemp(:) = line(:)
1894  deallocate (line)
1895  allocate (character(len=linesize + size_read) :: line)
1896  line(:) = linetemp(:)
1897  line(linesize + 1:) = buffer(:size_read)
1898  else
1899  exit
1900  end if
1901  end do
1902  !
1903  ! -- look for undetected end-of-record with isolated CR or LF
1904  linesize = len(line)
1905  crlfcheck: do i = 1, linesize
1906  if (line(i:i) .eq. cr .or. line(i:i) .eq. lf) then
1907  if (line(i:i) .eq. cr) then
1908  write (errmsg, '(a)') &
1909  'get_line: Found an isolated Carriage Return.'
1910  end if
1911  if (line(i:i) .eq. lf) then
1912  write (errmsg, '(a)') &
1913  'get_line: Found an isolated Line Feed.'
1914  end if
1915  write (errmsg, '(a,1x,a,a)') trim(errmsg), &
1916  'Replace with Carriage Return and Line Feed to', &
1917  ' read as two separate lines.'
1918  write (errmsg, '(a,1x,5a)') trim(errmsg), &
1919  'Line: "', line(1:i - 1), '|', line(i + 1:linesize), '"'
1920  call store_error(errmsg, terminate=.false.)
1921  call store_error_unit(lun, terminate=.true.)
1922  end if
1923  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 1680 of file InputOutput.f90.

1681  ! -- return
1682  integer(I4B) :: get_nwords !< number of words in a string
1683  ! -- dummy
1684  character(len=*), intent(in) :: line !< line
1685  ! -- local
1686  integer(I4B) :: linelen
1687  integer(I4B) :: lloc
1688  integer(I4B) :: istart
1689  integer(I4B) :: istop
1690  integer(I4B) :: idum
1691  real(DP) :: rdum
1692  !
1693  ! -- initialize variables
1694  get_nwords = 0
1695  linelen = len(line)
1696  !
1697  ! -- Count words in line and allocate words array
1698  lloc = 1
1699  do
1700  call urword(line, lloc, istart, istop, 0, idum, rdum, 0, 0)
1701  if (istart == linelen) exit
1702  get_nwords = get_nwords + 1
1703  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 1274 of file InputOutput.f90.

1275  implicit none
1276  ! -- dummy
1277  character(len=*), intent(in) :: pathname
1278  character(len=*), intent(out) :: filename
1279  ! -- local
1280  integer(I4B) :: i, istart, istop, lenpath
1281  character(len=1) :: fs = '/'
1282  character(len=1) :: bs = '\'
1283  !
1284  filename = ''
1285  lenpath = len_trim(pathname)
1286  istart = 1
1287  istop = lenpath
1288  loop: do i = lenpath, 1, -1
1289  if (pathname(i:i) == fs .or. pathname(i:i) == bs) then
1290  if (i == istop) then
1291  istop = istop - 1
1292  else
1293  istart = i + 1
1294  exit loop
1295  end if
1296  end if
1297  end do loop
1298  if (istop >= istart) then
1299  filename = pathname(istart:istop)
1300  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 165 of file InputOutput.f90.

166  ! -- modules
167  implicit none
168  ! -- return
169  integer(I4B) :: getunit !< free unit number
170  ! -- local
171  integer(I4B) :: iunit
172  !
173  ! -- code
174  call freeunitnumber(iunit)
175  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 225 of file InputOutput.f90.

226  implicit none
227  ! -- dummy
228  character(len=*) :: word
229  ! -- local
230  integer(I4B) :: idiff, k, l
231  !
232  ! -- Compute the difference between lowercase and uppercase.
233  l = len(word)
234  idiff = ichar('a') - ichar('A')
235  !
236  ! -- Loop through the string and convert any uppercase characters.
237  do k = 1, l
238  if (word(k:k) >= 'A' .and. word(k:k) <= 'Z') then
239  word(k:k) = char(ichar(word(k:k)) + idiff)
240  end if
241  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 if file is already open
105  inquire (file=fname(1:iflen), number=iuop)
106  open (unit=iu, file=fname(1:iflen), form=fmtarg, access=accarg, &
107  status=filstat, action=filact, iostat=ivar)
108  !
109  ! -- Check for an error
110  if (ivar /= 0) then
111  write (errmsg, '(3a,1x,i0,a)') &
112  'Could not open "', fname(1:iflen), '" on unit', iu, '.'
113  if (iuop > 0) then
114  write (errmsg, '(a,1x,a,1x,i0,a)') &
115  trim(errmsg), 'File already open on unit', iuop, '.'
116  end if
117  write (errmsg, '(a,1x,a,1x,a,a)') &
118  trim(errmsg), 'Specified file status', trim(filstat), '.'
119  write (errmsg, '(a,1x,a,1x,a,a)') &
120  trim(errmsg), 'Specified file format', trim(fmtarg), '.'
121  write (errmsg, '(a,1x,a,1x,a,a)') &
122  trim(errmsg), 'Specified file access', trim(accarg), '.'
123  write (errmsg, '(a,1x,a,1x,a,a)') &
124  trim(errmsg), 'Specified file action', trim(filact), '.'
125  write (errmsg, '(a,1x,a,1x,i0,a)') &
126  trim(errmsg), 'IOSTAT error number', ivar, '.'
127  write (errmsg, '(a,1x,a)') &
128  trim(errmsg), 'STOP EXECUTION in subroutine openfile().'
129  call store_error(errmsg, terminate=.true.)
130  end if
131  !
132  ! -- Write a message
133  if (iout > 0) then
134  write (iout, fmtmsg) fname(1:iflen), ftype, iu, filstat, fmtarg, &
135  accarg, filact
136  end if
137  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 1127 of file InputOutput.f90.

1128  ! -- modules
1129  use constantsmodule, only: linelength
1130  implicit none
1131  ! -- dummy
1132  character(len=*), intent(in) :: line
1133  integer(I4B), intent(inout) :: nwords
1134  character(len=*), allocatable, dimension(:), intent(inout) :: words
1135  integer(I4B), intent(in), optional :: inunit
1136  character(len=*), intent(in), optional :: filename
1137  ! -- local
1138  integer(I4B) :: i, idum, istart, istop, linelen, lloc
1139  real(DP) :: rdum
1140  !
1141  nwords = 0
1142  if (allocated(words)) then
1143  deallocate (words)
1144  end if
1145  linelen = len(line)
1146  !
1147  ! -- get the number of words in a line and allocate words array
1148  nwords = get_nwords(line)
1149  allocate (words(nwords))
1150  !
1151  ! -- Populate words array and return
1152  lloc = 1
1153  do i = 1, nwords
1154  call urword(line, lloc, istart, istop, 0, idum, rdum, 0, 0)
1155  words(i) = line(istart:istop)
1156  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 1405 of file InputOutput.f90.

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

1216  !
1217  implicit none
1218  ! -- dummy
1219  integer(I4B), intent(in) :: iu
1220  logical, intent(out) :: eof
1221  character(len=:), allocatable :: astring
1222  ! -- local
1223  integer(I4B) :: isize, istat
1224  character(len=256) :: buffer
1225  character(len=1000) :: ermsg, fname
1226  character(len=7) :: fmtd
1227  logical :: lop
1228  ! -- formats
1229  character(len=*), parameter :: fmterrmsg1 = &
1230  & "('Error in read_line: File ',i0,' is not open.')"
1231  character(len=*), parameter :: fmterrmsg2 = &
1232  & "('Error in read_line: Attempting to read text ' // &
1233  & 'from unformatted file: ""',a,'""')"
1234  character(len=*), parameter :: fmterrmsg3 = &
1235  & "('Error reading from file ""',a,'"" opened on unit ',i0, &
1236  & ' in read_line.')"
1237  !
1238  astring = ''
1239  eof = .false.
1240  do
1241  read (iu, '(a)', advance='NO', iostat=istat, size=isize, end=99) buffer
1242  if (istat > 0) then
1243  ! Determine error if possible, report it, and stop.
1244  if (iu <= 0) then
1245  ermsg = 'Programming error in call to read_line: '// &
1246  'Attempt to read from unit number <= 0'
1247  else
1248  inquire (unit=iu, opened=lop, name=fname, formatted=fmtd)
1249  if (.not. lop) then
1250  write (ermsg, fmterrmsg1) iu
1251  elseif (fmtd == 'NO' .or. fmtd == 'UNKNOWN') then
1252  write (ermsg, fmterrmsg2) trim(fname)
1253  else
1254  write (ermsg, fmterrmsg3) trim(fname), iu
1255  end if
1256  end if
1257  call store_error(ermsg)
1258  call store_error_unit(iu)
1259  end if
1260  astring = astring//buffer(:isize)
1261  ! -- An end-of-record condition stops the loop.
1262  if (istat < 0) then
1263  return
1264  end if
1265  end do
1266  !
1267  return
1268 99 continue
1269  !
1270  ! An end-of-file condition returns an empty string.
1271  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 1071 of file InputOutput.f90.

1072  implicit none
1073  ! -- dummy
1074  character(len=*), intent(in) :: word1, word2
1075  ! -- local
1076  character(len=200) :: upword1, upword2
1077  !
1078  upword1 = word1
1079  call upcase(upword1)
1080  upword2 = word2
1081  call upcase(upword2)
1082  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 1087 of file InputOutput.f90.

1088  ! -- local
1089  character(len=*), intent(in) :: str
1090  integer, intent(in) :: width
1091  ! -- Return
1092  character(len=max(len_trim(str), width)) :: res
1093  !
1094  res = str
1095  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 1758 of file InputOutput.f90.

1759  ! -- module
1760  use, intrinsic :: iso_fortran_env, only: iostat_end
1761  implicit none
1762  ! -- dummy
1763  integer(I4B), intent(in) :: iin
1764  integer(I4B), intent(in) :: iout
1765  character(len=:), allocatable, intent(inout) :: line
1766  integer(I4B), intent(out) :: ierr
1767  ! -- local
1768  character(len=:), allocatable :: linetemp
1769  character(len=2), parameter :: comment = '//'
1770  character(len=1), parameter :: tab = char(9)
1771  logical :: iscomment
1772  integer(I4B) :: i, j, l, istart, lsize
1773  !
1774  !readerrmsg = ''
1775  line = comment
1776  pcomments: do
1777  call get_line(iin, line, ierr)
1778  if (ierr == iostat_end) then
1779  ! -- End of file reached. Return with ierr = IOSTAT_END
1780  ! and line as an empty string
1781  line = ' '
1782  exit pcomments
1783  elseif (ierr /= 0) then
1784  ! -- Other error...report it
1785  call unitinquire(iin)
1786  write (errmsg, *) 'u9rdcom: Could not read from unit: ', iin
1787  call store_error(errmsg, terminate=.true.)
1788  end if
1789  if (len_trim(line) < 1) then
1790  line = comment
1791  cycle
1792  end if
1793  !
1794  ! -- Ensure that any initial tab characters are treated as spaces
1795  cleartabs: do
1796  !
1797  ! -- adjustl manually to avoid stack overflow
1798  lsize = len(line)
1799  istart = 1
1800  allocate (character(len=lsize) :: linetemp)
1801  do j = 1, lsize
1802  if (line(j:j) /= ' ' .and. line(j:j) /= ',' .and. &
1803  line(j:j) /= char(9)) then
1804  istart = j
1805  exit
1806  end if
1807  end do
1808  linetemp(:) = ' '
1809  linetemp(:) = line(istart:)
1810  line(:) = linetemp(:)
1811  deallocate (linetemp)
1812  !
1813  ! -- check for comment
1814  iscomment = .false.
1815  select case (line(1:1))
1816  case ('#')
1817  iscomment = .true.
1818  exit cleartabs
1819  case ('!')
1820  iscomment = .true.
1821  exit cleartabs
1822  case (tab)
1823  line(1:1) = ' '
1824  cycle cleartabs
1825  case default
1826  if (line(1:2) == comment) iscomment = .true.
1827  if (len_trim(line) < 1) iscomment = .true.
1828  exit cleartabs
1829  end select
1830  end do cleartabs
1831  !
1832  if (.not. iscomment) then
1833  exit pcomments
1834  else
1835  if (iout > 0) then
1836  !find the last non-blank character.
1837  l = len(line)
1838  do i = l, 1, -1
1839  if (line(i:i) /= ' ') then
1840  exit
1841  end if
1842  end do
1843  ! -- print the line up to the last non-blank character.
1844  write (iout, '(1x,a)') line(1:i)
1845  end if
1846  end if
1847  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 977 of file InputOutput.f90.

980  implicit none
981  ! -- dummy
982  integer(I4B), intent(in) :: kstp
983  integer(I4B), intent(in) :: kper
984  character(len=*), intent(in) :: text
985  character(len=*), intent(in) :: modelnam1
986  character(len=*), intent(in) :: paknam1
987  character(len=*), intent(in) :: modelnam2
988  character(len=*), intent(in) :: paknam2
989  integer(I4B), intent(in) :: naux
990  character(len=16), dimension(:), intent(in) :: auxtxt
991  integer(I4B), intent(in) :: ibdchn
992  integer(I4B), intent(in) :: ncol
993  integer(I4B), intent(in) :: nrow
994  integer(I4B), intent(in) :: nlay
995  integer(I4B), intent(in) :: nlist
996  integer(I4B), intent(in) :: iout
997  real(DP), intent(in) :: delt
998  real(DP), intent(in) :: pertim
999  real(DP), intent(in) :: totim
1000  ! -- local
1001  integer(I4B) :: n
1002  ! -- format
1003  character(len=*), parameter :: fmt = &
1004  & "(1X,'UBDSV06 SAVING ',A16,' IN MODEL ',A16,' PACKAGE ',A16,"// &
1005  & "'CONNECTED TO MODEL ',A16,' PACKAGE ',A16,"// &
1006  & "' ON UNIT',I7,' AT TIME STEP',I7,', STRESS PERIOD',I7)"
1007  !
1008  ! -- Write unformatted records identifying data.
1009  if (iout > 0) write (iout, fmt) text, modelnam1, paknam1, modelnam2, &
1010  paknam2, ibdchn, kstp, kper
1011  write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
1012  write (ibdchn) 6, delt, pertim, totim
1013  write (ibdchn) modelnam1
1014  write (ibdchn) paknam1
1015  write (ibdchn) modelnam2
1016  write (ibdchn) paknam2
1017  write (ibdchn) naux + 1
1018  if (naux > 0) write (ibdchn) (auxtxt(n), n=1, naux)
1019  write (ibdchn) nlist
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 941 of file InputOutput.f90.

943  implicit none
944  ! -- dummy
945  integer(I4B), intent(in) :: kstp
946  integer(I4B), intent(in) :: kper
947  character(len=*), intent(in) :: text
948  integer(I4B), intent(in) :: ibdchn
949  real(DP), dimension(:), intent(in) :: buff
950  integer(I4B), intent(in) :: ncol
951  integer(I4B), intent(in) :: nrow
952  integer(I4B), intent(in) :: nlay
953  integer(I4B), intent(in) :: iout
954  real(DP), intent(in) :: delt
955  real(DP), intent(in) :: pertim
956  real(DP), intent(in) :: totim
957  ! -- format
958  character(len=*), parameter :: fmt = &
959  & "(1X,'UBDSV1 SAVING ',A16,' ON UNIT',I7,' AT TIME STEP',I7,"// &
960  & "', STRESS PERIOD',I7)"
961  !
962  ! -- Write records
963  if (iout > 0) write (iout, fmt) text, ibdchn, kstp, kper
964  write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
965  write (ibdchn) 1, delt, pertim, totim
966  write (ibdchn) buff
967  !
968  ! -- flush file
969  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 622 of file InputOutput.f90.

624  ! -- dummy
625  character(len=16) :: text
626  character(len=16), dimension(:) :: auxtxt
627  real(DP), intent(in) :: delt, pertim, totim
628  ! -- formats
629  character(len=*), parameter :: fmt = &
630  & "(1X,'UBDSV4 SAVING ',A16,' ON UNIT',I7,' AT TIME STEP',I7,"// &
631  & "', STRESS PERIOD',I7)"
632  !
633  ! -- Write unformatted records identifying data
634  if (iout > 0) write (iout, fmt) text, ibdchn, kstp, kper
635  write (ibdchn) kstp, kper, text, ncol, nrow, -nlay
636  write (ibdchn) 5, delt, pertim, totim
637  write (ibdchn) naux + 1
638  if (naux > 0) write (ibdchn) (auxtxt(n), n=1, naux)
639  write (ibdchn) nlist

◆ ubdsvb()

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

Definition at line 645 of file InputOutput.f90.

646  ! -- dummy
647  real(DP), dimension(nvl) :: val
648  real(DP) :: q
649  !
650  ! -- Write cell number and flow rate
651  IF (naux > 0) then
652  n2 = laux + naux - 1
653  write (ibdchn) icrl, q, (val(n), n=laux, n2)
654  else
655  write (ibdchn) icrl, q
656  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 1026 of file InputOutput.f90.

1027  implicit none
1028  ! -- dummy
1029  integer(I4B), intent(in) :: ibdchn
1030  integer(I4B), intent(in) :: n
1031  real(DP), intent(in) :: q
1032  integer(I4B), intent(in) :: naux
1033  real(DP), dimension(naux), intent(in) :: aux
1034  ! -- local
1035  integer(I4B) :: nn
1036  !
1037  ! -- Write record
1038  if (naux > 0) then
1039  write (ibdchn) n, q, (aux(nn), nn=1, naux)
1040  else
1041  write (ibdchn) n, q
1042  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 1049 of file InputOutput.f90.

1050  implicit none
1051  ! -- dummy
1052  integer(I4B), intent(in) :: ibdchn
1053  integer(I4B), intent(in) :: n
1054  integer(I4B), intent(in) :: n2
1055  real(DP), intent(in) :: q
1056  integer(I4B), intent(in) :: naux
1057  real(DP), dimension(naux), intent(in) :: aux
1058  ! -- local
1059  integer(I4B) :: nn
1060  !
1061  ! -- Write record
1062  if (naux > 0) then
1063  write (ibdchn) n, n2, q, (aux(nn), nn=1, naux)
1064  else
1065  write (ibdchn) n, n2, q
1066  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 668 of file InputOutput.f90.

669  ! -- local
670  character(len=1) :: DOT, SPACE, DG, BF
671  dimension :: bf(1000), dg(10)
672  ! -- constants
673  data dg(1), dg(2), dg(3), dg(4), dg(5), dg(6), dg(7), dg(8), dg(9), dg(10)/ &
674  & '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'/
675  data dot, space/'.', ' '/
676  ! -- formats
677  character(len=*), parameter :: fmtmsgout1 = "(1x)"
678  character(len=*), parameter :: fmtmsgout2 = "(1x, 1000a1)"
679  !
680  ! -- Calculate # of columns to be printed (nlbl), width
681  ! of a line (ntot), number of lines (nwrap).
682  if (iout <= 0) return
683  write (iout, fmtmsgout1)
684  !
685  nlbl = nlbl2 - nlbl1 + 1
686  n = nlbl
687  !
688  if (nlbl < ncpl) n = ncpl
689  ntot = nspace + n * ndig
690  !
691  if (ntot > 1000) go to 50
692  nwrap = (nlbl - 1) / ncpl + 1
693  j1 = nlbl1 - ncpl
694  j2 = nlbl1 - 1
695  !
696  ! -- Build and print each line
697  do n = 1, nwrap
698  !
699  ! -- Clear the buffer (BF)
700  do i = 1, 1000
701  bf(i) = space
702  end do
703  nbf = nspace
704  !
705  ! -- Determine first (j1) and last (j2) column # for this line.
706  j1 = j1 + ncpl
707  j2 = j2 + ncpl
708  if (j2 > nlbl2) j2 = nlbl2
709  !
710  ! -- Load the column #'s into the buffer.
711  do j = j1, j2
712  nbf = nbf + ndig
713  i2 = j / 10
714  i1 = j - i2 * 10 + 1
715  bf(nbf) = dg(i1)
716  if (i2 == 0) go to 30
717  i3 = i2 / 10
718  i2 = i2 - i3 * 10 + 1
719  bf(nbf - 1) = dg(i2)
720  if (i3 == 0) go to 30
721  i4 = i3 / 10
722  i3 = i3 - i4 * 10 + 1
723  bf(nbf - 2) = dg(i3)
724  if (i4 == 0) go to 30
725  if (i4 > 9) then
726  ! -- If more than 4 digits, use "X" for 4th digit.
727  bf(nbf - 3) = 'X'
728  else
729  bf(nbf - 3) = dg(i4 + 1)
730  end if
731 30 end do
732  !
733  ! -- Print the contents of the buffer (i.e. print the line).
734  write (iout, fmtmsgout2) (bf(i), i=1, nbf)
735  !
736  end do
737  !
738  ! -- Print a line of dots (for aesthetic purposes only).
739 50 ntot = ntot
740  if (ntot > 1000) ntot = 1000
741  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 1161 of file InputOutput.f90.

1163  implicit none
1164  ! -- dummy
1165  integer(I4B), intent(in) :: ncol, nrow, kstp, kper, ilay, iout
1166  real(DP), dimension(ncol, nrow), intent(in) :: buf
1167  character(len=*), intent(in) :: text
1168  character(len=*), intent(in) :: userfmt
1169  integer(I4B), intent(in) :: nvalues, nwidth
1170  character(len=1), intent(in) :: editdesc
1171  ! -- local
1172  integer(I4B) :: i, j, nspaces
1173  ! -- formats
1174  character(len=*), parameter :: fmtmsgout1 = &
1175  "('1',/2X,A,' IN LAYER ',I3,' AT END OF TIME STEP ',I3, &
1176 & ' IN STRESS PERIOD ',I4/2X,75('-'))"
1177  character(len=*), parameter :: fmtmsgout2 = &
1178  "('1',/1X,A,' FOR CROSS SECTION AT END OF TIME STEP',I3, &
1179 & ' IN STRESS PERIOD ',I4/1X,79('-'))"
1180  !
1181  if (iout <= 0) return
1182  ! -- Print a header depending on ILAY
1183  if (ilay > 0) then
1184  write (iout, fmtmsgout1) trim(text), ilay, kstp, kper
1185  else if (ilay < 0) then
1186  write (iout, fmtmsgout2) trim(text), kstp, kper
1187  end if
1188  !
1189  ! -- Print column numbers.
1190  nspaces = 0
1191  if (editdesc == 'F') nspaces = 3
1192  call ucolno(1, ncol, nspaces, nvalues, nwidth + 1, iout)
1193  !
1194  ! -- Loop through the rows, printing each one in its entirety.
1195  do i = 1, nrow
1196  write (iout, userfmt) i, (buf(j, i), j=1, ncol)
1197  end do
1198  !
1199  ! -- flush file
1200  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 746 of file InputOutput.f90.

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

922  ! -- dummy
923  character(len=16) :: text
924  real(DP), dimension(ncol, nrow) :: buf
925  real(DP) :: pertim, totim
926  !
927  ! -- Write an unformatted record containing identifying information
928  write (ichn) kstp, kper, pertim, totim, text, ncol, nrow, ilay
929  !
930  ! -- Write an unformatted record containing array values. The array is
931  ! dimensioned (ncol,nrow)
932  write (ichn) ((buf(ic, ir), ic=1, ncol), ir=1, nrow)
933  !
934  ! -- flush file
935  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 584 of file InputOutput.f90.

585  ! -- dummy
586  character(len=*) :: label
587  character(len=16) :: caux(ncaux)
588  ! -- local
589  character(len=400) buf
590  ! -- constant
591  character(len=1) DASH(400)
592  data dash/400*'-'/
593  ! -- formats
594  character(len=*), parameter :: fmtmsgout1 = "(1x, a)"
595  character(len=*), parameter :: fmtmsgout2 = "(1x, 400a)"
596  !
597  ! -- Construct the complete label in BUF. Start with BUF=LABEL.
598  buf = label
599  !
600  ! -- Add auxiliary data names if there are any.
601  nbuf = len(label) + 9
602  if (naux > 0) then
603  do i = 1, naux
604  n1 = nbuf + 1
605  nbuf = nbuf + 16
606  buf(n1:nbuf) = caux(i)
607  end do
608  end if
609  !
610  ! -- Write the label.
611  write (iout, fmtmsgout1) buf(1:nbuf)
612  !
613  ! -- Add a line of dashes.
614  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 1098 of file InputOutput.f90.

1099  ! -- dummy
1100  integer(I4B) :: iu
1101  ! -- local
1102  character(len=LINELENGTH) :: line
1103  character(len=100) :: fname, ac, act, fm, frm, seq, unf
1104  ! -- format
1105  character(len=*), parameter :: fmta = &
1106  &"('unit:',i4,' name:',a,' access:',a,' action:',a)"
1107  character(len=*), parameter :: fmtb = &
1108  &"(' formatted:',a,' sequential:',a,' unformatted:',a,' form:',a)"
1109  !
1110  ! -- set strings using inquire statement
1111  inquire (unit=iu, name=fname, access=ac, action=act, formatted=fm, &
1112  sequential=seq, unformatted=unf, form=frm)
1113  !
1114  ! -- write the results of the inquire statement
1115  write (line, fmta) iu, trim(fname), trim(ac), trim(act)
1116  call write_message(line)
1117  write (line, fmtb) trim(fm), trim(seq), trim(unf), trim(frm)
1118  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 201 of file InputOutput.f90.

202  implicit none
203  ! -- dummy
204  character(len=*), intent(inout) :: word !< word to convert to upper case
205  ! -- local
206  integer(I4B) :: l
207  integer(I4B) :: idiff
208  integer(I4B) :: k
209  !
210  ! -- Compute the difference between lowercase and uppercase.
211  l = len(word)
212  idiff = ichar('a') - ichar('A')
213  !
214  ! -- Loop through the string and convert any lowercase characters.
215  do k = 1, l
216  IF (word(k:k) >= 'a' .and. word(k:k) <= 'z') &
217  word(k:k) = char(ichar(word(k:k)) - idiff)
218  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 1335 of file InputOutput.f90.

1336  ! -- modules
1337  use arrayhandlersmodule, only: expandarray
1338  use constantsmodule, only: lenauxname
1339  ! -- implicit
1340  implicit none
1341  ! -- dummy
1342  integer(I4B), intent(inout) :: naux
1343  integer(I4B), intent(in) :: inunit
1344  integer(I4B), intent(in) :: iout
1345  integer(I4B), intent(inout) :: lloc
1346  integer(I4B), intent(inout) :: istart
1347  integer(I4B), intent(inout) :: istop
1348  character(len=LENAUXNAME), allocatable, dimension(:), intent(inout) :: auxname
1349  character(len=*), intent(inout) :: line
1350  character(len=*), intent(in) :: text
1351  ! -- local
1352  integer(I4B) :: n, linelen
1353  integer(I4B) :: iauxlen
1354  real(DP) :: rval
1355  !
1356  linelen = len(line)
1357  if (naux > 0) then
1358  write (errmsg, '(a)') 'Auxiliary variables already specified. '// &
1359  & 'Auxiliary variables must be specified on one line in the '// &
1360  & 'options block.'
1361  call store_error(errmsg)
1362  call store_error_unit(inunit)
1363  end if
1364  auxloop: do
1365  call urword(line, lloc, istart, istop, 1, n, rval, iout, inunit)
1366  if (istart >= linelen) exit auxloop
1367  iauxlen = istop - istart + 1
1368  if (iauxlen > lenauxname) then
1369  write (errmsg, '(a, a, a, i0, a, i0, a)') &
1370  'Found auxiliary variable (', line(istart:istop), &
1371  ') with a name of size ', iauxlen, &
1372  '. Auxiliary variable names must be len than or equal&
1373  & to ', lenauxname, ' characters.'
1374  call store_error(errmsg)
1375  call store_error_unit(inunit)
1376  end if
1377  naux = naux + 1
1378  call expandarray(auxname)
1379  auxname(naux) = line(istart:istop)
1380  if (iout > 0) then
1381  write (iout, "(4X,'AUXILIARY ',a,' VARIABLE: ',A)") &
1382  trim(adjustl(text)), auxname(naux)
1383  end if
1384  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 420 of file InputOutput.f90.

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

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