14 logical :: hasimeth1flowja = .false.
15 integer(I4B) :: inunit
16 integer(I4B) :: nbudterms
19 integer(I4B) :: kstpnext
20 integer(I4B) :: kpernext
22 character(len=16) :: budtxt
23 character(len=16),
dimension(:),
allocatable :: budtxtarray
28 integer(I4B),
dimension(:),
allocatable :: imetharray
32 character(len=16) :: srcmodelname
33 character(len=16) :: srcpackagename
36 integer(I4B),
dimension(:),
allocatable :: nauxarray
37 character(len=16),
dimension(:),
allocatable :: auxtxt
38 character(len=16),
dimension(:, :),
allocatable :: auxtxtarray
40 real(dp),
dimension(:),
allocatable :: flowja
41 integer(I4B),
dimension(:),
allocatable :: nodesrc
42 integer(I4B),
dimension(:),
allocatable :: nodedst
43 real(dp),
dimension(:),
allocatable :: flow
44 real(dp),
dimension(:, :),
allocatable :: auxvar
45 character(len=16) :: dstmodelname
46 character(len=16) :: dstpackagename
47 character(len=16),
dimension(:),
allocatable :: dstpackagenamearray
64 integer(I4B),
intent(in) :: iu
65 integer(I4B),
intent(in) :: iout
66 integer(I4B),
intent(out) :: ncrbud
68 integer(I4B) :: ibudterm
69 integer(I4B) :: kstp_last, kper_last
70 integer(I4B) :: maxaux
73 this%endoffile = .false.
81 'Reading budget file to determine number of terms per time step.'
85 call this%read_record(success)
86 if (.not. success)
exit
87 this%nbudterms = this%nbudterms + 1
88 if (this%naux > maxaux) maxaux = this%naux
89 if (this%kstp /= this%kstpnext .or. this%kper /= this%kpernext) &
94 allocate (this%budtxtarray(this%nbudterms))
95 allocate (this%imetharray(this%nbudterms))
96 allocate (this%dstpackagenamearray(this%nbudterms))
97 allocate (this%nauxarray(this%nbudterms))
98 allocate (this%auxtxtarray(maxaux, this%nbudterms))
99 this%auxtxtarray(:, :) =
''
103 do ibudterm = 1, this%nbudterms
104 call this%read_record(success, iout)
105 if (.not. success)
exit
106 this%budtxtarray(ibudterm) = this%budtxt
107 this%imetharray(ibudterm) = this%imeth
108 this%dstpackagenamearray(ibudterm) = this%dstpackagename
109 this%nauxarray(ibudterm) = this%naux
110 if (this%naux > 0)
then
111 this%auxtxtarray(1:this%naux, ibudterm) = this%auxtxt(:)
113 if (this%srcmodelname == this%dstmodelname)
then
114 if (
allocated(this%nodesrc)) ncrbud = max(ncrbud, maxval(this%nodesrc))
119 write (iout,
'(a, i0, a)')
'Detected ', this%nbudterms, &
120 ' unique flow terms in budget file.'
130 logical,
intent(out) :: success
131 integer(I4B),
intent(in),
optional :: iout_opt
133 integer(I4B) :: i, n, iostat, iout
134 character(len=LINELENGTH) :: errmsg
136 if (
present(iout_opt))
then
149 this%srcmodelname =
''
150 this%srcpackagename =
''
151 this%dstmodelname =
''
152 this%dstpackagename =
''
157 read (this%inunit, iostat=iostat) this%kstp, this%kper, this%budtxt, &
158 this%nval, this%idum1, this%idum2
159 if (iostat /= 0)
then
161 if (iostat < 0) this%endoffile = .true.
164 read (this%inunit) this%imeth, this%delt, this%pertim, this%totim
165 if (this%imeth == 1)
then
166 if (trim(adjustl(this%budtxt)) ==
'FLOW-JA-FACE')
then
167 if (
allocated(this%flowja))
deallocate (this%flowja)
168 allocate (this%flowja(this%nval))
169 read (this%inunit) this%flowja
170 this%hasimeth1flowja = .true.
172 this%nval = this%nval * this%idum1 * abs(this%idum2)
173 if (
allocated(this%flow))
deallocate (this%flow)
174 allocate (this%flow(this%nval))
175 if (
allocated(this%nodesrc))
deallocate (this%nodesrc)
176 allocate (this%nodesrc(this%nval))
177 read (this%inunit) this%flow
182 elseif (this%imeth == 6)
then
184 read (this%inunit) this%srcmodelname
185 read (this%inunit) this%srcpackagename
186 read (this%inunit) this%dstmodelname
187 read (this%inunit) this%dstpackagename
188 read (this%inunit) this%ndat
189 this%naux = this%ndat - 1
190 if (
allocated(this%auxtxt))
deallocate (this%auxtxt)
191 allocate (this%auxtxt(this%naux))
192 read (this%inunit) this%auxtxt
193 read (this%inunit) this%nlist
194 if (
allocated(this%nodesrc))
deallocate (this%nodesrc)
195 allocate (this%nodesrc(this%nlist))
196 if (
allocated(this%nodedst))
deallocate (this%nodedst)
197 allocate (this%nodedst(this%nlist))
198 if (
allocated(this%flow))
deallocate (this%flow)
199 allocate (this%flow(this%nlist))
200 if (
allocated(this%auxvar))
deallocate (this%auxvar)
201 allocate (this%auxvar(this%naux, this%nlist))
202 read (this%inunit) (this%nodesrc(n), this%nodedst(n), this%flow(n), &
203 (this%auxvar(i, n), i=1, this%naux), n=1, this%nlist)
205 write (errmsg,
'(a, a)')
'ERROR READING: ', trim(this%budtxt)
207 write (errmsg,
'(a, i0)')
'INVALID METHOD CODE DETECTED: ', this%imeth
212 write (iout,
'(1pg15.6, a, 1x, a)') this%totim, this%budtxt, &
217 if (.not. this%endoffile)
then
218 read (this%inunit, iostat=iostat) this%kstpnext, this%kpernext
219 if (iostat == 0)
then
221 else if (iostat < 0)
then
222 this%endoffile = .true.
232 if (
allocated(this%auxtxt))
deallocate (this%auxtxt)
233 if (
allocated(this%flowja))
deallocate (this%flowja)
234 if (
allocated(this%nodesrc))
deallocate (this%nodesrc)
235 if (
allocated(this%nodedst))
deallocate (this%nodedst)
236 if (
allocated(this%flow))
deallocate (this%flow)
237 if (
allocated(this%auxvar))
deallocate (this%auxvar)
subroutine read_record(this, success, iout_opt)
subroutine finalize(this)
subroutine initialize(this, iu, iout, ncrbud)
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
This module defines variable data types.
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
subroutine, public store_error_unit(iunit, terminate)
Store the file unit number.