Skip to content

Commit

Permalink
fix(oc): fix TimeStepSelect logging
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Jul 8, 2024
1 parent 61f1e31 commit 63f190b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
30 changes: 29 additions & 1 deletion autotest/TestTimeStepSelect.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
26 changes: 20 additions & 6 deletions src/Model/ModelUtilities/TimeStepSelect.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 63f190b

Please sign in to comment.