13 character(len=16) :: text
14 integer(I4B) :: ncol, nrow, ilay
21 real(dp),
dimension(:),
allocatable :: head
37 integer(I4B),
intent(in) :: iu
38 integer(I4B),
intent(in) :: iout
40 integer(I4B) :: kstp_last, kper_last
48 call this%read_record(success)
49 kstp_last = this%header%kstp
50 kper_last = this%header%kper
56 'Reading binary file to determine number of records per time step.'
58 call this%read_record(success, iout)
59 if (.not. success)
exit
60 if (kstp_last /= this%header%kstp .or. kper_last /= this%header%kper)
exit
61 this%nlay = this%nlay + 1
65 write (iout,
'(a, i0, a)')
'Detected ', this%nlay, &
66 ' unique records in binary file.'
74 logical,
intent(out) :: success
75 integer(I4B),
intent(in),
optional :: iout
77 integer(I4B) :: iostat
81 select type (h => this%header)
89 inquire (unit=this%inunit, pos=h%pos)
90 read (this%inunit, iostat=iostat) h%kstp, h%kper, &
91 h%pertim, h%totim, h%text, h%ncol, h%nrow, h%ilay
94 if (iostat < 0) this%endoffile = .true.
97 inquire (unit=this%inunit, pos=pos)
98 this%header%size = pos - this%header%pos
109 logical,
intent(out) :: success
110 integer(I4B),
intent(in),
optional :: iout
112 integer(I4B) :: iout_opt
113 integer(I4B) :: ncol, nrow
115 if (
present(iout))
then
121 call this%read_header(success, iout_opt)
122 if (.not. success)
return
124 select type (h => this%header)
131 if (.not.
allocated(this%head))
then
132 allocate (this%head(ncol * nrow))
134 if (
size(this%head) /= ncol * nrow)
then
135 deallocate (this%head)
136 allocate (this%head(ncol * nrow))
141 read (this%inunit) this%head
143 call this%peek_record()
151 if (
allocated(this%head))
deallocate (this%head)
152 if (
allocated(this%header))
deallocate (this%header)
153 if (
allocated(this%headernext))
deallocate (this%headernext)
159 character(len=:),
allocatable :: str
160 character(len=LENBIGLINE) :: temp
162 write (temp,
'(*(G0))') &
163 'Head file header (pos: ', this%pos, &
164 ', kper: ', this%kper, &
165 ', kstp: ', this%kstp, &
166 ', pertim: ', this%pertim, &
167 ', totim: ', this%totim, &
168 ', text: ', trim(this%text), &
169 ', ncol: ', this%ncol, &
170 ', nrow: ', this%nrow, &
171 ', ilay: ', this%ilay, &
180 this%endoffile = .false.
181 if (
allocated(this%header))
deallocate (this%header)
182 if (
allocated(this%headernext))
deallocate (this%headernext)
186 this%headernext%pos = 1
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lenhugeline
maximum length of a huge line
integer(i4b), parameter lenbigline
maximum length of a big line
subroutine finalize(this)
subroutine read_record(this, success, iout)
subroutine initialize(this, iu, iout)
subroutine read_header(this, success, iout)
character(len=:) function, allocatable get_str(this)
Get a string representation of the head file header.
This module defines variable data types.