Skip to content

Commit 457bc78

Browse files
committed
Use calling_process in the FieldRequest::operator<
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.
1 parent b1c0213 commit 457bc78

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

components/eamxx/src/control/atmosphere_driver.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -537,15 +537,15 @@ void AtmosphereDriver::create_fields()
537537
// Before registering fields, check that Field Requests for tracers are compatible
538538
{
539539
// 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;
540+
std::map<std::string, std::set<FieldRequest>> tracer_requests;
541541
auto gather_tracer_requests = [&] (FieldRequest req) {
542542
if (not ekat::contains(req.groups, "tracers")) return;
543543

544544
std::string fname = req.fid.name();
545545
if (tracer_requests.find(fname) == tracer_requests.end()) {
546-
tracer_requests[fname] = std::vector<FieldRequest>(1, req);
546+
tracer_requests[fname] = {req};
547547
} else {
548-
tracer_requests[fname].push_back(req);
548+
tracer_requests[fname].emplace(req);
549549
}
550550
};
551551
for (const auto& req : m_atm_process_group->get_required_field_requests()){
@@ -558,18 +558,14 @@ void AtmosphereDriver::create_fields()
558558
// Go through the map entry for each tracer and check that every one
559559
// has the same request for turbulence advection.
560560
for (auto fr : tracer_requests) {
561-
bool mismatch_found = false;
562-
563561
const auto reqs = fr.second;
564-
const bool is_first_turb_advect = ekat::contains(reqs.front().groups, "turbulence_advected_tracers");
565-
for (size_t i=1; i<reqs.size(); ++i) {
566-
const bool is_turb_advect = ekat::contains(reqs[i].groups, "turbulence_advected_tracers");
567-
if (is_turb_advect != is_first_turb_advect) {
568-
mismatch_found = true;
569-
break;
570-
}
562+
563+
std::set<bool> turb_advect_types;
564+
for (auto req : reqs) {
565+
turb_advect_types.emplace(ekat::contains(req.groups, "turbulence_advected_tracers"));
571566
}
572-
if (mismatch_found) {
567+
568+
if (turb_advect_types.size()!=1) {
573569
std::ostringstream ss;
574570
ss << "Error! Incompatible tracer request. Turbulence advection requests not consistent among processes.\n"
575571
" - Tracer name: " + fr.first + "\n"

components/eamxx/src/share/field/field_request.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,11 @@ inline bool operator< (const FieldRequest& lhs,
285285
if (lhs.pack_size<rhs.pack_size) {
286286
return true;
287287
} else if (lhs.pack_size==rhs.pack_size) {
288-
return lhs.groups < rhs.groups;
288+
if (lhs.groups < rhs.groups) {
289+
return true;
290+
} else if (lhs.groups==rhs.groups) {
291+
return lhs.calling_process < rhs.calling_process;
292+
}
289293
}
290294
}
291295
return false;

0 commit comments

Comments
 (0)