2 ! Purpose: This program contains unit tests for the module overland_data
3 ! National Water Center
4 ! Responsibility: Donald W Johnson donald.w.johnson@noaa.gov
5 ! Authors: Donald W Johnson
13 write(6,*) "Running Test 1"
14 write(6,*) "Test that the allocation and deallocation functions work correctly"
15 rv = init_delete_test(100,100)
16 write(6,*) "Test Complete"
18 write(6,*) "Running Test 2"
19 write(6,*) "Testing scaling"
21 write(6,*) "Test Complete"
23 write(6,*) "Running Test 3"
24 write(6,*) "Testing double init"
25 rv = double_init_test()
26 write(6,*) "Test Complete"
28 write(6,*) "Running Test 4"
29 write(6,*) "Testing double destroy"
30 rv = double_destroy_test()
31 write(6,*) "Test Complete"
34 function init_delete_test(ix,jx) result(rv)
37 integer, intent(in) :: ix
38 integer, intent(in) :: jx
41 logical :: status = .true.
43 type (overland_struct) :: overland_data
45 ! initalize the structure
46 call overland_data%init(ix,jx,ix,jx)
48 ! test to see if control was associated
49 if ( associated(overland_data%control) ) then
50 !write(6,*) "control type was associated"
52 !write(6,*) "control type not associated"
56 ! test to see if streams_and_lakes was associated
57 if ( associated(overland_data%streams_and_lakes) ) then
58 !write(6,*) "streams and lakes type was associated"
60 !write(6,*) "streams and lakes type not associated"
64 ! test to see if streams_and_lakes was associated
65 if ( associated(overland_data%properties) ) then
66 !write(6,*) "properties type was associated"
68 !write(6,*) "properties type not associated"
72 ! test to see if streams_and_lakes was associated
73 if ( associated(overland_data%mass_balance) ) then
74 !write(6,*) "mass_balance type was associated"
76 !write(6,*) "mass_balance type not associated"
80 ! destroy the structure
81 call overland_data%destroy
83 ! test to see if control was associated
84 if ( .not. associated(overland_data%control) ) then
85 !write(6,*) "control type was disassociated"
87 !write(6,*) "control type not disassociated"
91 ! test to see if streams_and_lakes was associated
92 if ( .not. associated(overland_data%streams_and_lakes) ) then
93 !write(6,*) "streams and lakes type was disassociated"
95 !write(6,*) "streams and lakes type not disassociated"
99 ! test to see if streams_and_lakes was associated
100 if ( .not. associated(overland_data%properties) ) then
101 !write(6,*) "properties type was disassociated"
103 !write(6,*) "properties type not disassociated"
107 ! test to see if streams_and_lakes was associated
108 if ( .not. associated(overland_data%mass_balance) ) then
109 !write(6,*) "mass_balance type was disassociated"
111 !write(6,*) "mass_balance type not disassociated"
115 ! write final test results
117 write(6,*) "Test Passed"
119 write(6,*) "Test Failed"
123 end function init_delete_test
125 function scale_tests() result(rv)
128 logical, dimension(4) :: results
131 write(6,*) "Running Test for (10,10)"
132 results(1) = init_delete_test(10,10)
133 write(6,*) "Running Test for (100,100)"
134 results(2) = init_delete_test(100,100)
135 write(6,*) "Running Test for (1000,1000)"
136 results(3) = init_delete_test(1000,1000)
137 write(6,*) "Running Test for (5000,5000)"
138 results(4) = init_delete_test(5000,5000)
140 if ( all(results) ) then
142 write(6,*) "All Sub-Test Passed"
145 write(6,*) "At Least One Sub-Test Failed"
148 end function scale_tests
150 function double_init_test() result(rv)
154 type (overland_struct) :: overland_data
156 call overland_data%init(100,100,100,100)
157 call overland_data%init(100,100,100,100)
158 call overland_data%destroy
160 write(6,*) "Test Passed"
162 end function double_init_test
164 function double_destroy_test() result(rv)
168 type (overland_struct) :: overland_data
170 call overland_data%init(100,100,100,100)
171 call overland_data%destroy
172 call overland_data%destroy
174 write(6,*) "Test Passed"
176 end function double_destroy_test
178 end program overland_tests