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

Data Types

type  headfilereadertype
 

Functions/Subroutines

subroutine initialize (this, iu, iout)
 
subroutine read_record (this, success, iout_opt)
 
subroutine finalize (this)
 

Function/Subroutine Documentation

◆ finalize()

subroutine headfilereadermodule::finalize ( class(headfilereadertype this)

Definition at line 144 of file HeadFileReader.f90.

145 ! ******************************************************************************
146 ! budgetdata_finalize
147 ! ******************************************************************************
148 !
149 ! SPECIFICATIONS:
150 ! ------------------------------------------------------------------------------
151  class(HeadFileReaderType) :: this
152 ! ------------------------------------------------------------------------------
153  close (this%inunit)
154  if (allocated(this%head)) deallocate (this%head)
155  !
156  ! -- return
157  return

◆ initialize()

subroutine headfilereadermodule::initialize ( class(headfilereadertype this,
integer(i4b), intent(in)  iu,
integer(i4b), intent(in)  iout 
)
private

Definition at line 36 of file HeadFileReader.f90.

37 ! ******************************************************************************
38 ! initialize
39 ! ******************************************************************************
40 !
41 ! SPECIFICATIONS:
42 ! ------------------------------------------------------------------------------
43  ! -- dummy
44  class(HeadFileReaderType) :: this
45  integer(I4B), intent(in) :: iu
46  integer(I4B), intent(in) :: iout
47  ! -- local
48  integer(I4B) :: kstp_last, kper_last
49  logical :: success
50 ! ------------------------------------------------------------------------------
51  this%inunit = iu
52  this%endoffile = .false.
53  this%nlay = 0
54  !
55  ! -- Read the first head data record to set kstp_last, kstp_last
56  call this%read_record(success)
57  kstp_last = this%kstp
58  kper_last = this%kper
59  rewind(this%inunit)
60  !
61  ! -- Determine number of records within a time step
62  if (iout > 0) &
63  write (iout, '(a)') &
64  'Reading binary file to determine number of records per time step.'
65  do
66  call this%read_record(success, iout)
67  if (.not. success) exit
68  if (kstp_last /= this%kstp .or. kper_last /= this%kper) exit
69  this%nlay = this%nlay + 1
70  end do
71  rewind(this%inunit)
72  if (iout > 0) &
73  write (iout, '(a, i0, a)') 'Detected ', this%nlay, &
74  ' unique records in binary file.'
75  !
76  ! -- return
77  return

◆ read_record()

subroutine headfilereadermodule::read_record ( class(headfilereadertype this,
logical, intent(out)  success,
integer(i4b), intent(in), optional  iout_opt 
)
private

Definition at line 80 of file HeadFileReader.f90.

81 ! ******************************************************************************
82 ! read_record
83 ! ******************************************************************************
84 !
85 ! SPECIFICATIONS:
86 ! ------------------------------------------------------------------------------
87  ! -- modules
89  ! -- dummy
90  class(HeadFileReaderType) :: this
91  logical, intent(out) :: success
92  integer(I4B), intent(in), optional :: iout_opt
93  ! -- local
94  integer(I4B) :: iostat, iout
95  integer(I4B) :: ncol, nrow, ilay
96 ! ------------------------------------------------------------------------------
97  !
98  if (present(iout_opt)) then
99  iout = iout_opt
100  else
101  iout = 0
102  end if
103  !
104  this%kstp = 0
105  this%kper = 0
106  success = .true.
107  this%kstpnext = 0
108  this%kpernext = 0
109  read (this%inunit, iostat=iostat) this%kstp, this%kper, this%pertim, &
110  this%totim, this%text, ncol, nrow, ilay
111  if (iostat /= 0) then
112  success = .false.
113  if (iostat < 0) this%endoffile = .true.
114  return
115  end if
116  !
117  ! -- allocate head to proper size
118  if (.not. allocated(this%head)) then
119  allocate (this%head(ncol * nrow))
120  else
121  if (size(this%head) /= ncol * nrow) then
122  deallocate (this%head)
123  allocate (this%head(ncol * nrow))
124  end if
125  end if
126  !
127  ! -- read the head array
128  read (this%inunit) this%head
129  !
130  ! -- look ahead to next kstp and kper, then backup if read successfully
131  if (.not. this%endoffile) then
132  read (this%inunit, iostat=iostat) this%kstpnext, this%kpernext
133  if (iostat == 0) then
134  call fseek_stream(this%inunit, -2 * i4b, 1, iostat)
135  else if (iostat < 0) then
136  this%endoffile = .true.
137  end if
138  end if
139  !
140  ! -- return
141  return
subroutine, public fseek_stream(iu, offset, whence, status)
Move the file pointer.
Here is the call graph for this function: