1 ! This module holds tests for initialization of
2 ! various attributes of an RFC forecasts reservoir.
3 module module_rfc_forecasts_tests
4 use module_rfc_forecasts
5 use module_reservoir_read_rfc_time_series_data
10 function rfc_forecasts_data_info(rfc_forecasts_reservoir_data) result(data_info_result)
12 type (rfc_forecasts) :: rfc_forecasts_reservoir_data
13 logical :: data_info_result
14 logical, dimension(8) :: ptr_state
15 logical, dimension(8) :: data_state
17 data_info_result = .false.
19 ! Check to see if the rfc_forecasts_state data structure exists
20 print *, "Checking pointer association on data%state for rfc forecasts reservoirs"
21 if ( associated(rfc_forecasts_reservoir_data%state) ) then
26 ptr_state(1) = .false.
30 ! Check to see if the rfc_forecasts_properties data structure exists
31 print *, "Checking pointer association on data%properties for rfc forecasts reservoirs"
32 if ( associated(rfc_forecasts_reservoir_data%properties) ) then
37 ptr_state(2) = .false.
41 ! Check to see if the rfc_forecasts_input data structure exists
42 print *, "Checking pointer association on data%input for rfc forecasts reservoirs"
43 if ( associated(rfc_forecasts_reservoir_data%input) ) then
48 ptr_state(3) = .false.
52 ! Check to see if the rfc_forecasts_output data structure exists
53 print *, "Checking pointer association on data%output for rfc forecasts reservoirs"
54 if ( associated(rfc_forecasts_reservoir_data%output) ) then
59 ptr_state(4) = .false.
63 ! Test levelpool structure
64 ! Check to see if the rfc_forecasts levelpool_state data structure exists
65 print *, "Checking pointer association on data%levelpool_state for rfc forecasts reservoirs"
66 if ( associated(rfc_forecasts_reservoir_data%state%levelpool_ptr%state) ) then
71 ptr_state(5) = .false.
75 ! Check to see if the rfc_forecasts levelpool_properties data structure exists
76 print *, "Checking pointer association on data%levelpool_properties for rfc forecasts reservoirs"
77 if ( associated(rfc_forecasts_reservoir_data%state%levelpool_ptr%properties) ) then
82 ptr_state(6) = .false.
86 ! Check to see if the rfc_forecasts levelpool_input data structure exists
87 print *, "Checking pointer association on data%levelpool_input for rfc forecasts reservoirs"
88 if ( associated(rfc_forecasts_reservoir_data%state%levelpool_ptr%input) ) then
93 ptr_state(7) = .false.
97 ! Check to see if the rfc_forecasts levelpool_output data structure exists
98 print *, "Checking pointer association on data%levelpool_output for rfc forecasts reservoirs"
99 if ( associated(rfc_forecasts_reservoir_data%state%levelpool_ptr%output) ) then
101 ptr_state(8) = .true.
104 ptr_state(8) = .false.
109 ! Now check the data members of each substructure
110 if ( ptr_state(1) ) then
111 data_state(1) = test_rfc_forecasts_state(rfc_forecasts_reservoir_data%state)
114 if ( ptr_state(2) ) then
115 data_state(2) = test_rfc_forecasts_properties(rfc_forecasts_reservoir_data%properties)
118 if ( ptr_state(3) ) then
119 data_state(3) = test_input_rfc_forecasts(rfc_forecasts_reservoir_data%input)
122 if ( ptr_state(4) ) then
123 data_state(4) = test_output_rfc_forecasts(rfc_forecasts_reservoir_data%output)
126 ! Test Levelpool Substructures
127 if ( ptr_state(5) ) then
128 data_state(5) = test_rfc_forecasts_levelpool_state(rfc_forecasts_reservoir_data%state)
131 if ( ptr_state(6) ) then
132 data_state(6) = test_rfc_forecasts_levelpool_properties(rfc_forecasts_reservoir_data%state)
135 if ( ptr_state(7) ) then
136 data_state(7) = test_rfc_forecasts_levelpool_input(rfc_forecasts_reservoir_data%state%levelpool_ptr%input)
139 if ( ptr_state(8) ) then
140 data_state(8) = test_rfc_forecasts_levelpool_output(rfc_forecasts_reservoir_data%state%levelpool_ptr%output)
143 if ( all(ptr_state) .and. all(data_state) ) then
144 data_info_result = .true.
145 print *, "========================================================================"
146 print *, "All RFC Forecast Reservoir Object Tests Passed"
147 print *, "========================================================================"
150 data_info_result = .false.
151 print *, "========================================================================"
152 print *, "Not All RFC Forecast Reservoir Object Tests Passed"
153 print *, "========================================================================"
157 end function rfc_forecasts_data_info
159 ! Test to see that each member of the input structure is correctly allocated and readable
160 function test_input_rfc_forecasts(o) result(rv)
161 type (reservoir_input), intent(in) :: o
166 print *, "========================================================================"
167 print *, "Checking the values of the input structure"
170 print *, "Checking read on inflow"
172 if ( o%inflow .ne. 0.0) then
178 print *, "Checking read on lateral_inflow"
179 print *, o%lateral_inflow
180 if ( o%lateral_inflow .ne. 0.0) then
186 print *, "Checking read on previous_timestep_inflow"
187 print *, o%previous_timestep_inflow
188 if ( o%previous_timestep_inflow .ne. 0.0) then
194 end function test_input_rfc_forecasts
196 ! Test to see that each member of the output structure is correctly allocated and readable
197 function test_output_rfc_forecasts(o) result(rv)
198 type (reservoir_output), intent(in) :: o
203 print *, "========================================================================"
204 print *, "Checking the values of the output structure"
207 print *, "Checking read on outflow"
209 if ( o%outflow .ne. 0.0) then
215 end function test_output_rfc_forecasts
217 ! Test to see that each member of the state structure is correctly allocated and readable
218 function test_rfc_forecasts_state(o) result(rv)
219 type (rfc_forecasts_state_interface), intent(in) :: o
224 print *, "========================================================================"
225 print *, "Checking the values of the rfc_forecasts state data structure"
228 print *, "Checking read on water_elevation"
229 print *, o%water_elevation
230 if ( o%water_elevation .ne. 17.3999996) then
236 end function test_rfc_forecasts_state
239 ! Test to see that each member of the properties structure is correctly allocated and readable
240 function test_rfc_forecasts_properties(o) result(rv)
241 type (rfc_forecasts_properties_interface), intent(in) :: o
246 print *, "========================================================================"
247 print *, "Checking the values of the rfc_forecasts properties data structure"
250 print *, "Checking read on lake_number"
251 print *, o%lake_number
252 if ( o%lake_number .ne. 3745478) then
258 print *, "Checking read on rfc_gage_id"
259 print *, o%rfc_gage_id
260 if ( o%rfc_gage_id .ne. "DIEA4") then
266 end function test_rfc_forecasts_properties
269 ! Levelpool data tests
270 ! Test to see that each member of the levelpool input structure is correctly allocated and readable
271 function test_rfc_forecasts_levelpool_input(o) result(rv)
272 type (reservoir_input), intent(in) :: o
277 print *, "========================================================================"
278 print *, "Checking the values of the rfc forecasts levelpool input structure"
281 print *, "Checking read on inflow"
283 if ( o%inflow .ne. 0.0) then
289 print *, "Checking read on lateral_inflow"
290 print *, o%lateral_inflow
291 if ( o%lateral_inflow .ne. 0.0) then
297 print *, "Checking read on previous_timestep_inflow"
298 print *, o%previous_timestep_inflow
299 if ( o%previous_timestep_inflow .ne. 0.0) then
305 end function test_rfc_forecasts_levelpool_input
307 ! Test to see that each member of the levelpool output structure is correctly allocated and readable
308 function test_rfc_forecasts_levelpool_output(o) result(rv)
309 type (reservoir_output), intent(in) :: o
314 print *, "========================================================================"
315 print *, "Checking the values of the rfc forecasts levelpool output structure"
318 print *, "Checking read on outflow"
320 if ( o%outflow .ne. 0.0) then
326 end function test_rfc_forecasts_levelpool_output
328 ! Test to see that each member of the levelpool state structure is correctly allocated and readable
329 function test_rfc_forecasts_levelpool_state(o) result(rv)
330 type (rfc_forecasts_state_interface), intent(in) :: o
335 print *, "========================================================================"
336 print *, "Checking the values of the rfc forecasts levelpool state data structure"
339 print *, "Checking read on water_elevation"
340 print *, o%levelpool_ptr%state%water_elevation
341 if ( o%levelpool_ptr%state%water_elevation .ne. 2.0) then
347 end function test_rfc_forecasts_levelpool_state
350 ! Test to see that each member of the levelpool properties structure is correctly allocated and readable
351 function test_rfc_forecasts_levelpool_properties(o) result(rv)
352 type (rfc_forecasts_state_interface), intent(in) :: o
357 print *, "========================================================================"
358 print *, "Checking the values of the rfc forecasts levelpool properties data structure"
361 print *, "Checking read on lake_area"
362 print *, o%levelpool_ptr%properties%lake_area
363 if ( o%levelpool_ptr%properties%lake_area .ne. 4.0) then
369 print *, "Checking read on weir_elevation"
370 print *, o%levelpool_ptr%properties%weir_elevation
371 if ( o%levelpool_ptr%properties%weir_elevation .ne. 6.0) then
377 print *, "Checking read on weir_coeffecient"
378 print *, o%levelpool_ptr%properties%weir_coeffecient
379 if ( o%levelpool_ptr%properties%weir_coeffecient .ne. 8.0) then
385 print *, "Checking read on weir_length"
386 print *, o%levelpool_ptr%properties%weir_length
387 if ( o%levelpool_ptr%properties%weir_length .ne. 10.0) then
393 print *, "Checking read on orifice_elevation"
394 print *, o%levelpool_ptr%properties%orifice_elevation
395 if ( o%levelpool_ptr%properties%orifice_elevation .ne. 12.0) then
401 print *, "Checking read on orifice_coefficient"
402 print *, o%levelpool_ptr%properties%orifice_coefficient
403 if ( o%levelpool_ptr%properties%orifice_coefficient .ne. 14.0) then
409 print *, "Checking read on orifice_area"
410 print *, o%levelpool_ptr%properties%orifice_area
411 if ( o%levelpool_ptr%properties%orifice_area .ne. 16.0) then
417 print *, "Checking read on max_depth"
418 print *, o%levelpool_ptr%properties%max_depth
419 if ( o%levelpool_ptr%properties%max_depth .ne. 18.0) then
425 print *, "Checking read on lake_number"
426 print *, o%levelpool_ptr%properties%lake_number
427 if ( o%levelpool_ptr%properties%lake_number .ne. 3745478) then
433 end function test_rfc_forecasts_levelpool_properties