Skip to content

Commit 713aa2d

Browse files
committed
Allow for not advecting tracers in shoc
1 parent 776a79a commit 713aa2d

19 files changed

+169
-85
lines changed

components/eamxx/src/control/atmosphere_driver.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,66 @@ void AtmosphereDriver::create_fields()
534534
m_field_mgrs[grid->name()]->registration_begins();
535535
}
536536

537+
// Before registering fields, check that Field Requests for tracers are compatible
538+
{
539+
// Create map from tracer name to a vector which contains the field requests for that tracer.
540+
std::map<std::string, std::vector<FieldRequest>> tracer_requests;
541+
auto gather_tracer_requests = [&] (FieldRequest req) {
542+
if (std::find(req.groups.begin(),
543+
req.groups.end(),
544+
"tracers") == req.groups.end()) return;
545+
546+
std::string fname = req.fid.name();
547+
if (tracer_requests.find(fname) == tracer_requests.end()) {
548+
tracer_requests[fname] = std::vector<FieldRequest>(1, req);
549+
} else {
550+
tracer_requests[fname].push_back(req);
551+
}
552+
};
553+
for (const auto& req : m_atm_process_group->get_required_field_requests()){
554+
gather_tracer_requests(req);
555+
}
556+
for (const auto& req : m_atm_process_group->get_computed_field_requests()) {
557+
gather_tracer_requests(req);
558+
}
559+
560+
// Go through the map entry for each tracer and check that every one
561+
// has the same request for turbulence advection.
562+
for (auto fr : tracer_requests) {
563+
bool mismatch_found = false;
564+
565+
const auto reqs = fr.second;
566+
const bool is_first_turb_advect =
567+
std::find(reqs.front().groups.begin(),
568+
reqs.front().groups.end(),
569+
"turbulence_advected_tracers") != reqs.front().groups.end();
570+
for (size_t i=1; i<reqs.size(); ++i) {
571+
const bool is_turb_advect =
572+
std::find(reqs[i].groups.begin(),
573+
reqs[i].groups.end(),
574+
"turbulence_advected_tracers") != reqs[i].groups.end();
575+
if (is_turb_advect != is_first_turb_advect) {
576+
mismatch_found = true;
577+
break;
578+
}
579+
}
580+
if (mismatch_found) {
581+
std::ostringstream ss;
582+
ss << "Error! Incompatible tracer request. Turbulence advection requests not consistent among processes.\n"
583+
" - Tracer name: " + fr.first + "\n"
584+
" - Requests (process name, grid name, is tracers turbulence advected):\n";
585+
for (auto req : reqs) {
586+
const auto grid_name = req.fid.get_grid_name();
587+
const bool turb_advect = std::find(req.groups.begin(),
588+
req.groups.end(),
589+
"turbulence_advected_tracers") != req.groups.end();
590+
ss << " - (" + req.calling_process + ", " + grid_name + ", " + (turb_advect ? "true" : "false") + ")\n";
591+
}
592+
EKAT_ERROR_MSG(ss.str());
593+
}
594+
}
595+
}
596+
537597
// Register required/computed fields
538598
for (const auto& req : m_atm_process_group->get_required_field_requests()) {
539599
m_field_mgrs.at(req.fid.get_grid_name())->register_field(req);

components/eamxx/src/control/atmosphere_surface_coupling_exporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void SurfaceCouplingExporter::set_grids(const std::shared_ptr<const GridsManager
4444
add_field<Required>("phis", scalar2d_layout, m2/s2, grid_name);
4545
add_field<Required>("p_mid", scalar3d_layout_mid, Pa, grid_name, ps);
4646
add_field<Required>("T_mid", scalar3d_layout_mid, K, grid_name, ps);
47-
add_tracer<Required>("qv", m_grid, kg/kg, ps);
47+
add_tracer<Required>("qv", m_grid, kg/kg, true, ps);
4848
// 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.
4949
add_field<Required>("horiz_winds", vector3d_layout, m/s, grid_name);
5050
add_field<Required>("sfc_flux_dir_nir", scalar2d_layout, W/m2, grid_name);

components/eamxx/src/dynamics/homme/eamxx_homme_process_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void HommeDynamics::set_grids (const std::shared_ptr<const GridsManager> grids_m
179179
add_field<Computed>("p_dry_mid", pg_scalar3d_mid, Pa, pgn,N);
180180
add_field<Computed>("omega", pg_scalar3d_mid, Pa/s, pgn,N);
181181

182-
add_tracer<Updated >("qv", m_phys_grid, kg/kg, N);
182+
add_tracer<Updated >("qv", m_phys_grid, kg/kg, true, N);
183183
add_group<Updated>("tracers",pgn,N, Bundling::Required);
184184

185185
if (fv_phys_active()) {

components/eamxx/src/physics/cld_fraction/eamxx_cld_fraction_process_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void CldFraction::set_grids(const std::shared_ptr<const GridsManager> grids_mana
3838

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

4444
// Set of fields used strictly as output

components/eamxx/src/physics/cosp/eamxx_cosp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ void Cosp::set_grids(const std::shared_ptr<const GridsManager> grids_manager)
7474
add_field<Required>("phis", scalar2d , m2/s2, grid_name);
7575
add_field<Required>("pseudo_density", scalar3d_mid, Pa, grid_name);
7676
add_field<Required>("cldfrac_rad", scalar3d_mid, nondim, grid_name);
77-
add_tracer<Required>("qv", m_grid, kg/kg);
78-
add_tracer<Required>("qc", m_grid, kg/kg);
79-
add_tracer<Required>("qi", m_grid, kg/kg);
77+
add_tracer<Required>("qv", m_grid, kg/kg, true);
78+
add_tracer<Required>("qc", m_grid, kg/kg, true);
79+
add_tracer<Required>("qi", m_grid, kg/kg, true);
8080
// Optical properties, should be computed in radiation interface
8181
add_field<Required>("dtau067", scalar3d_mid, nondim, grid_name); // 0.67 micron optical depth
8282
add_field<Required>("dtau105", scalar3d_mid, nondim, grid_name); // 10.5 micron optical depth

components/eamxx/src/physics/mam/eamxx_mam_aci_process_interface.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,19 @@ void MAMAci::set_grids(
8282

8383
// atmospheric quantities
8484
// specific humidity [kg/kg]
85-
add_tracer<Required>("qv", grid_, q_unit);
85+
add_tracer<Required>("qv", grid_, q_unit, true);
8686

8787
// cloud liquid mass mixing ratio [kg/kg]
88-
add_tracer<Required>("qc", grid_, q_unit);
88+
add_tracer<Required>("qc", grid_, q_unit, true);
8989

9090
// cloud ice mass mixing ratio [kg/kg]
91-
add_tracer<Required>("qi", grid_, q_unit);
91+
add_tracer<Required>("qi", grid_, q_unit, true);
9292

9393
// cloud liquid number mixing ratio [1/kg]
94-
add_tracer<Required>("nc", grid_, n_unit);
94+
add_tracer<Required>("nc", grid_, n_unit, true);
9595

9696
// cloud ice number mixing ratio [1/kg]
97-
add_tracer<Required>("ni", grid_, n_unit);
97+
add_tracer<Required>("ni", grid_, n_unit, true);
9898

9999
// Temperature[K] at midpoints
100100
add_field<Required>("T_mid", scalar3d_mid, K, grid_name);
@@ -157,15 +157,16 @@ void MAMAci::set_grids(
157157

158158
// interstitial and cloudborne aerosol tracers of interest: mass (q) and
159159
// number (n) mixing ratios
160+
// NOTE:
161+
// - For interstitial aerosols, we have dynamics advect, but not turbulence.
162+
// - For cloudborne aerosols, DO NOT advect.
160163
for(int mode = 0; mode < mam_coupling::num_aero_modes(); ++mode) {
161164
// interstitial aerosol tracers of interest: number (n) mixing ratios
162165
const char *int_nmr_field_name =
163166
mam_coupling::int_aero_nmr_field_name(mode);
164-
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit);
167+
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit, false);
165168

166169
// cloudborne aerosol tracers of interest: number (n) mixing ratios
167-
// NOTE: DO NOT add cld borne aerosols to the "tracer" group as these are
168-
// NOT advected
169170
const char *cld_nmr_field_name =
170171
mam_coupling::cld_aero_nmr_field_name(mode);
171172
add_field<Updated>(cld_nmr_field_name, scalar3d_mid, n_unit, grid_name);
@@ -175,11 +176,9 @@ void MAMAci::set_grids(
175176
const char *int_mmr_field_name =
176177
mam_coupling::int_aero_mmr_field_name(mode, a);
177178
if(strlen(int_mmr_field_name) > 0) {
178-
add_tracer<Updated>(int_mmr_field_name, grid_, q_unit);
179+
add_tracer<Updated>(int_mmr_field_name, grid_, q_unit, false);
179180
}
180181
// (cloudborne) aerosol tracers of interest: mass (q) mixing ratios
181-
// NOTE: DO NOT add cld borne aerosols to the "tracer" group as these are
182-
// NOT advected
183182
const char *cld_mmr_field_name =
184183
mam_coupling::cld_aero_mmr_field_name(mode, a);
185184
if(strlen(cld_mmr_field_name) > 0) {
@@ -190,7 +189,7 @@ void MAMAci::set_grids(
190189

191190
for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) {
192191
const char *gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g);
193-
add_tracer<Updated>(gas_mmr_field_name, grid_, q_unit);
192+
add_tracer<Updated>(gas_mmr_field_name, grid_, q_unit, true);
194193
} // end for loop num gases
195194

196195
// ------------------------------------------------------------------------

components/eamxx/src/physics/mam/eamxx_mam_constituent_fluxes_interface.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ void MAMConstituentFluxes::set_grids(
4343
// --------------------------------------------------------------------------
4444
// ----------- Atmospheric quantities -------------
4545
// Specific humidity [kg/kg](Require only for building DS)
46-
add_tracer<Required>("qv", grid_, q_unit);
46+
add_tracer<Required>("qv", grid_, q_unit, true);
4747

4848
// Cloud liquid mass mixing ratio [kg/kg](Require only for building DS)
49-
add_tracer<Required>("qc", grid_, q_unit);
49+
add_tracer<Required>("qc", grid_, q_unit, true);
5050

5151
// Cloud ice mass mixing ratio [kg/kg](Require only for building DS)
52-
add_tracer<Required>("qi", grid_, q_unit);
52+
add_tracer<Required>("qi", grid_, q_unit, true);
5353

5454
// Cloud liquid number mixing ratio [1/kg](Require only for building DS)
55-
add_tracer<Required>("nc", grid_, n_unit);
55+
add_tracer<Required>("nc", grid_, n_unit, true);
5656

5757
// Cloud ice number mixing ratio [1/kg](Require only for building DS)
58-
add_tracer<Required>("ni", grid_, n_unit);
58+
add_tracer<Required>("ni", grid_, n_unit, true);
5959

6060
// Temperature[K] at midpoints
6161
add_field<Required>("T_mid", scalar3d_mid, K, grid_name);
@@ -98,15 +98,16 @@ void MAMConstituentFluxes::set_grids(
9898

9999
// interstitial and cloudborne aerosol tracers of interest: mass (q) and
100100
// number (n) mixing ratios
101+
// NOTE:
102+
// - For interstitial aerosols, we have dynamics advect, but not turbulence.
103+
// - For cloudborne aerosols, DO NOT advect. (for now just a field)
101104
for(int mode = 0; mode < mam_coupling::num_aero_modes(); ++mode) {
102105
// interstitial aerosol tracers of interest: number (n) mixing ratios
103106
const std::string int_nmr_field_name =
104107
mam_coupling::int_aero_nmr_field_name(mode);
105-
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit);
108+
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit, false);
106109

107110
// cloudborne aerosol tracers of interest: number (n) mixing ratios
108-
// NOTE: DO NOT add cld borne aerosols to the "tracer" group as these are
109-
// NOT advected
110111
const std::string cld_nmr_field_name =
111112
mam_coupling::cld_aero_nmr_field_name(mode);
112113
add_field<Updated>(cld_nmr_field_name, scalar3d_mid, n_unit, grid_name);
@@ -116,11 +117,9 @@ void MAMConstituentFluxes::set_grids(
116117
const std::string int_mmr_field_name =
117118
mam_coupling::int_aero_mmr_field_name(mode, a);
118119
if(not int_mmr_field_name.empty()) {
119-
add_tracer<Updated>(int_mmr_field_name, grid_, q_unit);
120+
add_tracer<Updated>(int_mmr_field_name, grid_, q_unit, false);
120121
}
121122
// (cloudborne) aerosol tracers of interest: mass (q) mixing ratios
122-
// NOTE: DO NOT add cld borne aerosols to the "tracer" group as these are
123-
// NOT advected
124123
const std::string cld_mmr_field_name =
125124
mam_coupling::cld_aero_mmr_field_name(mode, a);
126125
if(not cld_mmr_field_name.empty()) {
@@ -131,7 +130,7 @@ void MAMConstituentFluxes::set_grids(
131130

132131
for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) {
133132
const std::string gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g);
134-
add_tracer<Updated>(gas_mmr_field_name, grid_, q_unit);
133+
add_tracer<Updated>(gas_mmr_field_name, grid_, q_unit, true);
135134
} // end for loop num gases
136135

137136
} // set_grid

components/eamxx/src/physics/mam/eamxx_mam_dry_deposition_process_interface.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ void MAMDryDep::set_grids(
7171

7272
// ----------- Atmospheric quantities -------------
7373
// Specific humidity [kg/kg](Require only for building DS)
74-
add_tracer<Required>("qv", grid_, q_unit);
74+
add_tracer<Required>("qv", grid_, q_unit, true);
7575

7676
// Cloud liquid mass mixing ratio [kg/kg](Require only for building DS)
77-
add_tracer<Required>("qc", grid_, q_unit);
77+
add_tracer<Required>("qc", grid_, q_unit, true);
7878

7979
// Cloud ice mass mixing ratio [kg/kg](Require only for building DS)
80-
add_tracer<Required>("qi", grid_, q_unit);
80+
add_tracer<Required>("qi", grid_, q_unit, true);
8181

8282
// Cloud liquid number mixing ratio [1/kg](Require only for building DS)
83-
add_tracer<Required>("nc", grid_, n_unit);
83+
add_tracer<Required>("nc", grid_, n_unit, true);
8484

8585
// Cloud ice number mixing ratio [1/kg](Require only for building DS)
86-
add_tracer<Required>("ni", grid_, n_unit);
86+
add_tracer<Required>("ni", grid_, n_unit, true);
8787

8888
// Temperature[K] at midpoints
8989
add_field<Required>("T_mid", scalar3d_mid, K, grid_name);
@@ -153,20 +153,22 @@ void MAMDryDep::set_grids(
153153

154154
// (interstitial) aerosol tracers of interest: mass (q) and number (n) mixing
155155
// ratios
156+
// NOTE: For interstitial aerosols, we have dynamics advect, but not turbulence.
156157
for(int m = 0; m < num_aero_modes; ++m) {
157158
const char *int_nmr_field_name = mam_coupling::int_aero_nmr_field_name(m);
158159

159-
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit);
160+
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit, false);
160161
for(int a = 0; a < mam_coupling::num_aero_species(); ++a) {
161162
const char *int_mmr_field_name =
162163
mam_coupling::int_aero_mmr_field_name(m, a);
163164

164165
if(strlen(int_mmr_field_name) > 0) {
165-
add_tracer<Updated>(int_mmr_field_name, grid_, q_unit);
166+
add_tracer<Updated>(int_mmr_field_name, grid_, q_unit, false);
166167
}
167168
}
168169
}
169170
// (cloud) aerosol tracers of interest: mass (q) and number (n) mixing ratios
171+
// NOTE: For cloudborne aerosols, DO NOT advect.
170172
for(int m = 0; m < num_aero_modes; ++m) {
171173
const char *cld_nmr_field_name = mam_coupling::cld_aero_nmr_field_name(m);
172174

@@ -184,7 +186,7 @@ void MAMDryDep::set_grids(
184186
// aerosol-related gases: mass mixing ratios
185187
for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) {
186188
const char *gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g);
187-
add_tracer<Updated>(gas_mmr_field_name, grid_, q_unit);
189+
add_tracer<Updated>(gas_mmr_field_name, grid_, q_unit, true);
188190
}
189191

190192
// -------------------------------------------------------------

components/eamxx/src/physics/mam/eamxx_mam_microphysics_process_interface.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,19 @@ void MAMMicrophysics::set_grids(
8080
// ----------- Atmospheric quantities -------------
8181

8282
// Specific humidity [kg/kg](Require only for building DS)
83-
add_tracer<Required>("qv", grid_, kg/kg); // specific humidity
83+
add_tracer<Required>("qv", grid_, kg/kg, true); // specific humidity
8484

8585
// Cloud liquid mass mixing ratio [kg/kg](Require only for building DS)
86-
add_tracer<Updated>("qc", grid_, kg/kg); // cloud liquid wet mixing ratio
86+
add_tracer<Updated>("qc", grid_, kg/kg, true); // cloud liquid wet mixing ratio
8787

8888
// Cloud ice mass mixing ratio [kg/kg](Require only for building DS)
89-
add_tracer<Required>("qi", grid_, kg/kg); // ice wet mixing ratio
89+
add_tracer<Required>("qi", grid_, kg/kg, true); // ice wet mixing ratio
9090

9191
// Cloud liquid number mixing ratio [1/kg](Require only for building DS)
92-
add_tracer<Updated>("nc", grid_, n_unit); // cloud liquid wet number mixing ratio
92+
add_tracer<Updated>("nc", grid_, n_unit, true); // cloud liquid wet number mixing ratio
9393

9494
// Cloud ice number mixing ratio [1/kg](Require only for building DS)
95-
add_tracer<Required>("ni", grid_, n_unit); // ice number mixing ratio
95+
add_tracer<Required>("ni", grid_, n_unit, true); // ice number mixing ratio
9696

9797
// Temperature[K] at midpoints
9898
add_field<Required>("T_mid", scalar3d_mid, K, grid_name);
@@ -151,20 +151,22 @@ void MAMMicrophysics::set_grids(
151151

152152
// (interstitial) aerosol tracers of interest: mass (q) and number (n) mixing
153153
// ratios
154+
// NOTE: For interstitial aerosols, we have dynamics advect, but not turbulence.
154155
for(int m = 0; m < nmodes; ++m) {
155156
const char *int_nmr_field_name = mam_coupling::int_aero_nmr_field_name(m);
156157

157-
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit);
158+
add_tracer<Updated>(int_nmr_field_name, grid_, n_unit, false);
158159
for(int a = 0; a < mam_coupling::num_aero_species(); ++a) {
159160
const char *int_mmr_field_name =
160161
mam_coupling::int_aero_mmr_field_name(m, a);
161162

162163
if(strlen(int_mmr_field_name) > 0) {
163-
add_tracer<Updated>(int_mmr_field_name, grid_, kg/kg);
164+
add_tracer<Updated>(int_mmr_field_name, grid_, kg/kg, false);
164165
}
165166
} // for loop species
166167
} // for loop nmodes interstitial
167168
// (cloud) aerosol tracers of interest: mass (q) and number (n) mixing ratios
169+
// NOTE: For cloudborne aerosols, DO NOT advect.
168170
for(int m = 0; m < nmodes; ++m) {
169171
const char *cld_nmr_field_name = mam_coupling::cld_aero_nmr_field_name(m);
170172

@@ -182,7 +184,7 @@ void MAMMicrophysics::set_grids(
182184
// aerosol-related gases: mass mixing ratios
183185
for(int g = 0; g < mam_coupling::num_aero_gases(); ++g) {
184186
const char *gas_mmr_field_name = mam_coupling::gas_mmr_field_name(g);
185-
add_tracer<Updated>(gas_mmr_field_name, grid_, kg/kg);
187+
add_tracer<Updated>(gas_mmr_field_name, grid_, kg/kg, true);
186188
}
187189

188190
// Creating a Linoz reader and setting Linoz parameters involves reading data

0 commit comments

Comments
 (0)