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

This module contains the LongLineReaderType. More...

Data Types

type  longlinereadertype
 LongLineReaderType. More...
 

Functions/Subroutines

subroutine rdcom (this, iu, iout, line, ierr)
 Return the first non-comment line. More...
 
subroutine bkspc (this, iin)
 Emulate a Fortran backspace. More...
 

Detailed Description

The LongLineReader is a utility for reading text lines from mf6 input files. It calls u9rdcom (which calls get_line) to read the first non-commented line of an input file. The LongLineReader can emulate the Fortran backspace command by calling the bkspc method, which stores the current line in last_line, and will return last_line upon the next call to rdcom. The LongLineReader was implemented to replace all Fortran backspace calls, due to a bug in ifort and ifx that prevented the backspace command from working properly with non-advancing IO.

Function/Subroutine Documentation

◆ bkspc()

subroutine longlinereadermodule::bkspc ( class(longlinereadertype this,
integer(i4b), intent(in)  iin 
)
private

Emulate a fortran backspace call by storing the current line in long_line

Definition at line 103 of file LongLineReader.f90.

104  class(LongLineReaderType) :: this
105  integer(I4B), intent(in) :: iin
106  if (this%nbackspace > 0) then
107  call store_error( &
108  "Programming error in LongLineReaderType%bkspc(). Backspace &
109  & called more than once for an open file.", &
110  terminate=.true.)
111  else
112  this%nbackspace = 1
113  end if
114  return
Here is the call graph for this function:

◆ rdcom()

subroutine longlinereadermodule::rdcom ( class(longlinereadertype this,
integer(i4b), intent(in)  iu,
integer(i4b), intent(in)  iout,
character(len=:), intent(inout), allocatable  line,
integer(i4b), intent(inout)  ierr 
)
private

Skip through any comments and return the first non-commented line. If an end of file was encountered previously, then return a blank line. If a backspace was called prior to this call, then do not read a new line and return last_line instead.

Definition at line 59 of file LongLineReader.f90.

60  class(LongLineReaderType) :: this
61  integer(I4B), intent(in) :: iu
62  integer(I4B), intent(in) :: iout
63  character(len=:), intent(inout), allocatable :: line
64  integer(I4B), intent(inout) :: ierr
65 
66  ierr = 0
67 
68  ! If using this reader to read from a new file
69  ! then reset state
70  if (iu /= this%last_unit) then
71  this%nbackspace = 0
72  this%iostat = 0
73  end if
74 
75  if (this%nbackspace == 1) then
76  ! If backspace was called, then return last line
77  if (allocated(line)) deallocate (line)
78  allocate (character(len=len(this%last_line) + 1) :: line)
79  line(:) = this%last_line(:)
80  this%nbackspace = 0
81  else
82  ! if end of file was reached previously, then return a
83  ! blank line and return ierr as IOSTAT_END
84  if (this%iostat == iostat_end) then
85  line = ' '
86  ierr = iostat_end
87  else
88  call u9rdcom(iu, iout, line, ierr)
89  end if
90  this%last_line = line
91  this%iostat = ierr
92  end if
93  this%last_unit = iu
94  return
Here is the call graph for this function: