Skip to content

Commit 0dc7e95

Browse files
authored
fix: improve error message when dis package missing (MODFLOW-ORG#2813)
Stop with an informative error if grid discretization is missing after loading the model input file's packages block.
1 parent a6a4984 commit 0dc7e95

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

doc/ReleaseNotes/develop.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,8 @@ description = "Avoids an unhandled and unnecessary exception in cases where a GW
6363
section = "fixes"
6464
subsection = "netcdf"
6565
description = "Fix an indexing issue in structured NetCDF export where READASARRAYS packages (RCHA, EVTA) with time-varying per-period arrays would crash with a NetCDF edge-exceeds-bound error when writing any stress period after the first."
66+
67+
[[items]]
68+
section = "fixes"
69+
subsection = "basic"
70+
description = "Stop with an informative error if a discretization package is missing after loading the model input file's PACKAGES block."

src/Utilities/Idm/ModelPackageInputs.f90

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,21 @@ subroutine modelpkgs_create(this, ftypes)
277277
integer(I4B), dimension(:), allocatable :: cunit_idxs, indx
278278
character(len=LENPACKAGETYPE) :: ftype
279279
integer(I4B) :: n, m
280-
logical(LGP) :: found
280+
logical(LGP) :: found, has_dis
281281

282282
! allocate
283283
allocate (cunit_idxs(0))
284+
has_dis = .false.
284285

285286
! identify input packages and check that each is supported
286287
do n = 1, size(ftypes)
287288
! type from model nam file packages block
288289
ftype = ftypes(n)
289290
found = .false.
290291

292+
! check for discretization package (any type starting with 'DIS')
293+
if (ftype(1:3) == 'DIS') has_dis = .true.
294+
291295
! search supported types for this filetype
292296
do m = 1, this%niunit
293297
if (this%cunit(m) == ftype) then
@@ -317,6 +321,15 @@ subroutine modelpkgs_create(this, ftypes)
317321
end if
318322
end do
319323

324+
! check that a discretization package is specified
325+
if (.not. has_dis) then
326+
write (errmsg, '(3a)') &
327+
'Discretization package not specified for model "', &
328+
trim(this%modelname), '".'
329+
call store_error(errmsg)
330+
call store_error_filename(this%modelfname)
331+
end if
332+
320333
! allocate the pkglist
321334
allocate (this%pkglist(size(cunit_idxs)))
322335

0 commit comments

Comments
 (0)