Skip to content

Commit

Permalink
Merge branch 'brhillman/eam/use-reduced-rrtmgp-gpoints' (#5196)
Browse files Browse the repository at this point in the history
Use reduced g-point data when using RRTMGP in EAM and E3SM-MMF. This should half the cost of RRTMGP in E3SM and bring performance in line with RRTMG, which was already using a similar number of quadrature points. This will be non-BFB only for the tests that use RRTMGP (eam-rrtmgp/eam-rrtmgpxx testmods, and all of the MMF tests), but BFB for all other tests.

[non-BFB] for RRTMGP tests
  • Loading branch information
brhillman committed Oct 18, 2022
2 parents 9f0094d + c348a85 commit 0fedbb1
Show file tree
Hide file tree
Showing 5 changed files with 368 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/eam/bld/configure
Original file line number Diff line number Diff line change
Expand Up @@ -2617,14 +2617,14 @@ sub write_filepath
} elsif ($rad eq 'rrtmgp') {
print $fh "$camsrcdir/eam/src/physics/rrtmgp\n";
if (not defined $opts{'rrtmgpxx'} ) {
print $fh "$camsrcdir/eam/src/physics/rrtmgp/f90\n";
print $fh "$camsrcdir/eam/src/physics/rrtmgp/external/rte\n";
print $fh "$camsrcdir/eam/src/physics/rrtmgp/external/rte/kernels\n";
print $fh "$camsrcdir/eam/src/physics/rrtmgp/external/rrtmgp\n";
print $fh "$camsrcdir/eam/src/physics/rrtmgp/external/rrtmgp/kernels\n";
print $fh "$camsrcdir/eam/src/physics/rrtmgp/external/extensions\n";
print $fh "$camsrcdir/eam/src/physics/rrtmgp/external/extensions/rng\n";
print $fh "$camsrcdir/eam/src/physics/rrtmgp/external/examples\n";
print $fh "$camsrcdir/eam/src/physics/rrtmgp/f90\n";
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/eam/bld/namelist_files/namelist_defaults_eam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@
<liqopticsfile rad="rrtmgp">atm/cam/physprops/F_nwvl200_mu20_lam50_res64_t298_c080428.nc</liqopticsfile>

<!-- Gas absorption coefficients for RRTMGP -->
<rrtmgp_coefficients_file_lw rad="rrtmgp">atm/cam/rad/rrtmgp_coefficients_lw_20181204.nc</rrtmgp_coefficients_file_lw>
<rrtmgp_coefficients_file_sw rad="rrtmgp">atm/cam/rad/rrtmgp_coefficients_sw_20181204.nc</rrtmgp_coefficients_file_sw>
<rrtmgp_coefficients_file_lw rad="rrtmgp">atm/cam/rad/rrtmgp-data-lw-g128-210809.nc</rrtmgp_coefficients_file_lw>
<rrtmgp_coefficients_file_sw rad="rrtmgp">atm/cam/rad/rrtmgp-data-sw-g112-210809.nc</rrtmgp_coefficients_file_sw>

<rrtmgp_enable_temperature_warnings rad="rrtmgp" >.true.</rrtmgp_enable_temperature_warnings>
<rrtmgp_enable_temperature_warnings rad="rrtmgp" aquaplanet="1">.false.</rrtmgp_enable_temperature_warnings>
Expand Down
2 changes: 1 addition & 1 deletion components/eam/src/physics/rrtmgp/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
set (F90_SRC rrtmgp_interface.F90)
set (CXX_SRC
rrtmgp_interface.cpp
mo_load_coefficients.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../external/cpp/extensions/fluxes_byband/mo_fluxes_byband_kernels.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../external/cpp/examples/mo_load_coefficients.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../external/cpp/examples/all-sky/mo_load_cloud_coefficients.cpp
)

Expand Down
123 changes: 123 additions & 0 deletions components/eam/src/physics/rrtmgp/cpp/mo_load_coefficients.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@

#include "mo_load_coefficients.h"
#include "YAKL_netcdf.h"

// This code is part of RRTM for GCM Applications - Parallel (RRTMGP)
//
// Contacts: Robert Pincus and Eli Mlawer
// email: rrtmgp@aer.com
//
// Copyright 2015-2018, Atmospheric and Environmental Research and
// Regents of the University of Colorado. All right reserved.
//
// Use and duplication is permitted under the terms of the
// BSD 3-clause license, see http://opensource.org/licenses/BSD-3-Clause
// -------------------------------------------------------------------------------------------------

void load_and_init(GasOpticsRRTMGP &kdist, std::string filename, GasConcs const &available_gases) {
yakl::SimpleNetCDF io;
io.open(filename , yakl::NETCDF_MODE_READ);

// Read the many arrays
string1d gas_names;
string1d gas_minor;
string1d identifier_minor;
string1d minor_gases_lower;
string1d minor_gases_upper;
string1d scaling_gas_lower;
string1d scaling_gas_upper;
intHost3d key_species;
realHost2d band_lims;
intHost2d band2gpt;
real press_ref_trop;
real temp_ref_p;
real temp_ref_t;
realHost1d press_ref;
realHost1d temp_ref;
realHost3d vmr_ref;
realHost4d kmajor;
intHost2d minor_limits_gpt_lower;
intHost2d minor_limits_gpt_upper;
boolHost1d minor_scales_with_density_lower;
boolHost1d minor_scales_with_density_upper;
boolHost1d scale_by_complement_lower;
boolHost1d scale_by_complement_upper;
intHost1d kminor_start_lower;
intHost1d kminor_start_upper;
realHost3d kminor_lower;
realHost3d kminor_upper;
realHost3d rayl_lower;
realHost3d rayl_upper;

// Read in strings
charHost2d tmp;
tmp = charHost2d(); io.read( tmp , "gas_names" ); gas_names = char2d_to_string1d(tmp);
tmp = charHost2d(); io.read( tmp , "gas_minor" ); gas_minor = char2d_to_string1d(tmp);
tmp = charHost2d(); io.read( tmp , "identifier_minor" ); identifier_minor = char2d_to_string1d(tmp);
tmp = charHost2d(); io.read( tmp , "minor_gases_lower" ); minor_gases_lower = char2d_to_string1d(tmp);
tmp = charHost2d(); io.read( tmp , "minor_gases_upper" ); minor_gases_upper = char2d_to_string1d(tmp);
tmp = charHost2d(); io.read( tmp , "scaling_gas_lower" ); scaling_gas_lower = char2d_to_string1d(tmp);
tmp = charHost2d(); io.read( tmp , "scaling_gas_upper" ); scaling_gas_upper = char2d_to_string1d(tmp);

io.read( key_species , "key_species" );
io.read( band_lims , "bnd_limits_wavenumber" );
io.read( band2gpt , "bnd_limits_gpt" );
io.read( press_ref , "press_ref" );
io.read( temp_ref , "temp_ref" );
io.read( temp_ref_p , "absorption_coefficient_ref_P" );
io.read( temp_ref_t , "absorption_coefficient_ref_T" );
io.read( press_ref_trop , "press_ref_trop" );
io.read( kminor_lower , "kminor_lower" );
io.read( kminor_upper , "kminor_upper" );
io.read( minor_limits_gpt_lower , "minor_limits_gpt_lower" );
io.read( minor_limits_gpt_upper , "minor_limits_gpt_upper" );
io.read( minor_scales_with_density_lower , "minor_scales_with_density_lower" );
io.read( minor_scales_with_density_upper , "minor_scales_with_density_upper" );
io.read( scale_by_complement_lower , "scale_by_complement_lower" );
io.read( scale_by_complement_upper , "scale_by_complement_upper" );
io.read( kminor_start_lower , "kminor_start_lower" );
io.read( kminor_start_upper , "kminor_start_upper" );
io.read( vmr_ref , "vmr_ref" );
io.read( kmajor , "kmajor" );

if (io.varExists("rayl_lower")) {
io.read( rayl_lower , "rayl_lower" );
io.read( rayl_upper , "rayl_upper" );
}

// Initialize the gas optics class with data. The calls look slightly different depending
// on whether the radiation sources are internal to the atmosphere (longwave) or external (shortwave)
// gas_optics%load() returns a string; a non-empty string indicates an error.
if (io.varExists("totplnk")) {
// If there's a totplnk variable in the file, then it's a longwave (internal sources) type
realHost2d totplnk;
realHost4d planck_frac;
io.read( totplnk , "totplnk" );
io.read( planck_frac , "plank_fraction" );
kdist.load(available_gases, gas_names, key_species, band2gpt, band_lims, press_ref, press_ref_trop,
temp_ref, temp_ref_p, temp_ref_t, vmr_ref, kmajor, kminor_lower, kminor_upper,
gas_minor, identifier_minor, minor_gases_lower, minor_gases_upper,
minor_limits_gpt_lower, minor_limits_gpt_upper, minor_scales_with_density_lower,
minor_scales_with_density_upper, scaling_gas_lower, scaling_gas_upper,
scale_by_complement_lower, scale_by_complement_upper, kminor_start_lower,
kminor_start_upper, totplnk, planck_frac, rayl_lower, rayl_upper);
} else {
// Otherwise, it's a shortwave type
realHost1d solar_src;
if (io.varExists("solar_source")) {
io.read( solar_src , "solar_source" );
} else {
io.read( solar_src , "solar_source_quiet" );
}
kdist.load(available_gases, gas_names, key_species, band2gpt, band_lims, press_ref, press_ref_trop,
temp_ref, temp_ref_p, temp_ref_t, vmr_ref, kmajor, kminor_lower, kminor_upper,
gas_minor, identifier_minor, minor_gases_lower, minor_gases_upper,
minor_limits_gpt_lower, minor_limits_gpt_upper, minor_scales_with_density_lower,
minor_scales_with_density_upper, scaling_gas_lower, scaling_gas_upper,
scale_by_complement_lower, scale_by_complement_upper, kminor_start_lower,
kminor_start_upper, solar_src, rayl_lower, rayl_upper);
}
io.close();
}


Loading

0 comments on commit 0fedbb1

Please sign in to comment.