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, pos
80 select type (h => this%header)
88 inquire (unit=this%inunit, pos=h%pos)
89 read (this%inunit, iostat=iostat) h%kstp, h%kper, &
90 h%pertim, h%totim, h%text, h%ncol, h%nrow, h%ilay
93 if (iostat < 0) this%endoffile = .true.
96 inquire (unit=this%inunit, pos=pos)
97 this%header%size = pos - this%header%pos
108 logical,
intent(out) :: success
109 integer(I4B),
intent(in),
optional :: iout
111 integer(I4B) :: iout_opt
112 integer(I4B) :: ncol, nrow
114 if (
present(iout))
then
120 call this%read_header(success, iout_opt)
121 if (.not. success)
return
123 select type (h => this%header)
130 if (.not.
allocated(this%head))
then
131 allocate (this%head(ncol * nrow))
133 if (
size(this%head) /= ncol * nrow)
then
134 deallocate (this%head)
135 allocate (this%head(ncol * nrow))
140 read (this%inunit) this%head
142 call this%peek_record()
150 if (
allocated(this%head))
deallocate (this%head)
151 if (
allocated(this%header))
deallocate (this%header)
152 if (
allocated(this%headernext))
deallocate (this%headernext)
158 character(len=:),
allocatable :: str
159 character(len=LENBIGLINE) :: temp
161 write (temp,
'(*(G0))') &
162 'Head file header (pos: ', this%pos, &
163 ', kper: ', this%kper, &
164 ', kstp: ', this%kstp, &
165 ', pertim: ', this%pertim, &
166 ', totim: ', this%totim, &
167 ', text: ', trim(this%text), &
168 ', ncol: ', this%ncol, &
169 ', nrow: ', this%nrow, &
170 ', ilay: ', this%ilay, &
179 this%endoffile = .false.
180 if (
allocated(this%header))
deallocate (this%header)
181 if (
allocated(this%headernext))
deallocate (this%headernext)
185 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.