MONC
Functions/Subroutines | Variables
test_terminationcheck_mod Module Reference

Functions/Subroutines

subroutine test_timestep_callback ()
 
subroutine test_consolidation_callback ()
 
subroutine test_modeldump_callback ()
 
subroutine init_random_seed ()
 

Variables

integer, parameter max_tests = 1000
 

Function/Subroutine Documentation

◆ init_random_seed()

subroutine test_terminationcheck_mod::init_random_seed

Definition at line 91 of file test_terminationcheck.F90.

92  integer :: i, n, clock
93  integer, dimension(:), allocatable :: seed
94 
95  call random_seed(size = n)
96  allocate(seed(n))
97 
98  call system_clock(count=clock)
99 
100  seed = clock + 37 * (/ (i - 1, i = 1, n) /)
101  call random_seed(put=seed)
102 
103  deallocate(seed)
Here is the caller graph for this function:

◆ test_consolidation_callback()

subroutine test_terminationcheck_mod::test_consolidation_callback

Definition at line 36 of file test_terminationcheck.F90.

37  integer :: i, nn_timesteps, nn_consolidation, multiplier
38  type(model_state_type) :: current_state
39  real :: r
40 
41  call init_random_seed
42 
43  do i=1,max_tests
44  call random_number(r)
45  nn_timesteps= int(r*9)+1
46  call random_number(r)
47  multiplier = int(r*199)+1
48  call random_number(r)
49  nn_consolidation = int(r*9)+1
50 
51  current_state%timestep = nn_timesteps * multiplier ! timestep already terminated hence multiplication
52  current_state%continue_consolidation=.true.
53  call options_add(current_state%options_database, "nn_timesteps", nn_timesteps)
54  call options_add(current_state%options_database, "nn_consolidation", nn_consolidation)
55  call consolidation_callback(current_state)
56  call assert_equals(mod(current_state%timestep / nn_timesteps, nn_consolidation) /= 0, current_state%continue_consolidation,&
57  "Consolidation completion consistent with expectations")
58  end do
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_modeldump_callback()

subroutine test_terminationcheck_mod::test_modeldump_callback

Definition at line 62 of file test_terminationcheck.F90.

63  integer :: i, nn_timesteps, nn_consolidation, nn_modeldump, multiplier
64  type(model_state_type) :: current_state
65  real :: r
66 
67  call init_random_seed
68 
69  do i=1,max_tests
70  call random_number(r)
71  nn_timesteps= int(r*9)+1
72  call random_number(r)
73  multiplier = int(r*39)+1
74  call random_number(r)
75  nn_consolidation = int(r*9)+1
76  call random_number(r)
77  nn_modeldump = int(r*9)+1
78 
79  current_state%timestep = nn_timesteps * nn_consolidation * multiplier ! timestep and consolidation already terminated hence multiplication
80  current_state%continue_modeldump=.true.
81  call options_add(current_state%options_database, "nn_timesteps", nn_timesteps)
82  call options_add(current_state%options_database, "nn_consolidation", nn_consolidation)
83  call options_add(current_state%options_database, "nn_modeldump", nn_modeldump)
84  call modeldump_callback(current_state)
85  call assert_equals(mod(current_state%timestep / nn_timesteps / nn_consolidation, nn_modeldump) /= 0,&
86  current_state%continue_modeldump, "Model dump completion consistent with expectations")
87  end do
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_timestep_callback()

subroutine test_terminationcheck_mod::test_timestep_callback

Definition at line 13 of file test_terminationcheck.F90.

14  integer :: i, nn_timesteps
15  type(model_state_type) :: current_state
16  real :: r
17 
18  call init_random_seed
19 
20  do i=1,max_tests
21  call random_number(r)
22  current_state%timestep = int(r*10000)+1
23  call random_number(r)
24  nn_timesteps= int(r*9)+1
25 
26  current_state%last_timestep_column = .true. ! Forces the check (only once per timestep)
27  current_state%continue_timestep=.true.
28  call options_add(current_state%options_database, "nn_timesteps", nn_timesteps)
29  call timestep_callback(current_state)
30  call assert_equals(mod(current_state%timestep, nn_timesteps) /= 0, current_state%continue_timestep,&
31  "Timestep completion consistent with expectations")
32  end do
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ max_tests

integer, parameter test_terminationcheck_mod::max_tests = 1000

Definition at line 8 of file test_terminationcheck.F90.

8  integer, parameter :: MAX_TESTS = 1000 ! Number of tests to run for each case, some will require termination some not
optionsdatabase_mod::options_add
Generic add interface for adding different types of data to the databases.
Definition: optionsdatabase.F90:28