10 integer(I4B) :: pos, size
11 integer(I4B) :: kper, kstp
12 real(dp) :: pertim, totim
18 integer(I4B) :: inunit
19 integer(I4B) :: nrecords
20 logical(LGP) :: indexed
21 logical(LGP) :: endoffile
22 integer(I4B),
allocatable :: record_sizes(:)
38 logical(LGP),
intent(out) :: success
39 integer(I4B),
intent(in),
optional :: iout
46 logical(LGP),
intent(out) :: success
47 integer(I4B),
intent(in),
optional :: iout
55 character(len=:),
allocatable :: str
57 write (str,
'(*(G0))') &
58 'Binary file header (pos: ', this%pos, &
59 ', kper: ', this%kper, &
60 ', kstp: ', this%kstp, &
61 ', pertim: ', this%pertim, &
62 ', totim: ', this%totim, &
71 logical(LGP) :: success
72 integer(I4B) :: pos, record_size
74 this%indexed = .false.
77 if (
allocated(this%record_sizes))
deallocate (this%record_sizes)
81 call this%read_record(success)
82 if (.not. success)
exit
83 this%nrecords = this%nrecords + 1
86 allocate (this%record_sizes(this%nrecords))
89 call this%read_record(success)
90 inquire (this%inunit, pos=pos)
91 record_size = pos - this%header%pos
92 if (.not. success)
exit
93 this%record_sizes(this%nrecords) = this%header%size + record_size
104 integer(I4B) :: iostat
106 if (.not. this%endoffile)
then
107 inquire (this%inunit, pos=this%headernext%pos)
108 read (this%inunit, iostat=iostat) this%headernext%kstp, this%headernext%kper
109 if (iostat == 0)
then
111 else if (iostat < 0)
then
112 this%endoffile = .true.
113 if (
allocated(this%headernext))
deallocate (this%headernext)
123 if (
allocated(this%header))
deallocate (this%header)
124 if (
allocated(this%headernext))
deallocate (this%headernext)
128 this%headernext%pos = 1
129 this%endoffile = .false.
character(len=:) function, allocatable get_str(this)
Get a string representation of the header.
subroutine rewind(this)
Rewind the file to the beginning.
subroutine build_index(this)
Build an index of data sizes in the file.
subroutine peek_record(this)
Peek to see if another record is available.
subroutine pstop(status, message)
Stop the program, optionally specifying an error status code.
This module defines variable data types.