diff --git a/include_test/Radiation_solver_rt.h b/include_test/Radiation_solver_rt.h index bb56d27..4d59a97 100644 --- a/include_test/Radiation_solver_rt.h +++ b/include_test/Radiation_solver_rt.h @@ -99,6 +99,7 @@ class Radiation_solver_shortwave #ifdef __CUDACC__ void solve_gpu( const bool switch_fluxes, + const bool switch_disable_2s, const bool switch_raytracing, const bool switch_independent_column, const bool switch_cloud_optics, diff --git a/src_test/Radiation_solver_rt.cu b/src_test/Radiation_solver_rt.cu index 49348a2..778b573 100644 --- a/src_test/Radiation_solver_rt.cu +++ b/src_test/Radiation_solver_rt.cu @@ -567,6 +567,7 @@ void Radiation_solver_shortwave::load_mie_tables( void Radiation_solver_shortwave::solve_gpu( const bool switch_fluxes, + const bool switch_disable_2s, const bool switch_raytracing, const bool switch_independent_column, const bool switch_cloud_optics, @@ -636,10 +637,10 @@ void Radiation_solver_shortwave::solve_gpu( if (switch_fluxes) { - Gas_optics_rrtmgp_kernels_cuda_rt::zero_array(n_lev, grid_cells.y, grid_cells.x, sw_flux_up.ptr()); - Gas_optics_rrtmgp_kernels_cuda_rt::zero_array(n_lev, grid_cells.y, grid_cells.x, sw_flux_dn.ptr()); - Gas_optics_rrtmgp_kernels_cuda_rt::zero_array(n_lev, grid_cells.y, grid_cells.x, sw_flux_dn_dir.ptr()); - Gas_optics_rrtmgp_kernels_cuda_rt::zero_array(n_lev, grid_cells.y, grid_cells.x, sw_flux_net.ptr()); + // Gas_optics_rrtmgp_kernels_cuda_rt::zero_array(n_lev, grid_cells.y, grid_cells.x, sw_flux_up.ptr()); + // Gas_optics_rrtmgp_kernels_cuda_rt::zero_array(n_lev, grid_cells.y, grid_cells.x, sw_flux_dn.ptr()); + // Gas_optics_rrtmgp_kernels_cuda_rt::zero_array(n_lev, grid_cells.y, grid_cells.x, sw_flux_dn_dir.ptr()); + // Gas_optics_rrtmgp_kernels_cuda_rt::zero_array(n_lev, grid_cells.y, grid_cells.x, sw_flux_net.ptr()); if (switch_raytracing) { Gas_optics_rrtmgp_kernels_cuda_rt::zero_array(grid_cells.y, grid_cells.x, rt_flux_tod_up.ptr()); @@ -837,10 +838,13 @@ void Radiation_solver_shortwave::solve_gpu( (*fluxes).net_flux(); - Gpt_combine_kernels_cuda_rt::add_from_gpoint( - n_col, n_lev, sw_flux_up.ptr(), sw_flux_dn.ptr(), sw_flux_dn_dir.ptr(), sw_flux_net.ptr(), - (*fluxes).get_flux_up().ptr(), (*fluxes).get_flux_dn().ptr(), (*fluxes).get_flux_dn_dir().ptr(), (*fluxes).get_flux_net().ptr()); - + if(!switch_disable_2s) + { + Gpt_combine_kernels_cuda_rt::add_from_gpoint( + n_col, n_lev, sw_flux_up.ptr(), sw_flux_dn.ptr(), sw_flux_dn_dir.ptr(), sw_flux_net.ptr(), + (*fluxes).get_flux_up().ptr(), (*fluxes).get_flux_dn().ptr(), (*fluxes).get_flux_dn_dir().ptr(), (*fluxes).get_flux_net().ptr()); + } + if (switch_raytracing) { Gpt_combine_kernels_cuda_rt::add_from_gpoint( diff --git a/src_test/test_rte_rrtmgp_rt.cu b/src_test/test_rte_rrtmgp_rt.cu index 2e93cf9..f4a27e9 100644 --- a/src_test/test_rte_rrtmgp_rt.cu +++ b/src_test/test_rte_rrtmgp_rt.cu @@ -227,6 +227,7 @@ void solve_radiation(int argc, char** argv) {"shortwave" , { true, "Enable computation of shortwave radiation."}}, {"longwave" , { false, "Enable computation of longwave radiation." }}, {"fluxes" , { true, "Enable computation of fluxes." }}, + {"disable-2s" , { false, "use raytracing onlu for flux computation. must be passed with raytracing" }}, {"raytracing" , { true, "Use raytracing for flux computation. '--raytracing 256': use 256 rays per pixel" }}, {"independent-column", { false, "run raytracer in independent column mode"}}, {"cloud-optics" , { false, "Enable cloud optics." }}, @@ -249,6 +250,7 @@ void solve_radiation(int argc, char** argv) const bool switch_shortwave = command_line_switches.at("shortwave" ).first; const bool switch_longwave = command_line_switches.at("longwave" ).first; const bool switch_fluxes = command_line_switches.at("fluxes" ).first; + const bool switch_disable_2s = command_line_switches.at("disable-2s").first; const bool switch_raytracing = command_line_switches.at("raytracing" ).first; const bool switch_independent_column= command_line_switches.at("independent-column").first; const bool switch_cloud_optics = command_line_switches.at("cloud-optics" ).first; @@ -275,6 +277,11 @@ void solve_radiation(int argc, char** argv) throw std::runtime_error(error); } + if (switch_disable_2s && !switch_raytracing) { + std::string error = "cannot disable two-stream for flux calc without turning ray tracing on"; + throw std::runtime_error(error); + } + if (switch_liq_cloud_optics && switch_ice_cloud_optics) { std::string error = "Both liquid-only and ice-only cloud optics cannot be enabled simultaneously"; throw std::runtime_error(error); @@ -716,10 +723,13 @@ void solve_radiation(int argc, char** argv) if (switch_fluxes) { - sw_flux_up .set_dims({n_col, n_lev}); - sw_flux_dn .set_dims({n_col, n_lev}); - sw_flux_dn_dir.set_dims({n_col, n_lev}); - sw_flux_net .set_dims({n_col, n_lev}); + if(!switch_disable_2s) + { + sw_flux_up .set_dims({n_col, n_lev}); + sw_flux_dn .set_dims({n_col, n_lev}); + sw_flux_dn_dir.set_dims({n_col, n_lev}); + sw_flux_net .set_dims({n_col, n_lev}); + } if (switch_raytracing) { @@ -780,6 +790,7 @@ void solve_radiation(int argc, char** argv) rad_sw.solve_gpu( switch_fluxes, + switch_disable_2s, switch_raytracing, switch_independent_column, switch_cloud_optics, @@ -917,27 +928,30 @@ void solve_radiation(int argc, char** argv) if (switch_fluxes) { - auto nc_sw_flux_up = output_nc.add_variable("sw_flux_up" , {"lev", "y", "x"}); - auto nc_sw_flux_dn = output_nc.add_variable("sw_flux_dn" , {"lev", "y", "x"}); - auto nc_sw_flux_dn_dir = output_nc.add_variable("sw_flux_dn_dir", {"lev", "y", "x"}); - auto nc_sw_flux_net = output_nc.add_variable("sw_flux_net" , {"lev", "y", "x"}); + if(!switch_disable_2s) + { + auto nc_sw_flux_up = output_nc.add_variable("sw_flux_up" , {"lev", "y", "x"}); + auto nc_sw_flux_dn = output_nc.add_variable("sw_flux_dn" , {"lev", "y", "x"}); + auto nc_sw_flux_dn_dir = output_nc.add_variable("sw_flux_dn_dir", {"lev", "y", "x"}); + auto nc_sw_flux_net = output_nc.add_variable("sw_flux_net" , {"lev", "y", "x"}); - nc_sw_flux_up .insert(sw_flux_up_cpu .v(), {0, 0, 0}); - nc_sw_flux_dn .insert(sw_flux_dn_cpu .v(), {0, 0, 0}); - nc_sw_flux_dn_dir.insert(sw_flux_dn_dir_cpu.v(), {0, 0, 0}); - nc_sw_flux_net .insert(sw_flux_net_cpu .v(), {0, 0, 0}); + nc_sw_flux_up .insert(sw_flux_up_cpu .v(), {0, 0, 0}); + nc_sw_flux_dn .insert(sw_flux_dn_cpu .v(), {0, 0, 0}); + nc_sw_flux_dn_dir.insert(sw_flux_dn_dir_cpu.v(), {0, 0, 0}); + nc_sw_flux_net .insert(sw_flux_net_cpu .v(), {0, 0, 0}); - nc_sw_flux_up.add_attribute("long_name","Upwelling shortwave fluxes (TwoStream solver)"); - nc_sw_flux_up.add_attribute("units","W m-2"); + nc_sw_flux_up.add_attribute("long_name","Upwelling shortwave fluxes (TwoStream solver)"); + nc_sw_flux_up.add_attribute("units","W m-2"); - nc_sw_flux_dn.add_attribute("long_name","Downwelling shortwave fluxes (TwoStream solver)"); - nc_sw_flux_dn.add_attribute("units","W m-2"); + nc_sw_flux_dn.add_attribute("long_name","Downwelling shortwave fluxes (TwoStream solver)"); + nc_sw_flux_dn.add_attribute("units","W m-2"); - nc_sw_flux_dn_dir.add_attribute("long_name","Downwelling direct shortwave fluxes (TwoStream solver)"); - nc_sw_flux_dn_dir.add_attribute("units","W m-2"); + nc_sw_flux_dn_dir.add_attribute("long_name","Downwelling direct shortwave fluxes (TwoStream solver)"); + nc_sw_flux_dn_dir.add_attribute("units","W m-2"); - nc_sw_flux_net.add_attribute("long_name","Net shortwave fluxes (TwoStream solver)"); - nc_sw_flux_net.add_attribute("units","W m-2"); + nc_sw_flux_net.add_attribute("long_name","Net shortwave fluxes (TwoStream solver)"); + nc_sw_flux_net.add_attribute("units","W m-2"); + } if (switch_raytracing) { @@ -979,27 +993,30 @@ void solve_radiation(int argc, char** argv) if (switch_single_gpt) { - auto nc_sw_gpt_flux_up = output_nc.add_variable("sw_gpt_flux_up" , {"lev", "y", "x"}); - auto nc_sw_gpt_flux_dn = output_nc.add_variable("sw_gpt_flux_dn" , {"lev", "y", "x"}); - auto nc_sw_gpt_flux_dn_dir = output_nc.add_variable("sw_gpt_flux_dn_dir", {"lev", "y", "x"}); - auto nc_sw_gpt_flux_net = output_nc.add_variable("sw_gpt_flux_net" , {"lev", "y", "x"}); - - nc_sw_gpt_flux_up .insert(sw_gpt_flux_up_cpu .v(), {0, 0, 0}); - nc_sw_gpt_flux_dn .insert(sw_gpt_flux_dn_cpu .v(), {0, 0, 0}); - nc_sw_gpt_flux_dn_dir.insert(sw_gpt_flux_dn_dir_cpu.v(), {0, 0, 0}); - nc_sw_gpt_flux_net .insert(sw_gpt_flux_net_cpu .v(), {0, 0, 0}); - - nc_sw_gpt_flux_up.add_attribute("long_name","Upwelling shortwave fluxes for g-point "+std::to_string(single_gpt)+" (TwoStream solver)"); - nc_sw_gpt_flux_up.add_attribute("units","W m-2"); - - nc_sw_gpt_flux_dn.add_attribute("long_name","Downwelling shortwave fluxes for g-point "+std::to_string(single_gpt)+" (TwoStream solver)"); - nc_sw_gpt_flux_dn.add_attribute("units","W m-2"); - - nc_sw_gpt_flux_dn_dir.add_attribute("long_name","Downwelling direct shortwave fluxes for g-point "+std::to_string(single_gpt)+" (TwoStream solver)"); - nc_sw_gpt_flux_dn_dir.add_attribute("units","W m-2"); - - nc_sw_gpt_flux_net.add_attribute("long_name","Net shortwave fluxes for g-point "+std::to_string(single_gpt)+" (TwoStream solver)"); - nc_sw_gpt_flux_net.add_attribute("units","W m-2"); + if(!switch_disable_2s) + { + auto nc_sw_gpt_flux_up = output_nc.add_variable("sw_gpt_flux_up" , {"lev", "y", "x"}); + auto nc_sw_gpt_flux_dn = output_nc.add_variable("sw_gpt_flux_dn" , {"lev", "y", "x"}); + auto nc_sw_gpt_flux_dn_dir = output_nc.add_variable("sw_gpt_flux_dn_dir", {"lev", "y", "x"}); + auto nc_sw_gpt_flux_net = output_nc.add_variable("sw_gpt_flux_net" , {"lev", "y", "x"}); + + nc_sw_gpt_flux_up .insert(sw_gpt_flux_up_cpu .v(), {0, 0, 0}); + nc_sw_gpt_flux_dn .insert(sw_gpt_flux_dn_cpu .v(), {0, 0, 0}); + nc_sw_gpt_flux_dn_dir.insert(sw_gpt_flux_dn_dir_cpu.v(), {0, 0, 0}); + nc_sw_gpt_flux_net .insert(sw_gpt_flux_net_cpu .v(), {0, 0, 0}); + + nc_sw_gpt_flux_up.add_attribute("long_name","Upwelling shortwave fluxes for g-point "+std::to_string(single_gpt)+" (TwoStream solver)"); + nc_sw_gpt_flux_up.add_attribute("units","W m-2"); + + nc_sw_gpt_flux_dn.add_attribute("long_name","Downwelling shortwave fluxes for g-point "+std::to_string(single_gpt)+" (TwoStream solver)"); + nc_sw_gpt_flux_dn.add_attribute("units","W m-2"); + + nc_sw_gpt_flux_dn_dir.add_attribute("long_name","Downwelling direct shortwave fluxes for g-point "+std::to_string(single_gpt)+" (TwoStream solver)"); + nc_sw_gpt_flux_dn_dir.add_attribute("units","W m-2"); + + nc_sw_gpt_flux_net.add_attribute("long_name","Net shortwave fluxes for g-point "+std::to_string(single_gpt)+" (TwoStream solver)"); + nc_sw_gpt_flux_net.add_attribute("units","W m-2"); + } } } }