-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for tracer to not be advected by SHOC #3085
Changes from all commits
18e335e
74c95e6
6746b67
37ba461
b1c0213
457bc78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -534,6 +534,52 @@ void AtmosphereDriver::create_fields() | |
m_field_mgrs[grid->name()]->registration_begins(); | ||
} | ||
|
||
// 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::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] = {req}; | ||
} else { | ||
tracer_requests[fname].emplace(req); | ||
} | ||
}; | ||
for (const auto& req : m_atm_process_group->get_required_field_requests()){ | ||
gather_tracer_requests(req); | ||
} | ||
for (const auto& req : m_atm_process_group->get_computed_field_requests()) { | ||
gather_tracer_requests(req); | ||
} | ||
|
||
// 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) { | ||
const auto reqs = fr.second; | ||
|
||
std::set<bool> turb_advect_types; | ||
for (auto req : reqs) { | ||
turb_advect_types.emplace(ekat::contains(req.groups, "turbulence_advected_tracers")); | ||
} | ||
|
||
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" | ||
" - Requests (process name, grid name, is tracers turbulence advected):\n"; | ||
for (auto req : reqs) { | ||
const auto grid_name = req.fid.get_grid_name(); | ||
const bool turb_advect = ekat::contains(req.groups, "turbulence_advected_tracers"); | ||
ss << " - (" + req.calling_process + ", " + grid_name + ", " + (turb_advect ? "true" : "false") + ")\n"; | ||
} | ||
EKAT_ERROR_MSG(ss.str()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sample output in case that P3 requests
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is there a repeated entry for homme? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is because there exists a computed and required group request (since "qv" is "updated" in homme), but then I don't know why p3 does not have 2 requests as well. Let me investigate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So yes, double entries are due to "updated" fields, since a request exists for "required" and "computed". Also, field requests in ATMProcGroup is a set, and so only one version of each reqest is used. By chance homme's "qv" was the version of "qv" with packsize>1, P3 was picked up since it's req.groups was unique (i.e., no turbulence advection), and mam4_aci was picked up as the packsize=1 request (all other mam "qv" request ignored. @bartgol I've pushed a solution that does the following
The other options for 2. I think are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could put an enum in the request, that specifies whether this req is for input, output, or input-output. It may be helpful for debugging purposes. That said, I don't think that seeing duplicated processes in the output is a big deal. What I would do, maybe, is explain why the requests are incompatible. That is, you could add a line at the bottom of the error msg, like
|
||
} | ||
} | ||
} | ||
|
||
// Register required/computed fields | ||
for (const auto& req : m_atm_process_group->get_required_field_requests()) { | ||
m_field_mgrs.at(req.fid.get_grid_name())->register_field(req); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this snippet should be moved somewhere, like in share/util, or maybe as a free function in
field_request.hpp
, something like(maybe with a better name)