Skip to content

Commit

Permalink
feat(tdis): error check for invalid time step lengths
Browse files Browse the repository at this point in the history
Added a new error check for very small time steps.  If the value of startime plus the time step length is equal to endtime, then the time step is too small to be differentiated by the program based on the precision of floating point numbers.  The program will terminate with an error in this case.  The program will also terminate if the storage package and a transient stress period has a time step length of zero.   Closes #42.
  • Loading branch information
langevin-usgs committed Sep 27, 2018
1 parent ce48c17 commit 11f497c
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 40 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Automated Testing Status on Travis-CI

### Version 6.0.3 develop — build 22
### Version 6.0.3 develop — build 23
[![Build Status](https://travis-ci.org/MODFLOW-USGS/modflow6.svg?branch=develop)](https://travis-ci.org/MODFLOW-USGS/modflow6)

## Introduction
Expand All @@ -31,7 +31,7 @@ MODFLOW 6 is the latest core version of MODFLOW. It synthesizes many of the capa

#### ***Software/Code citation for MODFLOW 6:***

[Langevin, C.D., Hughes, J.D., Banta, E.R., Provost, A.M., Niswonger, R.G., and Panday, Sorab, 2018, MODFLOW 6 Modular Hydrologic Model version 6.0.3 — develop: U.S. Geological Survey Software Release, 25 September 2018, https://doi.org/10.5066/F76Q1VQV](https://doi.org/10.5066/F76Q1VQV)
[Langevin, C.D., Hughes, J.D., Banta, E.R., Provost, A.M., Niswonger, R.G., and Panday, Sorab, 2018, MODFLOW 6 Modular Hydrologic Model version 6.0.3 — develop: U.S. Geological Survey Software Release, 27 September 2018, https://doi.org/10.5066/F76Q1VQV](https://doi.org/10.5066/F76Q1VQV)


## Instructions for building definition files for new packages
Expand Down
18 changes: 9 additions & 9 deletions code.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
[
{
"status": "Release Candidate",
"languages": [
"Fortran2008"
],
"downloadURL": "https://code.usgs.gov/usgs/modflow/modflow6/archive/master.zip",
"repositoryURL": "https://code.usgs.gov/usgs/modflow/modflow6.git",
"laborHours": -1,
"disclaimerURL": "https://code.usgs.gov/usgs/modflow/modflow6/blob/master/DISCLAIMER.md",
"name": "modflow6",
"tags": [
"MODFLOW",
"groundwater model"
],
"description": "MODFLOW is the USGS's modular hydrologic model. MODFLOW is considered an international standard for simulating and predicting groundwater conditions and groundwater/surface-water interactions.",
"languages": [
"Fortran2008"
],
"contact": {
"name": "Christian D. Langevin",
"email": "langevin@usgs.gov"
},
"downloadURL": "https://code.usgs.gov/usgs/modflow/modflow6/archive/master.zip",
"vcs": "git",
"laborHours": -1,
"version": "6.0.3.22",
"version": "6.0.3.23",
"date": {
"metadataLastUpdated": "2018-09-25"
"metadataLastUpdated": "2018-09-27"
},
"organization": "U.S. Geological Survey",
"permissions": {
Expand All @@ -33,6 +33,6 @@
"usageType": "openSource"
},
"homepageURL": "https://code.usgs.gov/usgs/modflow/modflow6/",
"description": "MODFLOW is the USGS's modular hydrologic model. MODFLOW is considered an international standard for simulating and predicting groundwater conditions and groundwater/surface-water interactions."
"name": "modflow6"
}
]
2 changes: 1 addition & 1 deletion doc/ReleaseNotes/ReleaseNotes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ \section{History}
\begin{itemize}
\item Addressed issue with pointing contiguous pointer vectors/arrays to non-contiguous pointer vectors/arrays that caused code compilation failure with gfortran-8. A consequence of addressing this issue is that all pointer vectors/arrays that are allocated or pointed to using the memory manager must be defined to be contiguous.
\item Corrected a problem with the reading of grid data from a binary file, in which the program was reading a binary header for each row of data.
\item -
\item Added a new error check for very small time steps. If the value of startime plus the time step length is equal to endtime, then the time step is too small to be differentiated by the program based on the precision of floating point numbers. The program will terminate with an error in this case. The program will also terminate if the storage package and a transient stress period has a time step length of zero.
\end{itemize}

\underline{STRESS PACKAGES}
Expand Down
4 changes: 2 additions & 2 deletions doc/version.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\newcommand{\modflowversion}{mf6.0.3.22}
\newcommand{\modflowdate}{September 25, 2018}
\newcommand{\modflowversion}{mf6.0.3.23}
\newcommand{\modflowdate}{September 27, 2018}
\newcommand{\currentmodflowversion}{Version \modflowversion---\modflowdate}
15 changes: 15 additions & 0 deletions src/Model/GroundWaterFlow/gwf3sto8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ subroutine sto_fc(this, kiter, nodes, hold, hnew, nja, njasln, amat, &
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
! -- modules
use SimModule, only: ustop, store_error
use ConstantsModule, only: LINELENGTH
use TdisModule, only: delt
! -- dummy
class(GwfStoType) :: this
Expand All @@ -260,11 +263,23 @@ subroutine sto_fc(this, kiter, nodes, hold, hnew, nja, njasln, amat, &
real(DP) :: snold, snnew
real(DP) :: ss0, ss1, ssh0, ssh1
real(DP) :: rhsterm
character(len=LINELENGTH) :: errmsg
! -- formats
character(len=*), parameter :: fmtsperror = &
&"('DETECTED TIME STEP LENGTH OF ZERO. GWF STORAGE PACKAGE CANNOT BE ', &
&'USED UNLESS DELT IS NON-ZERO.')"
! ------------------------------------------------------------------------------
!
! -- test if steady-state stress period
if (this%iss /= 0) return
!
! -- Ensure time step length is not zero
if (delt == DZERO) then
write(errmsg, fmtsperror)
call store_error(errmsg)
call ustop()
endif
!
! -- set variables
tled = DONE / delt
!
Expand Down
119 changes: 97 additions & 22 deletions src/Timing/tdis.f90
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,6 @@ subroutine tdis_read_timing()
&' MULTIPLIER FOR DELT',/1X,76('-'))"
character(len=*), parameter :: fmtrow = &
"(1X,I8,1PG21.7,I7,0PF25.3)"
character(len=*), parameter :: fmtpwarn = &
"(1X,/1X, &
&'WARNING: PERLEN MUST NOT BE 0.0 FOR TRANSIENT STRESS PERIODS')"
!data
! ------------------------------------------------------------------------------
!
! -- get PERIODDATA block
Expand All @@ -554,26 +550,11 @@ subroutine tdis_read_timing()
nstp(n) = parser%GetInteger()
tsmult(n) = parser%GetDouble()
write (iout, fmtrow) n, perlen(n), nstp(n), tsmult(n)
!
!-----stop if nstp le 0, perlen eq 0 for transient stress periods,
!-----tsmult le 0, or perlen lt 0..
if(nstp(n) <= 0) then
call store_error( &
'THERE MUST BE AT LEAST ONE TIME STEP IN EVERY STRESS PERIOD')
end if
if(perlen(n) == dzero) then
write(iout, fmtpwarn)
end if
if(tsmult(n) <= dzero) then
call store_error( &
'TSMULT MUST BE GREATER THAN 0.0')
end if
if(perlen(n).lt.dzero) then
call store_error( &
'PERLEN CANNOT BE LESS THAN 0.0 FOR ANY STRESS PERIOD')
end if
totalsimtime = totalsimtime + perlen(n)
enddo
!
! -- Check timing information
call check_tdis_timing(nper, perlen, nstp, tsmult)
call parser%terminateblock()
!
! -- Check for errors
Expand All @@ -592,6 +573,100 @@ subroutine tdis_read_timing()
! -- Return
return
end subroutine tdis_read_timing

subroutine check_tdis_timing(nper, perlen, nstp, tsmult)
! ******************************************************************************
! check_tdis_timing -- Check the tdis timing information. Return back to
! tdis_read_timing if an error condition is found and let the ustop
! routine be called there instead so the StoreErrorUnit routine can be
! called to assign the correct file name.
! ******************************************************************************
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
! -- modules
use ConstantsModule, only: LINELENGTH, DZERO, DONE
use SimModule, only: ustop, store_error, count_errors
! -- dummy
integer(I4B), intent(in) :: nper
real(DP), dimension(:), contiguous, intent(in) :: perlen
integer(I4B), dimension(:), contiguous, intent(in) :: nstp
real(DP), dimension(:), contiguous, intent(in) :: tsmult
! -- local
integer(I4B) :: kper, kstp
real(DP) :: tstart, tend, dt
character(len=LINELENGTH) :: errmsg
! -- formats
character(len=*), parameter :: fmtpwarn = &
&"(1X,/1X,'PERLEN IS ZERO FOR STRESS PERIOD ', I0, &
&'. PERLEN MUST NOT BE ZERO FOR TRANSIENT PERIODS.')"
character(len=*), parameter :: fmtsperror = &
&"(A,' FOR STRESS PERIOD ', I0)"
character(len=*), parameter :: fmtdterror = &
&"('TIME STEP LENGTH OF ', G0, ' IS TOO SMALL IN PERIOD ', I0, &
&' AND TIME STEP ', I0)"
! ------------------------------------------------------------------------------
!
! -- Initialize
tstart = DZERO
!
! -- Go through and check each stress period
do kper = 1, nper
!
! -- Error if nstp less than or equal to zero
if(nstp(kper) <= 0) then
write(errmsg, fmtsperror) 'NUMBER OF TIME STEPS LESS THAN ONE ', kper
call store_error(errmsg)
return
end if
!
! -- Warn if perlen is zero
if(perlen(kper) == DZERO) then
write(iout, fmtpwarn) kper
return
end if
!
! -- Error if tsmult is less than zero
if(tsmult(kper) <= DZERO) then
write(errmsg, fmtsperror) 'TSMULT MUST BE GREATER THAN 0.0 ', kper
call store_error(errmsg)
return
end if
!
! -- Error if negative period length
if(perlen(kper) < DZERO) then
write(errmsg, fmtsperror) 'PERLEN CANNOT BE LESS THAN 0.0 ', kper
call store_error(errmsg)
return
end if
!
! -- Go through all time step lengths and make sure they are valid
do kstp = 1, nstp(kper)
if (kstp == 1) then
dt = perlen(kper) / float(nstp(kper))
if(tsmult(kper) /= DONE) &
dt = perlen(kper) * (DONE-tsmult(kper)) / &
(DONE - tsmult(kper) ** nstp(kper))
else
dt = dt * tsmult(kper)
endif
tend = tstart + dt
!
! -- Error condition if tstart == tend
if (tstart == tend) then
write(errmsg, fmtdterror) dt, kper, kstp
call store_error(errmsg)
return
endif
enddo
!
! -- reset tstart = tend
tstart = tend
!
enddo
! -- Return
return
end subroutine check_tdis_timing

subroutine subtiming_begin(isubtime, nsubtimes, idsolution)
! ******************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/version.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module VersionModule
public
! -- modflow 6 version
integer(I4B), parameter :: IDEVELOPMODE = 1
character(len=40), parameter :: VERSION = '6.0.3.22 09/25/2018'
character(len=40), parameter :: VERSION = '6.0.3.23 09/27/2018'
character(len=10), parameter :: MFVNAM = ' 6'
character(len=*), parameter :: MFTITLE = &
'U.S. GEOLOGICAL SURVEY MODULAR HYDROLOGIC MODEL'
Expand Down
6 changes: 3 additions & 3 deletions version.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# MODFLOW 6 version file automatically created using...pre-commit.py
# created on...September 25, 2018 17:06:18
# created on...September 27, 2018 16:51:25

# add some comments on how this version file
# should be manually updated and used

major = 6
minor = 0
micro = 3
build = 22
commit = 123
build = 23
commit = 124

0 comments on commit 11f497c

Please sign in to comment.