Skip to content

Commit

Permalink
Pass grid to add_tracer(), get layout and grid_name from grid
Browse files Browse the repository at this point in the history
  • Loading branch information
tcclevenger committed Oct 24, 2024
1 parent 748ecc2 commit 9c2b2e4
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void SurfaceCouplingExporter::set_grids(const std::shared_ptr<const GridsManager
add_field<Required>("pseudo_density", scalar3d_layout_mid, Pa, grid_name, ps);
add_field<Required>("phis", scalar2d_layout, m2/s2, grid_name);
add_field<Required>("p_mid", scalar3d_layout_mid, Pa, grid_name, ps);
add_tracer<Required>("qv", scalar3d_layout_mid, kg/kg, grid_name, ps);
add_field<Required>("T_mid", scalar3d_layout_mid, K, grid_name, ps);
add_tracer<Required>("qv", m_grid, kg/kg, ps);
// TODO: Switch horiz_winds to using U and V, note right now there is an issue with when the subfields are created, so can't switch yet.
add_field<Required>("horiz_winds", vector3d_layout, m/s, grid_name);
add_field<Required>("sfc_flux_dir_nir", scalar2d_layout, W/m2, grid_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void HommeDynamics::set_grids (const std::shared_ptr<const GridsManager> grids_m
add_field<Computed>("p_dry_mid", pg_scalar3d_mid, Pa, pgn,N);
add_field<Computed>("omega", pg_scalar3d_mid, Pa/s, pgn,N);

add_tracer<Updated >("qv", pg_scalar3d_mid, kg/kg, pgn, N);
add_tracer<Updated >("qv", m_phys_grid, kg/kg, N);
add_group<Updated>("tracers",pgn,N, Bundling::Required);

if (fv_phys_active()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void CldFraction::set_grids(const std::shared_ptr<const GridsManager> grids_mana

// Set of fields used strictly as input
constexpr int ps = Pack::n;
add_tracer<Required>("qi", scalar3d_layout_mid, kg/kg, grid_name, ps);
add_tracer<Required>("qi", m_grid, kg/kg, ps);
add_field<Required>("cldfrac_liq", scalar3d_layout_mid, nondim, grid_name,ps);

// Set of fields used strictly as output
Expand Down
6 changes: 3 additions & 3 deletions components/eamxx/src/physics/cosp/eamxx_cosp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ void Cosp::set_grids(const std::shared_ptr<const GridsManager> grids_manager)
add_field<Required>("phis", scalar2d , m2/s2, grid_name);
add_field<Required>("pseudo_density", scalar3d_mid, Pa, grid_name);
add_field<Required>("cldfrac_rad", scalar3d_mid, nondim, grid_name);
add_tracer<Required>("qv", scalar3d_mid, kg/kg, grid_name);
add_tracer<Required>("qc", scalar3d_mid, kg/kg, grid_name);
add_tracer<Required>("qi", scalar3d_mid, kg/kg, grid_name);
add_tracer<Required>("qv", m_grid, kg/kg);
add_tracer<Required>("qc", m_grid, kg/kg);
add_tracer<Required>("qi", m_grid, kg/kg);
// Optical properties, should be computed in radiation interface
add_field<Required>("dtau067", scalar3d_mid, nondim, grid_name); // 0.67 micron optical depth
add_field<Required>("dtau105", scalar3d_mid, nondim, grid_name); // 10.5 micron optical depth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,19 @@ void MAMAci::set_grids(

// atmospheric quantities
// specific humidity [kg/kg]
add_tracer<Required>("qv", scalar3d_layout_mid, q_unit, grid_name);
add_tracer<Required>("qv", grid_, q_unit);

// cloud liquid mass mixing ratio [kg/kg]
add_tracer<Required>("qc", scalar3d_layout_mid, q_unit, grid_name);
add_tracer<Required>("qc", grid_, q_unit);

// cloud ice mass mixing ratio [kg/kg]
add_tracer<Required>("qi", scalar3d_layout_mid, q_unit, grid_name);
add_tracer<Required>("qi", grid_, q_unit);

// cloud liquid number mixing ratio [1/kg]
add_tracer<Required>("nc", scalar3d_layout_mid, n_unit, grid_name);
add_tracer<Required>("nc", grid_, n_unit);

// cloud ice number mixing ratio [1/kg]
add_tracer<Required>("ni", scalar3d_layout_mid, n_unit, grid_name);
add_tracer<Required>("ni", grid_, n_unit);

// Temperature[K] at midpoints
add_field<Required>("T_mid", scalar3d_layout_mid, K, grid_name);
Expand Down Expand Up @@ -164,8 +164,7 @@ void MAMAci::set_grids(
// interstitial aerosol tracers of interest: number (n) mixing ratios
const char *int_nmr_field_name =
mam_coupling::int_aero_nmr_field_name(mode);
add_tracer<Updated>(int_nmr_field_name, scalar3d_layout_mid, n_unit,
grid_name);
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit);

// cloudborne aerosol tracers of interest: number (n) mixing ratios
// NOTE: DO NOT add cld borne aerosols to the "tracer" group as these are
Expand All @@ -180,8 +179,7 @@ void MAMAci::set_grids(
const char *int_mmr_field_name =
mam_coupling::int_aero_mmr_field_name(mode, a);
if(strlen(int_mmr_field_name) > 0) {
add_tracer<Updated>(int_mmr_field_name, scalar3d_layout_mid, q_unit,
grid_name);
add_tracer<Updated>(int_mmr_field_name, grid_, q_unit);
}
// (cloudborne) aerosol tracers of interest: mass (q) mixing ratios
// NOTE: DO NOT add cld borne aerosols to the "tracer" group as these are
Expand All @@ -197,8 +195,7 @@ void MAMAci::set_grids(

for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) {
const char *gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g);
add_tracer<Updated>(gas_mmr_field_name, scalar3d_layout_mid, q_unit,
grid_name);
add_tracer<Updated>(gas_mmr_field_name, grid_, q_unit);
} // end for loop num gases

// ------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ void MAMConstituentFluxes::set_grids(
// --------------------------------------------------------------------------
// ----------- Atmospheric quantities -------------
// Specific humidity [kg/kg](Require only for building DS)
add_tracer<Required>("qv", scalar3d_mid, q_unit, grid_name);
add_tracer<Required>("qv", grid_, q_unit);

// Cloud liquid mass mixing ratio [kg/kg](Require only for building DS)
add_tracer<Required>("qc", scalar3d_mid, q_unit, grid_name);
add_tracer<Required>("qc", grid_, q_unit);

// Cloud ice mass mixing ratio [kg/kg](Require only for building DS)
add_tracer<Required>("qi", scalar3d_mid, q_unit, grid_name);
add_tracer<Required>("qi", grid_, q_unit);

// Cloud liquid number mixing ratio [1/kg](Require only for building DS)
add_tracer<Required>("nc", scalar3d_mid, n_unit, grid_name);
add_tracer<Required>("nc", grid_, n_unit);

// Cloud ice number mixing ratio [1/kg](Require only for building DS)
add_tracer<Required>("ni", scalar3d_mid, n_unit, grid_name);
add_tracer<Required>("ni", grid_, n_unit);

// Temperature[K] at midpoints
add_field<Required>("T_mid", scalar3d_mid, K, grid_name);
Expand Down Expand Up @@ -102,7 +102,7 @@ void MAMConstituentFluxes::set_grids(
// interstitial aerosol tracers of interest: number (n) mixing ratios
const std::string int_nmr_field_name =
mam_coupling::int_aero_nmr_field_name(mode);
add_tracer<Updated>(int_nmr_field_name, scalar3d_mid, n_unit, grid_name);
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit);

// cloudborne aerosol tracers of interest: number (n) mixing ratios
// NOTE: DO NOT add cld borne aerosols to the "tracer" group as these are
Expand All @@ -116,7 +116,7 @@ void MAMConstituentFluxes::set_grids(
const std::string int_mmr_field_name =
mam_coupling::int_aero_mmr_field_name(mode, a);
if(not int_mmr_field_name.empty()) {
add_tracer<Updated>(int_mmr_field_name, scalar3d_mid, q_unit, grid_name);
add_tracer<Updated>(int_mmr_field_name, grid_, q_unit);
}
// (cloudborne) aerosol tracers of interest: mass (q) mixing ratios
// NOTE: DO NOT add cld borne aerosols to the "tracer" group as these are
Expand All @@ -131,7 +131,7 @@ void MAMConstituentFluxes::set_grids(

for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) {
const std::string gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g);
add_tracer<Updated>(gas_mmr_field_name, scalar3d_mid, q_unit, grid_name);
add_tracer<Updated>(gas_mmr_field_name, grid_, q_unit);
} // end for loop num gases

} // set_grid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ void MAMDryDep::set_grids(

// ----------- Atmospheric quantities -------------
// Specific humidity [kg/kg](Require only for building DS)
add_tracer<Required>("qv", scalar3d_mid, q_unit, grid_name);
add_tracer<Required>("qv", grid_, q_unit);

// Cloud liquid mass mixing ratio [kg/kg](Require only for building DS)
add_tracer<Required>("qc", scalar3d_mid, q_unit, grid_name);
add_tracer<Required>("qc", grid_, q_unit);

// Cloud ice mass mixing ratio [kg/kg](Require only for building DS)
add_tracer<Required>("qi", scalar3d_mid, q_unit, grid_name);
add_tracer<Required>("qi", grid_, q_unit);

// Cloud liquid number mixing ratio [1/kg](Require only for building DS)
add_tracer<Required>("nc", scalar3d_mid, n_unit, grid_name);
add_tracer<Required>("nc", grid_, n_unit);

// Cloud ice number mixing ratio [1/kg](Require only for building DS)
add_tracer<Required>("ni", scalar3d_mid, n_unit, grid_name);
add_tracer<Required>("ni", grid_, n_unit);

// Temperature[K] at midpoints
add_field<Required>("T_mid", scalar3d_mid, K, grid_name);
Expand Down Expand Up @@ -158,13 +158,13 @@ void MAMDryDep::set_grids(
for(int m = 0; m < num_aero_modes; ++m) {
const char *int_nmr_field_name = mam_coupling::int_aero_nmr_field_name(m);

add_tracer<Updated>(int_nmr_field_name, scalar3d_mid, n_unit, grid_name);
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit);
for(int a = 0; a < mam_coupling::num_aero_species(); ++a) {
const char *int_mmr_field_name =
mam_coupling::int_aero_mmr_field_name(m, a);

if(strlen(int_mmr_field_name) > 0) {
add_tracer<Updated>(int_mmr_field_name, scalar3d_mid, q_unit, grid_name);
add_tracer<Updated>(int_mmr_field_name, grid_, q_unit);
}
}
}
Expand All @@ -186,7 +186,7 @@ void MAMDryDep::set_grids(
// aerosol-related gases: mass mixing ratios
for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) {
const char *gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g);
add_tracer<Updated>(gas_mmr_field_name, scalar3d_mid, q_unit, grid_name);
add_tracer<Updated>(gas_mmr_field_name, grid_, q_unit);
}

// -------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,34 +122,34 @@ void MAMMicrophysics::set_grids(const std::shared_ptr<const GridsManager> grids_
add_field<Required>("omega", scalar3d_layout_mid, Pa/s, grid_name); // vertical pressure velocity
add_field<Required>("T_mid", scalar3d_layout_mid, K, grid_name); // Temperature
add_field<Required>("p_mid", scalar3d_layout_mid, Pa, grid_name); // total pressure
add_tracer<Required>("qv", scalar3d_layout_mid, kg/kg, grid_name); // specific humidity
add_tracer<Required>("qi", scalar3d_layout_mid, kg/kg, grid_name); // ice wet mixing ratio
add_tracer<Required>("ni", scalar3d_layout_mid, n_unit, grid_name); // ice number mixing ratio
add_field<Required>("pbl_height", scalar2d_layout_col, m, grid_name); // planetary boundary layer height
add_field<Required>("pseudo_density", scalar3d_layout_mid, Pa, grid_name); // p_del, hydrostatic pressure
add_field<Required>("phis", scalar2d_layout_col, m2/s2, grid_name);
add_field<Required>("cldfrac_tot", scalar3d_layout_mid, nondim, grid_name); // cloud fraction
add_tracer<Required>("qv", grid_, kg/kg); // specific humidity
add_tracer<Required>("qi", grid_, kg/kg); // ice wet mixing ratio
add_tracer<Required>("ni", grid_, n_unit); // ice number mixing ratio

// droplet activation can alter cloud liquid and number mixing ratios
add_tracer<Updated>("qc", scalar3d_layout_mid, kg/kg, grid_name); // cloud liquid wet mixing ratio
add_tracer<Updated>("nc", scalar3d_layout_mid, n_unit, grid_name); // cloud liquid wet number mixing ratio
add_tracer<Updated>("qc", grid_, kg/kg); // cloud liquid wet mixing ratio
add_tracer<Updated>("nc", grid_, n_unit); // cloud liquid wet number mixing ratio

// (interstitial) aerosol tracers of interest: mass (q) and number (n) mixing ratios
for (int m = 0; m < mam_coupling::num_aero_modes(); ++m) {
const char* int_nmr_field_name = mam_coupling::int_aero_nmr_field_name(m);
add_tracer<Updated>(int_nmr_field_name, scalar3d_layout_mid, n_unit, grid_name);
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit);
for (int a = 0; a < mam_coupling::num_aero_species(); ++a) {
const char* int_mmr_field_name = mam_coupling::int_aero_mmr_field_name(m, a);
if (strlen(int_mmr_field_name) > 0) {
add_tracer<Updated>(int_mmr_field_name, scalar3d_layout_mid, kg/kg, grid_name);
add_tracer<Updated>(int_mmr_field_name, grid_, kg/kg);
}
}
}

// aerosol-related gases: mass mixing ratios
for (int g = 0; g < mam_coupling::num_aero_gases(); ++g) {
const char* gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g);
add_tracer<Updated>(gas_mmr_field_name, scalar3d_layout_mid, kg/kg, grid_name);
add_tracer<Updated>(gas_mmr_field_name, grid_, kg/kg);
}

// Tracers group -- do we need this in addition to the tracers above? In any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ void MAMOptics::set_grids(
add_field<Required>("p_int", scalar3d_int, Pa, grid_name); // total pressure
add_field<Required>("pseudo_density", scalar3d_mid, Pa, grid_name);
add_field<Required>("pseudo_density_dry", scalar3d_mid, Pa, grid_name);
add_tracer<Required>("qv", scalar3d_mid, kg/kg, grid_name); // specific humidity
add_tracer<Required>("qi", scalar3d_mid, kg/kg, grid_name); // ice wet mixing ratio
add_tracer<Required>("ni", scalar3d_mid, n_unit, grid_name); // ice number mixing ratio
add_tracer<Required>("qv", grid_, kg/kg); // specific humidity
add_tracer<Required>("qi", grid_, kg/kg); // ice wet mixing ratio
add_tracer<Required>("ni", grid_, n_unit); // ice number mixing ratio

// droplet activation can alter cloud liquid and number mixing ratios
add_tracer<Required>("qc", scalar3d_mid, kg/kg, grid_name); // cloud liquid wet mixing ratio
add_tracer<Required>("nc", scalar3d_mid, n_unit, grid_name); // cloud liquid wet number mixing ratio
add_tracer<Required>("qc", grid_, kg/kg); // cloud liquid wet mixing ratio
add_tracer<Required>("nc", grid_, n_unit); // cloud liquid wet number mixing ratio

add_field<Required>("phis", scalar2d, m2 / s2, grid_name);
add_field<Required>("cldfrac_tot", scalar3d_mid, nondim,grid_name); // cloud fraction
Expand All @@ -86,12 +86,12 @@ void MAMOptics::set_grids(
for(int m = 0; m < mam_coupling::num_aero_modes(); ++m) {
const char *int_nmr_field_name = mam_coupling::int_aero_nmr_field_name(m);

add_tracer<Updated>(int_nmr_field_name, scalar3d_mid, n_unit,grid_name);
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit);
for(int a = 0; a < mam_coupling::num_aero_species(); ++a) {
const char *int_mmr_field_name = mam_coupling::int_aero_mmr_field_name(m, a);

if(strlen(int_mmr_field_name) > 0) {
add_tracer<Updated>(int_mmr_field_name, scalar3d_mid, kg/kg,grid_name);
add_tracer<Updated>(int_mmr_field_name, grid_, kg/kg);
}
}
}
Expand All @@ -113,7 +113,7 @@ void MAMOptics::set_grids(
// aerosol-related gases: mass mixing ratios
for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) {
const char *gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g);
add_tracer<Updated>(gas_mmr_field_name, scalar3d_mid, kg/kg, grid_name);
add_tracer<Updated>(gas_mmr_field_name, grid_, kg/kg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ void MAMWetscav::set_grids(

// ----------- Atmospheric quantities -------------
// Specific humidity [kg/kg]
add_tracer<Required>("qv", scalar3d_mid, q_unit, grid_name);
add_tracer<Required>("qv", m_grid, q_unit);

// cloud liquid mass mixing ratio [kg/kg]
add_tracer<Required>("qc", scalar3d_mid, q_unit, grid_name);
add_tracer<Required>("qc", m_grid, q_unit);

// cloud ice mass mixing ratio [kg/kg]
add_tracer<Required>("qi", scalar3d_mid, q_unit, grid_name);
add_tracer<Required>("qi", m_grid, q_unit);

// cloud liquid number mixing ratio [1/kg]
add_tracer<Required>("nc", scalar3d_mid, n_unit, grid_name);
add_tracer<Required>("nc", m_grid, n_unit);

// cloud ice number mixing ratio [1/kg]
add_tracer<Required>("ni", scalar3d_mid, n_unit, grid_name);
add_tracer<Required>("ni", m_grid, n_unit);

// Temperature[K] at midpoints
add_field<Required>("T_mid", scalar3d_mid, K, grid_name);
Expand Down Expand Up @@ -161,7 +161,7 @@ void MAMWetscav::set_grids(
// interstitial aerosol tracers of interest: number (n) mixing ratios
const char *int_nmr_field_name =
mam_coupling::int_aero_nmr_field_name(imode);
add_tracer<Updated>(int_nmr_field_name, scalar3d_mid, n_unit, grid_name);
add_tracer<Updated>(int_nmr_field_name, m_grid, n_unit);

// cloudborne aerosol tracers of interest: number (n) mixing ratios
// Note: Do *not* add cld borne aerosols to the "tracer" group as these are
Expand All @@ -176,7 +176,7 @@ void MAMWetscav::set_grids(
const char *int_mmr_field_name =
mam_coupling::int_aero_mmr_field_name(imode, ispec);
if(strlen(int_mmr_field_name) > 0) {
add_tracer<Updated>(int_mmr_field_name, scalar3d_mid, q_unit, grid_name);
add_tracer<Updated>(int_mmr_field_name, m_grid, q_unit);
}

// (cloudborne) aerosol tracers of interest: mass (q) mixing ratios
Expand All @@ -196,7 +196,7 @@ void MAMWetscav::set_grids(
// aerosol-related gases: mass mixing ratios
for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) {
const char *gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g);
add_tracer<Updated>(gas_mmr_field_name, scalar3d_mid, q_unit, grid_name);
add_tracer<Updated>(gas_mmr_field_name, m_grid, q_unit);
}

// -------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void MLCorrection::set_grids(
add_field<Updated>("precip_liq_surf_mass", scalar2d, kg/m2, grid_name);
add_field<Updated>("precip_ice_surf_mass", scalar2d, kg/m2, grid_name);
/* ----------------------- WARNING --------------------------------*/
add_tracer<Updated>("qv", scalar3d_mid, kg/kg, grid_name, ps);
add_tracer<Updated>("qv", m_grid, kg/kg, ps);
add_group<Updated>("tracers", grid_name, 1, Bundling::Required);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void Nudging::set_grids(const std::shared_ptr<const GridsManager> grids_manager)
add_field<Updated>("T_mid", scalar3d_layout_mid, K, grid_name, ps);
}
if (ekat::contains(m_fields_nudge,"qv")) {
add_tracer<Updated>("qv", scalar3d_layout_mid, kg/kg, grid_name, ps);
add_tracer<Updated>("qv", m_grid, kg/kg, ps);
}
if (ekat::contains(m_fields_nudge,"U") or ekat::contains(m_fields_nudge,"V")) {
add_field<Updated>("horiz_winds", horiz_wind_layout, m/s, grid_name, ps);
Expand Down
Loading

0 comments on commit 9c2b2e4

Please sign in to comment.