Skip to content

Commit

Permalink
fix(getblock): add error message if block not found (#1065)
Browse files Browse the repository at this point in the history
* uget_block did not terminate with an error when looking for a required block and found end of file instead
* update release notes
* Close #148
  • Loading branch information
langevin-usgs authored Oct 12, 2022
1 parent b2cb908 commit 5e142a4
Show file tree
Hide file tree
Showing 18 changed files with 47 additions and 18 deletions.
1 change: 1 addition & 0 deletions doc/ReleaseNotes/ReleaseNotes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ \section{Changes Introduced in this Release}
\item Terminate with error if METHOD or METHODS not specified in time series input files. Prior to this change, the program would continue without an interpolated value for one or more time series records.
\item When a GWF Model and a corresponding GWT model are solved in the same simulation, the GWF Model must be solved before the corresponding GWT model. The GWF Model must also be solved by a different IMS than the GWT Model. There was not a check for this in previous versions and if these conditions were not met, the solution would often not converge or it would give erroneous results.
\item The DISV Package would not raise an error if a model cell was defined as a line. The program was modified to check for the case where the calculated cell area is equal to zero. If the calculated cell area is equal to zero, the program terminates with an error.
\item When searching for a required block in an input file, the program would not terminate with a sensible error message if the end of file was found instead of the required block. Program now indicates that the required block was not found.
\end{itemize}

\underline{INTERNAL FLOW PACKAGES}
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterFlow/gwf3csub8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2532,7 +2532,8 @@ subroutine csub_rp(this)
!
! -- get period block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterFlow/gwf3evt8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ subroutine evt_rp(this)
! When reading a list, OPEN/CLOSE is handled by list reader,
! so supportOpenClose needs to be false in call the GetBlock.
! When reading as arrays, set supportOpenClose as desired.
call this%parser%GetBlock('PERIOD', isfound, ierr)
call this%parser%GetBlock('PERIOD', isfound, ierr, &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterFlow/gwf3hfb8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ subroutine hfb_rp(this)
!
! -- get period block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterFlow/gwf3lak8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3590,7 +3590,8 @@ subroutine lak_rp(this)
!
! -- get period block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterFlow/gwf3maw8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,8 @@ subroutine maw_rp(this)
!
! -- get period block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterFlow/gwf3mvr8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ subroutine mvr_rp(this)
!
! -- get period block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterFlow/gwf3rch8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ subroutine rch_rp(this)
! When reading a list, OPEN/CLOSE is handled by list reader,
! so supportOpenClose needs to be false in call the GetBlock.
! When reading as arrays, set supportOpenClose as desired.
call this%parser%GetBlock('PERIOD', isfound, ierr)
call this%parser%GetBlock('PERIOD', isfound, ierr, &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterFlow/gwf3sfr8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,8 @@ subroutine sfr_rp(this)
!
! -- get period block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterFlow/gwf3sto8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ subroutine sto_rp(this)
!
! -- get period block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterFlow/gwf3tvbase8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ subroutine rp(this)
!
! -- Get PERIOD block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
if (isfound) then
!
! -- Read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterFlow/gwf3uzf8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,8 @@ subroutine uzf_rp(this)
!
! -- get period block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterTransport/gwt1apt1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ subroutine apt_rp(this)
!
! -- get period block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/ModelUtilities/BoundaryPackage.f90
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ subroutine bnd_rp(this)
!
! -- get period block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
3 changes: 2 additions & 1 deletion src/Model/ModelUtilities/GwtSpc.f90
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ subroutine spc_rp(this)
!
! -- get period block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
if (isfound) then
!
! -- read ionper and check for increasing period numbers
Expand Down
8 changes: 6 additions & 2 deletions src/SimulationCreate.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module SimulationCreateModule

use KindModule, only: DP, I4B, write_kindinfo
use KindModule, only: DP, I4B, LGP, write_kindinfo
use ConstantsModule, only: LINELENGTH, LENMODELNAME, LENBIGLINE, DZERO
use SimVariablesModule, only: simfile, simlstfile, iout
use GenericUtilitiesModule, only: sim_message, write_centered
Expand Down Expand Up @@ -403,6 +403,7 @@ subroutine solution_groups_create()
integer(I4B) :: isgpsoln
integer(I4B) :: sgid
integer(I4B) :: mid
logical(LGP) :: blockRequired
character(len=LINELENGTH) :: errmsg
character(len=LENBIGLINE) :: keyword
character(len=LINELENGTH) :: fname, mname
Expand All @@ -421,8 +422,11 @@ subroutine solution_groups_create()
!Read through the simulation name file and process each SOLUTION_GROUP
sgploop: do
!
blockRequired = .false.
if (isgp == 0) blockRequired = .true.
call parser%GetBlock('SOLUTIONGROUP', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=blockRequired)
if (ierr /= 0) exit sgploop
if (.not. isfound) exit sgploop
isgp = isgp + 1
Expand Down
11 changes: 10 additions & 1 deletion src/Utilities/InputOutput.f90
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,16 @@ subroutine uget_block(iin, iout, ctag, ierr, isfound, lloc, line, iuext, &
mainloop: do
lloc = 1
call u9rdcom(iin, iout, line, ierr)
if (ierr < 0) exit
if (ierr < 0) then
if (blockRequiredLocal) then
ermsg = 'Required block "' // trim(ctag) // &
'" not found. Found end of file instead.'
call store_error(ermsg)
call store_error_unit(iuext)
end if
! block not found so exit
exit
end if
call urword(line, lloc, istart, istop, 1, ival, rval, iin, iout)
if (line(istart:istop) == 'BEGIN') then
call urword(line, lloc, istart, istop, 1, ival, rval, iin, iout)
Expand Down
3 changes: 2 additions & 1 deletion src/Utilities/OutputControl/OutputControl.f90
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ subroutine oc_rp(this)
!
! -- Get period block
call this%parser%GetBlock('PERIOD', isfound, ierr, &
supportOpenClose=.true.)
supportOpenClose=.true., &
blockRequired=.false.)
!
! -- If end of file, set iperoc past kper, else parse line
if (ierr < 0) then
Expand Down

0 comments on commit 5e142a4

Please sign in to comment.