Skip to content

Commit

Permalink
(utils_infile) do not return out-of-range integer if input is out-of-…
Browse files Browse the repository at this point in the history
…bounds
  • Loading branch information
danieljprice committed May 14, 2024
1 parent 7903c3e commit 7a2d983
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/main/utils_infiles.f90
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,17 @@ subroutine read_inopt_int(ival,tag,db,err,errcount,min,max)
if (ierr==0) then
if (present(min)) then
write(chmin,"(g10.0)") min
if (ival < min) ierr = ierr_rangemin
if (ival < min) then
ierr = ierr_rangemin
ival = min
endif
endif
if (present(max)) then
write(chmax,"(g10.0)") max
if (ival > max) ierr = ierr_rangemax
if (ival > max) then
ierr = ierr_rangemax
ival = max
endif
endif
endif

Expand Down Expand Up @@ -493,11 +499,17 @@ subroutine read_inopt_real(val,tag,db,err,errcount,min,max)
if (ierr==0) then
if (present(min)) then
write(chmin,"(g13.4)") min
if (val < min) ierr = ierr_rangemin
if (val < min) then
ierr = ierr_rangemin
val = min
endif
endif
if (present(max)) then
write(chmax,"(g13.4)") max
if (val > max) ierr = ierr_rangemax
if (val > max) then
ierr = ierr_rangemax
val = max
endif
endif
endif
if (present(err)) then
Expand Down

0 comments on commit 7a2d983

Please sign in to comment.