24 integer(I4B),
pointer ::
nper => null()
25 integer(I4B),
pointer ::
maxats => null()
26 real(dp),
public,
pointer ::
dtstable => null()
27 integer(I4B),
dimension(:),
pointer,
contiguous ::
kperats => null()
28 integer(I4B),
dimension(:),
pointer,
contiguous ::
iperats => null()
29 real(dp),
dimension(:),
pointer,
contiguous ::
dt0 => null()
30 real(dp),
dimension(:),
pointer,
contiguous ::
dtmin => null()
31 real(dp),
dimension(:),
pointer,
contiguous ::
dtmax => null()
32 real(dp),
dimension(:),
pointer,
contiguous ::
dtadj => null()
33 real(dp),
dimension(:),
pointer,
contiguous ::
dtfailadj => null()
45 integer(I4B),
intent(in) :: kper
64 integer(I4B),
intent(in) :: inunit
65 integer(I4B),
intent(in) :: nper_tdis
68 character(len=*),
parameter :: fmtheader = &
69 "(1X,/1X,'ATS -- ADAPTIVE TIME STEP PACKAGE,', / &
70 &' VERSION 1 : 03/18/2021 - INPUT READ FROM UNIT ',I0)"
76 write (
iout, fmtheader) inunit
205 character(len=LINELENGTH) :: keyword
207 logical :: isfound, endOfBlock
211 call parser%GetBlock(
'OPTIONS', isfound, ierr, &
212 supportopenclose=.true., blockrequired=.false.)
216 write (
iout,
'(1x,a)')
'PROCESSING ATS OPTIONS'
218 call parser%GetNextLine(endofblock)
220 call parser%GetStringCaps(keyword)
221 select case (keyword)
223 write (
errmsg,
'(a,a)')
'Unknown ATS option: ', &
226 call parser%StoreErrorUnit()
229 write (
iout,
'(1x,a)')
'END OF ATS OPTIONS'
244 character(len=LINELENGTH) :: keyword
246 logical :: isfound, endOfBlock
248 character(len=*),
parameter :: fmtmaxats = &
249 &
"(1X,I0,' ADAPTIVE TIME STEP RECORDS(S) WILL FOLLOW IN PERIODDATA')"
252 call parser%GetBlock(
'DIMENSIONS', isfound, ierr, &
253 supportopenclose=.true.)
257 write (
iout,
'(1x,a)')
'PROCESSING ATS DIMENSIONS'
259 call parser%GetNextLine(endofblock)
261 call parser%GetStringCaps(keyword)
262 select case (keyword)
267 write (
errmsg,
'(a,a)')
'Unknown ATS dimension: ', &
270 call parser%StoreErrorUnit()
273 write (
iout,
'(1x,a)')
'END OF ATS DIMENSIONS'
275 write (
errmsg,
'(a)')
'Required DIMENSIONS block not found.'
277 call parser%StoreErrorUnit()
295 logical :: isfound, endOfBlock
299 call parser%GetBlock(
'PERIODDATA', isfound, ierr, &
300 supportopenclose=.true.)
304 write (
iout,
'(1x,a)')
'READING ATS PERIODDATA'
306 call parser%GetNextLine(endofblock)
319 call parser%terminateblock()
323 call parser%StoreErrorUnit()
325 write (
iout,
'(1x,a)')
'END READING ATS PERIODDATA'
327 write (
errmsg,
'(a)')
'Required PERIODDATA block not found.'
329 call parser%StoreErrorUnit()
342 integer(I4B) :: kkper
348 if (kkper > 0 .and. kkper <=
nper)
then
362 character(len=LINELENGTH) :: tag
363 type(
tabletype),
pointer :: inputtab => null()
366 call table_cr(inputtab,
'ATS',
'ATS PERIOD DATA')
371 call inputtab%initialize_column(tag, 10, alignment=
tableft)
373 call inputtab%initialize_column(tag, 10, alignment=
tableft)
375 call inputtab%initialize_column(tag, 10, alignment=
tabcenter)
377 call inputtab%initialize_column(tag, 10, alignment=
tabcenter)
379 call inputtab%initialize_column(tag, 10, alignment=
tabcenter)
381 call inputtab%initialize_column(tag, 10, alignment=
tabcenter)
383 call inputtab%initialize_column(tag, 10, alignment=
tabcenter)
387 call inputtab%add_term(n)
388 call inputtab%add_term(
iperats(n))
389 call inputtab%add_term(
dt0(n))
390 call inputtab%add_term(
dtmin(n))
391 call inputtab%add_term(
dtmax(n))
392 call inputtab%add_term(
dtadj(n))
397 call inputtab%table_da()
398 deallocate (inputtab)
411 write (
iout,
'(1x,a)')
'PROCESSING ATS INPUT'
416 write (
errmsg,
'(a, i0, a, i0)') &
417 'IPERATS must be greater than zero. Found ',
iperats(n), &
418 ' for ATS PERIODDATA record ', n
422 write (
warnmsg,
'(a, i0, a, i0)') &
423 'IPERATS greater than NPER. Found ',
iperats(n), &
424 ' for ATS PERIODDATA record ', n
430 write (
errmsg,
'(a, g15.7, a, i0)') &
431 'DT0 must be >= zero. Found ',
dt0(n), &
432 ' for ATS PERIODDATA record ', n
438 write (
errmsg,
'(a, g15.7, a, i0)') &
439 'DTMIN must be > zero. Found ',
dtmin(n), &
440 ' for ATS PERIODDATA record ', n
446 write (
errmsg,
'(a, g15.7, a, i0)') &
447 'DTMAX must be > zero. Found ',
dtmax(n), &
448 ' for ATS PERIODDATA record ', n
454 write (
errmsg,
'(a, 2g15.7, a, i0)') &
455 'DTMIN must be < dtmax. Found ',
dtmin(n),
dtmax(n), &
456 ' for ATS PERIODDATA record ', n
462 write (
errmsg,
'(a, g15.7, a, i0)') &
463 'DTADJ must be 0 or >= 1.0. Found ',
dtadj(n), &
464 ' for ATS PERIODDATA record ', n
470 write (
errmsg,
'(a, g15.7, a, i0)') &
471 'DTFAILADJ must be 0 or >= 1.0. Found ',
dtfailadj(n), &
472 ' for ATS PERIODDATA record ', n
480 call parser%StoreErrorUnit()
482 write (
iout,
'(1x,a)')
'DONE PROCESSING ATS INPUT'
493 integer(I4B),
intent(in) :: kper
496 character(len=*),
parameter :: fmtspts = &
497 "(28X,'ATS IS OVERRIDING TIME STEPPING FOR THIS PERIOD',/ &
498 &28X,'INITIAL TIME STEP SIZE (DT0) = ',G15.7,/ &
499 &28X,'MINIMUM TIME STEP SIZE (DTMIN) = ',G15.7,/ &
500 &28X,'MAXIMUM TIME STEP SIZE (DTMAX) = ',G15.7,/ &
501 &28X,'MULTIPLIER/DIVIDER FOR TIME STEP (DTADJ) = ',G15.7,/ &
502 &28X,'DIVIDER FOR FAILED TIME STEP (DTFAILADJ) = ',G15.7,/ &
517 integer(I4B),
intent(in) :: kstp
518 integer(I4B),
intent(in) :: kper
519 real(dp),
intent(in) :: dt
520 character(len=*),
intent(in) :: sloc
521 integer(I4B),
intent(in),
optional :: idir
526 character(len=*),
parameter :: fmtdtsubmit = &
527 &
"(1x, 'ATS: ', A,' submitted a preferred time step size of ', G15.7)"
532 if (tsfact >
done)
then
537 if (
present(idir))
then
540 dt_temp = dt / tsfact
541 else if (idir == 1)
then
542 dt_temp = dt * tsfact
547 if (kstp > 1 .and. dt_temp >
dzero)
then
548 write (
iout, fmtdtsubmit) trim(adjustl(sloc)), dt_temp
568 integer(I4B),
intent(in) :: kstp
569 integer(I4B),
intent(in) :: kper
570 real(dp),
intent(inout) :: pertim
571 real(dp),
intent(in) :: perlencurrent
572 real(dp),
intent(inout) :: delt
577 character(len=*),
parameter :: fmtdt = &
578 "(1x, 'ATS: time step set to ', G15.7, ' for step ', i0, &
579 &' and period ', i0)"
608 if (delt <
dtmin(n))
then
611 if (delt >
dtmax(n))
then
616 if (tstart + delt > perlencurrent -
dtmin(n))
then
617 delt = perlencurrent - tstart
621 write (
iout, fmtdt) delt, kstp, kper
635 integer(I4B),
intent(in) :: kstp
636 integer(I4B),
intent(in) :: kper
637 integer(I4B),
intent(in) :: laststepfailed
638 real(dp),
intent(inout) :: delt
639 logical,
intent(inout) :: finishedtrying
642 real(dp) :: delt_temp
645 character(len=*),
parameter :: fmttsi = &
646 "(1X, 'Failed solution for step ', i0, ' and period ', i0, &
647 &' will be retried using time step of ', G15.7)"
649 if (laststepfailed /= 0)
then
653 if (tsfact >
done)
then
654 delt_temp = delt / tsfact
655 if (delt_temp >=
dtmin(n))
then
656 finishedtrying = .false.
658 write (
iout, fmttsi) kstp, kper, delt
674 integer(I4B),
intent(in) :: kper
675 real(dp),
intent(inout) :: pertim
676 real(dp),
intent(in) :: perlencurrent
677 logical(LGP),
intent(inout) :: endofperiod
683 if (abs(pertim - perlencurrent) <
dtmin(n))
then
subroutine ats_read_timing()
@ brief Read timing
subroutine, public ats_set_delt(kstp, kper, pertim, perlencurrent, delt)
@ brief Set time step
subroutine ats_allocate_arrays()
@ brief Allocate arrays
subroutine, public ats_cr(inunit, nper_tdis)
@ brief Create ATS object
subroutine, public ats_set_endofperiod(kper, pertim, perlencurrent, endofperiod)
@ brief Set end of period indicator
real(dp), dimension(:), pointer, contiguous dtfailadj
input array of time step factors for shortening due to nonconvergence
real(dp), dimension(:), pointer, contiguous dtmin
input array of minimum time step sizes
subroutine ats_input_table()
@ brief Write input table
real(dp), dimension(:), pointer, contiguous dtmax
input array of maximum time step sizes
subroutine ats_check_timing()
@ brief Check timing
integer(i4b), pointer nper
set equal to nper
logical(lgp) function, public isadaptiveperiod(kper)
@ brief Determine if period is adaptive
real(dp), pointer, public dtstable
delt value required for stability
integer(i4b), dimension(:), pointer, contiguous kperats
array of stress period numbers to apply ats (size NPER)
integer(i4b), pointer maxats
number of ats entries
subroutine, public ats_da()
@ brief Deallocate variables
subroutine, public ats_reset_delt(kstp, kper, lastStepFailed, delt, finishedTrying)
@ brief Reset time step because failure has occurred
subroutine ats_read_dimensions()
@ brief Read dimensions
subroutine ats_process_input()
@ brief Process input
subroutine, public ats_submit_delt(kstp, kper, dt, sloc, idir)
@ brief Allow and external caller to submit preferred time step
real(dp), dimension(:), pointer, contiguous dt0
input array of initial time step sizes
subroutine ats_allocate_scalars()
@ brief Allocate scalars
subroutine, public ats_period_message(kper)
@ brief Write period message
real(dp), dimension(:), pointer, contiguous dtadj
input array of time step factors for shortening or increasing
subroutine ats_read_options()
@ brief Read options
integer(i4b), dimension(:), pointer, contiguous iperats
array of stress period numbers to apply ats (size MAXATS)
type(blockparsertype) parser
block parser for reading input file
This module contains block parser methods.
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
@ tabcenter
centered table column
@ tableft
left justified table column
real(dp), parameter dnodata
real no data constant
real(dp), parameter dzero
real constant zero
real(dp), parameter done
real constant 1
This module defines variable data types.
This module contains simulation methods.
subroutine, public store_warning(msg, substring)
Store warning message.
subroutine, public store_error(msg, terminate)
Store an error message.
integer(i4b) function, public count_errors()
Return number of errors.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=maxcharlen) warnmsg
warning message string
integer(i4b) iout
file unit number for simulation output
subroutine, public table_cr(this, name, title)