Skip to content

Commit

Permalink
Use calling_process in the FieldRequest::operator<
Browse files Browse the repository at this point in the history
Increases the number of entries in the AtmosphereProcess set m_*_field_requests, but not the number of allocations. Allows us to output all instances of field requests of the same name.
  • Loading branch information
tcclevenger committed Nov 18, 2024
1 parent b1c0213 commit 457bc78
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 9 additions & 13 deletions components/eamxx/src/control/atmosphere_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,15 +537,15 @@ void AtmosphereDriver::create_fields()
// Before registering fields, check that Field Requests for tracers are compatible
{
// Create map from tracer name to a vector which contains the field requests for that tracer.
std::map<std::string, std::vector<FieldRequest>> tracer_requests;
std::map<std::string, std::set<FieldRequest>> tracer_requests;
auto gather_tracer_requests = [&] (FieldRequest req) {
if (not ekat::contains(req.groups, "tracers")) return;

std::string fname = req.fid.name();
if (tracer_requests.find(fname) == tracer_requests.end()) {
tracer_requests[fname] = std::vector<FieldRequest>(1, req);
tracer_requests[fname] = {req};
} else {
tracer_requests[fname].push_back(req);
tracer_requests[fname].emplace(req);
}
};
for (const auto& req : m_atm_process_group->get_required_field_requests()){
Expand All @@ -558,18 +558,14 @@ void AtmosphereDriver::create_fields()
// Go through the map entry for each tracer and check that every one
// has the same request for turbulence advection.
for (auto fr : tracer_requests) {
bool mismatch_found = false;

const auto reqs = fr.second;
const bool is_first_turb_advect = ekat::contains(reqs.front().groups, "turbulence_advected_tracers");
for (size_t i=1; i<reqs.size(); ++i) {
const bool is_turb_advect = ekat::contains(reqs[i].groups, "turbulence_advected_tracers");
if (is_turb_advect != is_first_turb_advect) {
mismatch_found = true;
break;
}

std::set<bool> turb_advect_types;
for (auto req : reqs) {
turb_advect_types.emplace(ekat::contains(req.groups, "turbulence_advected_tracers"));
}
if (mismatch_found) {

if (turb_advect_types.size()!=1) {
std::ostringstream ss;
ss << "Error! Incompatible tracer request. Turbulence advection requests not consistent among processes.\n"
" - Tracer name: " + fr.first + "\n"
Expand Down
6 changes: 5 additions & 1 deletion components/eamxx/src/share/field/field_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ inline bool operator< (const FieldRequest& lhs,
if (lhs.pack_size<rhs.pack_size) {
return true;
} else if (lhs.pack_size==rhs.pack_size) {
return lhs.groups < rhs.groups;
if (lhs.groups < rhs.groups) {
return true;
} else if (lhs.groups==rhs.groups) {
return lhs.calling_process < rhs.calling_process;
}
}
}
return false;
Expand Down

0 comments on commit 457bc78

Please sign in to comment.