20 use ai_wavelength_grid,
only : wavelength_grid_t
21 use ai_optics,
only : optics_t
25 use musica_assert,
only : assert
26 use musica_constants,
only : dk => musica_dk
27 use musica_property,
only : property_t
28 use mock_interpolation_strategy,
only : foo_mapper
30 character(len=*),
parameter :: my_name =
"optics utility tests"
31 type(wavelength_grid_t) :: native_sw_grid, native_lw_grid, output_grid
32 type(property_t) :: property
33 class(optics_t),
pointer :: optics
34 real(kind=dk) :: values(3)
36 native_sw_grid = wavelength_grid_t( (/ 0.0_dk, 10.0_dk, 200.0_dk /), &
37 (/ 10.0_dk, 110.0_dk, 400.0_dk /) )
38 native_lw_grid = wavelength_grid_t( (/ 10.0_dk, 400.0_dk /), &
39 (/ 20.0_dk, 600.0_dk /) )
42 output_grid = native_sw_grid
43 property = property_t( my_name, &
44 name =
"layer extinction optical depth" )
45 optics =>
create_optics( property, native_sw_grid, native_lw_grid,&
47 call optics%set_values( (/ 0.0_dk, 0.0_dk, 0.0_dk /) )
49 (/ 2.0_dk, 5.0_dk, 1.0_dk /), &
50 (/ 10.0_dk, 4.0_dk, 25.0_dk /), &
53 call optics%get_values( values )
54 call assert( 201129633, values(1) .eq. 150.0_dk )
55 call assert( 930972728, values(2) .eq. 0.0_dk )
56 call assert( 143291074, values(3) .eq. 10.0_dk )
59 property = property_t( my_name, &
60 name =
"layer single-scatter albedo" )
61 optics =>
create_optics( property, native_sw_grid, native_lw_grid,&
63 call optics%set_values( (/ 0.0_dk, 0.0_dk, 0.0_dk /) )
65 (/ 2.0_dk, 5.0_dk, 1.0_dk /), &
66 (/ 10.0_dk, 4.0_dk, 25.0_dk /), &
69 call optics%get_values( values )
70 call assert( 692900946, values(1) .eq. 300.0_dk )
71 call assert( 805219291, values(2) .eq. 0.0_dk )
72 call assert( 635062387, values(3) .eq. 10.0_dk )
75 property = property_t( my_name, &
76 name =
"asymmetry factor" )
77 optics =>
create_optics( property, native_sw_grid, native_lw_grid,&
79 call optics%set_values( (/ 0.0_dk, 0.0_dk, 0.0_dk /) )
81 (/ 2.0_dk, 5.0_dk, 1.0_dk /), &
82 (/ 10.0_dk, 4.0_dk, 25.0_dk /), &
85 call optics%get_values( values )
86 call assert( 914178863, values(1) .eq. 3000.0_dk )
87 call assert( 461546710, values(2) .eq. 0.0_dk )
88 call assert( 356398206, values(3) .eq. 250.0_dk )
91 property = property_t( my_name, &
92 name =
"forward scattered fraction" )
93 optics =>
create_optics( property, native_sw_grid, native_lw_grid,&
95 call optics%set_values( (/ 0.0_dk, 0.0_dk, 0.0_dk /) )
97 (/ 2.0_dk, 5.0_dk, 1.0_dk /), &
98 (/ 10.0_dk, 4.0_dk, 25.0_dk /), &
101 call optics%get_values( values )
102 call assert( 630250375, values(1) .eq. 30000.0_dk )
103 call assert( 177618222, values(2) .eq. 0.0_dk )
104 call assert( 907461317, values(3) .eq. 6250.0_dk )
107 output_grid = native_lw_grid
108 property = property_t( my_name, &
109 name =
"layer absorption optical depth" )
110 optics =>
create_optics( property, native_sw_grid, native_lw_grid,&
112 call optics%set_values( (/ 0.0_dk, 0.0_dk /) )
115 call optics%get_values( values(1:2) )
116 call assert( 228739235, values(1) .eq. 150.0_dk )
117 call assert( 676107081, values(2) .eq. 0.0_dk )
118 call assert( 223474928, values(3) .eq. 0.0_dk )
122 output_grid = wavelength_grid_t( (/ 4.0_dk, 14.0_dk, 210.0_dk /), &
123 (/ 13.0_dk, 105.0_dk, 403.0_dk /) )
124 property = property_t( my_name, &
125 name =
"layer extinction optical depth" )
126 optics =>
create_optics( property, native_sw_grid, native_lw_grid,&
128 interpolation_strategy = foo_mapper )
129 call optics%set_values( (/ 0.0_dk, 0.0_dk, 0.0_dk /) )
131 (/ 2.0_dk, 5.0_dk, 1.0_dk /), &
132 (/ 10.0_dk, 4.0_dk, 25.0_dk /), &
135 call optics%get_values( values )
136 call assert( 577249425, values(1) .eq. 150.5_dk )
137 call assert( 689567770, values(2) .eq. 0.5_dk )
138 call assert( 519410866, values(3) .eq. 0.0_dk )
141 property = property_t( my_name, &
142 name =
"layer single-scatter albedo" )
143 optics =>
create_optics( property, native_sw_grid, native_lw_grid,&
145 interpolation_strategy = foo_mapper )
146 call optics%set_values( (/ 0.0_dk, 0.0_dk, 0.0_dk /) )
148 (/ 2.0_dk, 5.0_dk, 1.0_dk /), &
149 (/ 10.0_dk, 4.0_dk, 25.0_dk /), &
152 call optics%get_values( values )
153 call assert( 110016064, values(1) .eq. 302.5_dk )
154 call assert( 287342809, values(2) .eq. 2.5_dk )
155 call assert( 734710655, values(3) .eq. 0.0_dk )
158 property = property_t( my_name, &
159 name =
"asymmetry factor" )
160 optics =>
create_optics( property, native_sw_grid, native_lw_grid,&
162 interpolation_strategy = foo_mapper )
163 call optics%set_values( (/ 0.0_dk, 0.0_dk, 0.0_dk /) )
165 (/ 2.0_dk, 5.0_dk, 1.0_dk /), &
166 (/ 10.0_dk, 4.0_dk, 25.0_dk /), &
169 call optics%get_values( values )
170 call assert( 283984036, values(1) .eq. 3010.0_dk )
171 call assert( 113827132, values(2) .eq. 10.0_dk )
172 call assert( 561194978, values(3) .eq. 0.0_dk )
175 property = property_t( my_name, &
176 name =
"forward scattered fraction" )
177 optics =>
create_optics( property, native_sw_grid, native_lw_grid,&
179 interpolation_strategy = foo_mapper )
180 call optics%set_values( (/ 0.0_dk, 0.0_dk, 0.0_dk /) )
182 (/ 2.0_dk, 5.0_dk, 1.0_dk /), &
183 (/ 10.0_dk, 4.0_dk, 25.0_dk /), &
186 call optics%get_values( values )
187 call assert( 892885706, values(1) .eq. 30040.0_dk )
188 call assert( 440253553, values(2) .eq. 40.0_dk )
189 call assert( 335105049, values(3) .eq. 0.0_dk )
192 property = property_t( my_name, &
193 name =
"layer absorption optical depth" )
194 optics =>
create_optics( property, native_sw_grid, native_lw_grid,&
196 interpolation_strategy = foo_mapper )
197 call optics%set_values( (/ 0.0_dk, 0.0_dk /) )
200 call optics%get_values( values )
201 call assert( 214163624, values(1) .eq. 150.5_dk )
202 call assert( 944006719, values(2) .eq. 0.5_dk )
203 call assert( 491374566, values(3) .eq. 0.0_dk )
Constants used to calculate MAM optical properties.
class(optics_t) function, pointer, public create_optics(property, native_shortwave_grid, native_longwave_grid, output_grid, interpolation_strategy)
Returns an optics_t object for a given property.
subroutine, public add_shortwave_property(extinction_optical_depth, single_scatter_albedo, asymmetry_factor, optics)
Adds to shortwave property values.
subroutine, public add_longwave_property(extinction_optical_depth, optics)
Adds to longwave property values.
program test_optics_util
Tests for optics utility functions.
subroutine test_optics_util_functions()