diff --git a/autotest/TestTimeStepSelect.f90 b/autotest/TestTimeStepSelect.f90 index bf1952f84f4..aa9a62ea7e9 100644 --- a/autotest/TestTimeStepSelect.f90 +++ b/autotest/TestTimeStepSelect.f90 @@ -16,7 +16,8 @@ subroutine collect_timestepselect(testsuite) new_unittest("last", test_last), & new_unittest("all", test_all), & new_unittest("freq", test_freq), & - new_unittest("step", test_step) & + new_unittest("step", test_step), & + new_unittest("multiple", test_multiple) & ] end subroutine collect_timestepselect @@ -119,4 +120,31 @@ subroutine test_step(error) end subroutine test_step + subroutine test_multiple(error) + type(error_type), allocatable, intent(out) :: error + type(TimeStepSelectType) :: steps + character(len=LINELENGTH) :: line + + call steps%init() + + line = "FIRST" + call steps%read(line) + + line = "LAST" + call steps%read(line) + + line = "STEPS 2" + call steps%read(line) + + call check(error, steps%is_selected(1, .false.)) + if (allocated(error)) return + + call check(error, steps%is_selected(2, .false.)) + if (allocated(error)) return + + call check(error, steps%is_selected(3, .true.)) + if (allocated(error)) return + + end subroutine test_multiple + end module TestTimeStepSelect diff --git a/src/Model/ModelUtilities/TimeStepSelect.f90 b/src/Model/ModelUtilities/TimeStepSelect.f90 index 881648f5138..aa7ab0fc344 100644 --- a/src/Model/ModelUtilities/TimeStepSelect.f90 +++ b/src/Model/ModelUtilities/TimeStepSelect.f90 @@ -23,6 +23,16 @@ module TimeStepSelectModule !! LAST !! FREQUENCY 4 !! + !! The read() procedure may be invoked multiple times to select multiple + !! time steps. Note that a character string re-using a keyword which has + !! been used for a previous read() invocation will override the previous + !! setting using that keyword. To combine multiple settings, be sure the + !! keywords are different on each invocation, e.g.: + !! + !! FIRST + !! LAST + !! STEPS 2 + !! !! The is_selected() function indicates whether the given time step is !! active. This function accepts an optional argument, indicating that !! the time step is the last in the stress period. @@ -75,15 +85,19 @@ subroutine log(this, iout, verb) if (this%all) then write (iout, "(6x,a,a)") 'ALL TIME STEPS WILL BE ', verb - else if (this%first) then - write (iout, "(6x,a,a)") 'THE FIRST TIME STEP WILL BE ', verb - else if (this%last) then - write (iout, "(6x,a,a)") 'THE LAST TIME STEP WILL BE ', verb - else if (size(this%steps) > 0) then + end if + if (size(this%steps) > 0) then write (iout, fmt_steps) verb, this%steps - else if (this%freq > 0) then + end if + if (this%freq > 0) then write (iout, fmt_freq) verb, this%freq end if + if (this%first) then + write (iout, "(6x,a,a)") 'THE FIRST TIME STEP WILL BE ', verb + end if + if (this%last) then + write (iout, "(6x,a,a)") 'THE LAST TIME STEP WILL BE ', verb + end if end subroutine log !> @brief Read a line of input and prepare the selection object.