Skip to content

Commit 12afb31

Browse files
committed
1) remove override sza/azi options as these angles are provided through the input files, we prefer to keep the slowly growing command line somewhat consise. 2) rename 'disable-2s' (default False) cmd line option to 'two-stream' (default True)
1 parent d4aa235 commit 12afb31

File tree

3 files changed

+19
-51
lines changed

3 files changed

+19
-51
lines changed

include_test/Radiation_solver_rt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class Radiation_solver_shortwave
9999
#ifdef __CUDACC__
100100
void solve_gpu(
101101
const bool switch_fluxes,
102-
const bool switch_disable_2s,
102+
const bool switch_twostream,
103103
const bool switch_raytracing,
104104
const bool switch_independent_column,
105105
const bool switch_cloud_optics,

src_test/Radiation_solver_rt.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ void Radiation_solver_shortwave::load_mie_tables(
567567

568568
void Radiation_solver_shortwave::solve_gpu(
569569
const bool switch_fluxes,
570-
const bool switch_disable_2s,
570+
const bool switch_twostream,
571571
const bool switch_raytracing,
572572
const bool switch_independent_column,
573573
const bool switch_cloud_optics,
@@ -637,7 +637,7 @@ void Radiation_solver_shortwave::solve_gpu(
637637

638638
if (switch_fluxes)
639639
{
640-
if (!switch_disable_2s)
640+
if (switch_twostream)
641641
{
642642
Gas_optics_rrtmgp_kernels_cuda_rt::zero_array(n_lev, grid_cells.y, grid_cells.x, sw_flux_up.ptr());
643643
Gas_optics_rrtmgp_kernels_cuda_rt::zero_array(n_lev, grid_cells.y, grid_cells.x, sw_flux_dn.ptr());
@@ -840,7 +840,7 @@ void Radiation_solver_shortwave::solve_gpu(
840840
}
841841

842842
(*fluxes).net_flux();
843-
if (!switch_disable_2s)
843+
if (switch_twostream)
844844
{
845845
Gpt_combine_kernels_cuda_rt::add_from_gpoint(
846846
n_col, n_lev, sw_flux_up.ptr(), sw_flux_dn.ptr(), sw_flux_dn_dir.ptr(), sw_flux_net.ptr(),

src_test/test_rte_rrtmgp_rt.cu

Lines changed: 15 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void solve_radiation(int argc, char** argv)
227227
{"shortwave" , { true, "Enable computation of shortwave radiation."}},
228228
{"longwave" , { false, "Enable computation of longwave radiation." }},
229229
{"fluxes" , { true, "Enable computation of fluxes." }},
230-
{"disable-2s" , { false, "use raytracing onlu for flux computation. must be passed with raytracing" }},
230+
{"two-stream" , { true, "Run two-stream solver for to obtain 1D fluxes" }},
231231
{"raytracing" , { true, "Use raytracing for flux computation. '--raytracing 256': use 256 rays per pixel" }},
232232
{"independent-column", { false, "run raytracer in independent column mode"}},
233233
{"cloud-optics" , { false, "Enable cloud optics (both liquid and ice)."}},
@@ -238,23 +238,19 @@ void solve_radiation(int argc, char** argv)
238238
{"single-gpt" , { false, "Output optical properties and fluxes for a single g-point. '--single-gpt 100': output 100th g-point" }},
239239
{"profiling" , { false, "Perform additional profiling run." }},
240240
{"delta-cloud" , { false, "delta-scaling of cloud optical properties" }},
241-
{"delta-aerosol" , { false, "delta-scaling of aerosol optical properties" }} ,
242-
{"override-sza" , { false, "override provided value of sza in input file. IN DEGREES. '--override-sza 50': use a sza of 50 degrees" }},
243-
{"override-azi" , { false, "override provided value of azi in input file. IN DEGREES. '--override-azi 240': use of azi of 240 degrees" }}};
241+
{"delta-aerosol" , { false, "delta-scaling of aerosol optical properties" }}};
244242

245243
std::map<std::string, std::pair<int, std::string>> command_line_ints {
246244
{"raytracing", {32, "Number of rays initialised at TOD per pixel per quadraute."}},
247-
{"single-gpt", {1 , "g-point to store optical properties and fluxes of" }},
248-
{"override-sza", {0, "solar zenith angle (theta) in degrees."}},
249-
{"override-azi", {0, "Solar azimuth angle in degrees."}} };
245+
{"single-gpt", {1 , "g-point to store optical properties and fluxes of" }}};
250246

251247
if (parse_command_line_options(command_line_switches, command_line_ints, argc, argv))
252248
return;
253249

254250
const bool switch_shortwave = command_line_switches.at("shortwave" ).first;
255251
const bool switch_longwave = command_line_switches.at("longwave" ).first;
256252
const bool switch_fluxes = command_line_switches.at("fluxes" ).first;
257-
const bool switch_disable_2s = command_line_switches.at("disable-2s" ).first;
253+
const bool switch_twostream = command_line_switches.at("two-stream" ).first;
258254
const bool switch_raytracing = command_line_switches.at("raytracing" ).first;
259255
const bool switch_independent_column= command_line_switches.at("independent-column").first;
260256
bool switch_cloud_optics = command_line_switches.at("cloud-optics" ).first;
@@ -266,8 +262,6 @@ void solve_radiation(int argc, char** argv)
266262
const bool switch_profiling = command_line_switches.at("profiling" ).first;
267263
const bool switch_delta_cloud = command_line_switches.at("delta-cloud" ).first;
268264
const bool switch_delta_aerosol = command_line_switches.at("delta-aerosol" ).first;
269-
const bool override_sza = command_line_switches.at("override-sza" ).first;
270-
const bool override_azi = command_line_switches.at("override-azi" ).first;
271265

272266
Int photons_per_pixel = Int(command_line_ints.at("raytracing").first);
273267
if (Float(int(std::log2(Float(photons_per_pixel)))) != std::log2(Float(photons_per_pixel)))
@@ -282,7 +276,7 @@ void solve_radiation(int argc, char** argv)
282276
throw std::runtime_error(error);
283277
}
284278

285-
if (switch_disable_2s && !switch_raytracing) {
279+
if (!switch_twostream && !switch_raytracing) {
286280
std::string error = "cannot disable two-stream for flux calculation without turning ray tracing on";
287281
throw std::runtime_error(error);
288282
}
@@ -301,21 +295,9 @@ void solve_radiation(int argc, char** argv)
301295
print_command_line_options(command_line_switches, command_line_ints);
302296

303297
int single_gpt = command_line_ints.at("single-gpt").first;
304-
int sza_deg = Int(command_line_ints.at("override-sza").first);
305-
int azi_deg = Int(command_line_ints.at("override-azi").first);
306298

307299
Status::print_message("Using "+ std::to_string(photons_per_pixel) + " rays per pixel");
308300

309-
if (override_sza)
310-
{
311-
Status::print_message("Using SZA of "+ std::to_string(sza_deg) + " degrees");
312-
}
313-
314-
if (override_azi)
315-
{
316-
Status::print_message("Using azi of "+ std::to_string(azi_deg) + " degrees");
317-
}
318-
319301
////// READ THE ATMOSPHERIC DATA //////
320302
Status::print_message("Reading atmospheric input data from NetCDF.");
321303

@@ -392,15 +374,17 @@ void solve_radiation(int argc, char** argv)
392374
if (switch_cloud_optics)
393375
{
394376

395-
if(switch_liq_cloud_optics){
377+
if(switch_liq_cloud_optics)
378+
{
396379
lwp.set_dims({n_col, n_lay});
397380
lwp = std::move(input_nc.get_variable<Float>("lwp", {n_lay, n_col_y, n_col_x}));
398381

399382
rel.set_dims({n_col, n_lay});
400383
rel = std::move(input_nc.get_variable<Float>("rel", {n_lay, n_col_y, n_col_x}));
401384
}
402385

403-
if(switch_ice_cloud_optics){
386+
if(switch_ice_cloud_optics)
387+
{
404388
iwp.set_dims({n_col, n_lay});
405389
iwp = std::move(input_nc.get_variable<Float>("iwp", {n_lay, n_col_y, n_col_x}));
406390

@@ -682,24 +666,8 @@ void solve_radiation(int argc, char** argv)
682666
rad_sw.load_mie_tables("mie_lut_broadband.nc");
683667
}
684668

685-
Array<Float,1> mu0({n_col});
686-
Array<Float,1> azi({n_col});
687-
688-
if (override_sza) {
689-
Float mu0_in = cosf(sza_deg * 3.14159f / 180.0f);
690-
for (int icol=1; icol<=n_col; ++icol)
691-
mu0({icol}) = mu0_in;
692-
} else {
693-
mu0 = input_nc.get_variable<Float>("mu0", {n_col_y, n_col_x});
694-
}
695-
696-
if (override_azi) {
697-
Float azi_in = azi_deg * 3.14159f / 180.0f;
698-
for (int icol=1; icol<=n_col; ++icol)
699-
azi({icol}) = azi_in;
700-
} else {
701-
azi = input_nc.get_variable<Float>("azi", {n_col_y, n_col_x});
702-
}
669+
Array<Float,1> mu0(input_nc.get_variable<Float>("mu0", {n_col_y, n_col_x}), {n_col});
670+
Array<Float,1> azi(input_nc.get_variable<Float>("azi", {n_col_y, n_col_x}), {n_col});
703671

704672
Array<Float,2> sfc_alb_dir(input_nc.get_variable<Float>("sfc_alb_dir", {n_col_y, n_col_x, n_bnd_sw}), {n_bnd_sw, n_col});
705673
Array<Float,2> sfc_alb_dif(input_nc.get_variable<Float>("sfc_alb_dif", {n_col_y, n_col_x, n_bnd_sw}), {n_bnd_sw, n_col});
@@ -761,7 +729,7 @@ void solve_radiation(int argc, char** argv)
761729

762730
if (switch_fluxes)
763731
{
764-
if(!switch_disable_2s)
732+
if(switch_twostream)
765733
{
766734
sw_flux_up .set_dims({n_col, n_lev});
767735
sw_flux_dn .set_dims({n_col, n_lev});
@@ -828,7 +796,7 @@ void solve_radiation(int argc, char** argv)
828796

829797
rad_sw.solve_gpu(
830798
switch_fluxes,
831-
switch_disable_2s,
799+
switch_twostream,
832800
switch_raytracing,
833801
switch_independent_column,
834802
switch_cloud_optics,
@@ -966,7 +934,7 @@ void solve_radiation(int argc, char** argv)
966934

967935
if (switch_fluxes)
968936
{
969-
if (!switch_disable_2s)
937+
if (switch_twostream)
970938
{
971939
auto nc_sw_flux_up = output_nc.add_variable<Float>("sw_flux_up" , {"lev", "y", "x"});
972940
auto nc_sw_flux_dn = output_nc.add_variable<Float>("sw_flux_dn" , {"lev", "y", "x"});
@@ -1032,7 +1000,7 @@ void solve_radiation(int argc, char** argv)
10321000

10331001
if (switch_single_gpt)
10341002
{
1035-
if (!switch_disable_2s)
1003+
if (switch_twostream)
10361004
{
10371005
auto nc_sw_gpt_flux_up = output_nc.add_variable<Float>("sw_gpt_flux_up" , {"lev", "y", "x"});
10381006
auto nc_sw_gpt_flux_dn = output_nc.add_variable<Float>("sw_gpt_flux_dn" , {"lev", "y", "x"});

0 commit comments

Comments
 (0)