-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(oc): introduce module/type for time step selection (#1923)
In the spirit of TimeSelect, factor out a module and type TimeStepSelect for time step selections. This simplifies PrintSaveManager which can compose two of the latter. Add unit tests. Cleanup docstrings, comments, and style in base and concrete OC types. This can also be used by PRT, to come in a separate PR which cleans up particle release logic.
- Loading branch information
Showing
20 changed files
with
663 additions
and
683 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
module TestTimeStepSelect | ||
use testdrive, only: error_type, unittest_type, new_unittest, check | ||
use TimeStepSelectModule, only: TimeStepSelectType | ||
use ConstantsModule, only: LINELENGTH | ||
|
||
implicit none | ||
private | ||
public :: collect_timestepselect | ||
|
||
contains | ||
|
||
subroutine collect_timestepselect(testsuite) | ||
type(unittest_type), allocatable, intent(out) :: testsuite(:) | ||
testsuite = [ & | ||
new_unittest("first", test_first), & | ||
new_unittest("last", test_last), & | ||
new_unittest("all", test_all), & | ||
new_unittest("freq", test_freq), & | ||
new_unittest("step", test_step) & | ||
] | ||
end subroutine collect_timestepselect | ||
|
||
subroutine test_first(error) | ||
type(error_type), allocatable, intent(out) :: error | ||
type(TimeStepSelectType) :: steps | ||
character(len=LINELENGTH) :: line | ||
|
||
line = "FIRST" | ||
|
||
call steps%init() | ||
call steps%read(line) | ||
|
||
call check(error, steps%is_selected(1, .false.)) | ||
if (allocated(error)) return | ||
|
||
call check(error, steps%is_selected(1, .true.)) | ||
if (allocated(error)) return | ||
|
||
call check(error,.not. steps%is_selected(2, .false.)) | ||
if (allocated(error)) return | ||
|
||
end subroutine test_first | ||
|
||
subroutine test_last(error) | ||
type(error_type), allocatable, intent(out) :: error | ||
type(TimeStepSelectType) :: steps | ||
character(len=LINELENGTH) :: line | ||
|
||
line = "LAST" | ||
|
||
call steps%init() | ||
call steps%read(line) | ||
|
||
call check(error,.not. steps%is_selected(1, .false.)) | ||
if (allocated(error)) return | ||
|
||
call check(error, steps%is_selected(1, .true.)) | ||
if (allocated(error)) return | ||
|
||
end subroutine test_last | ||
|
||
subroutine test_all(error) | ||
type(error_type), allocatable, intent(out) :: error | ||
type(TimeStepSelectType) :: steps | ||
character(len=LINELENGTH) :: line | ||
|
||
line = "ALL" | ||
|
||
call steps%init() | ||
call steps%read(line) | ||
|
||
call check(error, steps%is_selected(1, .true.)) | ||
if (allocated(error)) return | ||
|
||
call check(error, steps%is_selected(1, .false.)) | ||
if (allocated(error)) return | ||
|
||
end subroutine test_all | ||
|
||
subroutine test_freq(error) | ||
type(error_type), allocatable, intent(out) :: error | ||
type(TimeStepSelectType) :: steps | ||
character(len=LINELENGTH) :: line | ||
|
||
line = "FREQUENCY 2" | ||
|
||
call steps%init() | ||
call steps%read(line) | ||
|
||
call check(error,.not. steps%is_selected(1, .false.)) | ||
if (allocated(error)) return | ||
|
||
call check(error, steps%is_selected(2, .false.)) | ||
if (allocated(error)) return | ||
|
||
call check(error,.not. steps%is_selected(3, .false.)) | ||
if (allocated(error)) return | ||
|
||
call check(error, steps%is_selected(4, .false.)) | ||
if (allocated(error)) return | ||
|
||
end subroutine test_freq | ||
|
||
subroutine test_step(error) | ||
type(error_type), allocatable, intent(out) :: error | ||
type(TimeStepSelectType) :: steps | ||
character(len=LINELENGTH) :: line | ||
|
||
line = "STEPS 1" | ||
|
||
call steps%init() | ||
call steps%read(line) | ||
|
||
call check(error, steps%is_selected(1, .false.)) | ||
if (allocated(error)) return | ||
|
||
call check(error,.not. steps%is_selected(2, .false.)) | ||
if (allocated(error)) return | ||
|
||
end subroutine test_step | ||
|
||
end module TestTimeStepSelect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.