Skip to content

Commit e58531e

Browse files
authored
Merge branch 'bartgol/eamxx/dump-fields-dictionary' (PR #6842)
The option (off by default) allows to save a yaml file containing a dictionary of the fields on the "Physics" grid, with some of their details.
2 parents 8818556 + 7eb5d2c commit e58531e

17 files changed

+183
-107
lines changed

components/eamxx/cime_config/namelist_defaults_scream.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ be lost if SCREAM_HACK_XML is not enabled.
717717
<!-- driver_options options for scream -->
718718
<driver_options>
719719
<atmosphere_dag_verbosity_level>0</atmosphere_dag_verbosity_level>
720+
<save_field_manager_dictionary type="logical">false</save_field_manager_dictionary>
720721
<atm_log_level type="string"
721722
valid_values="trace,debug,info,warn,error"
722723
doc="Verbosity level for the atm logger">

components/eamxx/src/control/atmosphere_driver.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,47 @@ void AtmosphereDriver::create_fields()
687687

688688
m_ad_status |= s_fields_created;
689689

690+
// If the user requested it, we can save a dictionary of the FM fields to file
691+
auto& driver_options_pl = m_atm_params.sublist("driver_options");
692+
if (driver_options_pl.get("save_field_manager_content",false)) {
693+
auto pg = m_grids_manager->get_grid("Physics");
694+
const auto& fm = m_field_mgrs.at(pg->name());
695+
ekat::ParameterList pl_out("field_manager_content");
696+
pl_out.sublist("provenance") = m_atm_params.sublist("provenance");
697+
DefaultMetadata std_names;
698+
std::string desc;
699+
desc = "content of the EAMxx FieldManager corresponding to the 'Physics' grid.\n"
700+
"The dict keys are the field names as used in EAMxx.\n"
701+
"For each field, we add the following entries:\n"
702+
" - standard_name: the name commonly used to refer to this field in atm sciences (if applicable)\n"
703+
" - units: the units for this field used in EAMxx\n"
704+
" - layout: the names of the dimensions for this field (time excluded)\n"
705+
" - providers: the atm processes that update/compute this field\n"
706+
" - customers: the atm processes that require this field as an input\n";
707+
pl_out.set("description", desc);
708+
auto& dict = pl_out.sublist("fields");
709+
for (const auto& it : *fm) {
710+
const auto& fid = it.second->get_header().get_identifier();
711+
auto& pl = dict.sublist(fid.name());
712+
713+
pl.set("units",fid.get_units().to_string());
714+
pl.set("layout",fid.get_layout().names());
715+
pl.set("standard_name",std_names.get_standardname(fid.name()));
716+
std::vector<std::string> providers,customers;
717+
const auto& track = it.second->get_header().get_tracking();
718+
for (auto ap : track.get_providers()) {
719+
providers.push_back(ap.lock()->name());
720+
}
721+
for (auto ap : track.get_customers()) {
722+
customers.push_back(ap.lock()->name());
723+
}
724+
pl.set("providers",providers);
725+
pl.set("customers",customers);
726+
}
727+
728+
ekat::write_yaml_file("eamxx_field_manager_content.yaml",pl_out);
729+
}
730+
690731
stop_timer("EAMxx::create_fields");
691732
stop_timer("EAMxx::init");
692733
m_atm_logger->info("[EAMxx] create_fields ... done!");

components/eamxx/src/share/atm_process/atmosphere_process.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,8 @@ get_field_in_impl(const std::string& field_name, const std::string& grid_name) c
896896
" field name: " + field_name + "\n"
897897
" grid name: " + grid_name + "\n");
898898
}
899+
static Field f;
900+
return f;
899901
}
900902

901903
Field& AtmosphereProcess::
@@ -917,6 +919,8 @@ get_field_in_impl(const std::string& field_name) const {
917919
" atm proc name: " + this->name() + "\n"
918920
" field name: " + field_name + "\n");
919921
}
922+
static Field f;
923+
return f;
920924
}
921925

922926
Field& AtmosphereProcess::
@@ -932,6 +936,8 @@ get_field_out_impl(const std::string& field_name, const std::string& grid_name)
932936
" field name: " + field_name + "\n"
933937
" grid name: " + grid_name + "\n");
934938
}
939+
static Field f;
940+
return f;
935941
}
936942

937943
Field& AtmosphereProcess::
@@ -953,6 +959,8 @@ get_field_out_impl(const std::string& field_name) const {
953959
" atm proc name: " + this->name() + "\n"
954960
" field name: " + field_name + "\n");
955961
}
962+
static Field f;
963+
return f;
956964
}
957965

958966
FieldGroup& AtmosphereProcess::
@@ -968,6 +976,8 @@ get_group_in_impl(const std::string& group_name, const std::string& grid_name) c
968976
" group name: " + group_name + "\n"
969977
" grid name: " + grid_name + "\n");
970978
}
979+
static FieldGroup g("");
980+
return g;
971981
}
972982

973983
FieldGroup& AtmosphereProcess::
@@ -989,6 +999,8 @@ get_group_in_impl(const std::string& group_name) const {
989999
" atm proc name: " + this->name() + "\n"
9901000
" group name: " + group_name + "\n");
9911001
}
1002+
static FieldGroup g("");
1003+
return g;
9921004
}
9931005

9941006
FieldGroup& AtmosphereProcess::
@@ -1004,6 +1016,8 @@ get_group_out_impl(const std::string& group_name, const std::string& grid_name)
10041016
" group name: " + group_name + "\n"
10051017
" grid name: " + grid_name + "\n");
10061018
}
1019+
static FieldGroup g("");
1020+
return g;
10071021
}
10081022

10091023
FieldGroup& AtmosphereProcess::
@@ -1025,6 +1039,8 @@ get_group_out_impl(const std::string& group_name) const {
10251039
" atm proc name: " + this->name() + "\n"
10261040
" group name: " + group_name + "\n");
10271041
}
1042+
static FieldGroup g("");
1043+
return g;
10281044
}
10291045

10301046
Field& AtmosphereProcess::
@@ -1040,6 +1056,8 @@ get_internal_field_impl(const std::string& field_name, const std::string& grid_n
10401056
" field name: " + field_name + "\n"
10411057
" grid name: " + grid_name + "\n");
10421058
}
1059+
static Field f;
1060+
return f;
10431061
}
10441062

10451063
Field& AtmosphereProcess::
@@ -1061,6 +1079,8 @@ get_internal_field_impl(const std::string& field_name) const {
10611079
" atm proc name: " + this->name() + "\n"
10621080
" field name: " + field_name + "\n");
10631081
}
1082+
static Field f;
1083+
return f;
10641084
}
10651085

10661086
void AtmosphereProcess

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ class Field {
349349
get_subview_1 (const get_view_type<data_nd_t<T,N>,HD>&, const int) const {
350350
EKAT_ERROR_MSG ("Error! Cannot subview a rank2 view along the second "
351351
"dimension without losing LayoutRight.\n");
352+
return get_view_type<data_nd_t<T,N-1>,HD>();
352353
}
353354

354355
template<HostOrDevice HD,typename T,int N>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ auto Field::get_ND_view () const
966966
"MaxRank = 6.\n"
967967
"This should never be called at run time.\n"
968968
"Please contact developer if this functionality is required\n");
969+
return get_view_type<data_nd_t<T,N>,HD>();
969970
}
970971

971972
} // namespace scream

components/eamxx/src/share/grid/library_grids_manager.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class LibraryGridsManager : public GridsManager
4141
"Error! LibraryGridsManager is not capable of creating remappers.\n"
4242
" - from_grid: " + from_grid->name() + "\n"
4343
" - to_grid: " + to_grid->name() + "\n");
44+
return nullptr;
4445
}
4546
};
4647

components/eamxx/src/share/grid/remap/vertical_remapper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ create_src_layout (const FieldLayout& tgt_layout) const
8181
// we cannot infer what the corresponding src layout was.
8282
// This function should never be used for this remapper.
8383
EKAT_ERROR_MSG ("Error! VerticalRemapper does not support creating a src layout from a tgt layout.\n");
84+
return FieldLayout();
8485
}
8586

8687
FieldLayout VerticalRemapper::

components/eamxx/src/share/io/scorpio_output.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,8 @@ get_field(const std::string& name, const std::string& mode) const
13141314
} else {
13151315
EKAT_ERROR_MSG ("ERROR::AtmosphereOutput::get_field Field " + name + " not found in " + mode + " field manager or diagnostics list.");
13161316
}
1317+
static Field f;
1318+
return f;
13171319
}
13181320
/* ---------------------------------------------------------- */
13191321
void AtmosphereOutput::set_diagnostics()

components/eamxx/src/share/io/scorpio_output.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#include "share/field/field_manager.hpp"
77
#include "share/grid/abstract_grid.hpp"
88
#include "share/grid/grids_manager.hpp"
9-
#include "share/util//scream_time_stamp.hpp"
9+
#include "share/util/scream_time_stamp.hpp"
10+
#include "share/util/scream_utils.hpp"
1011
#include "share/atm_process/atmosphere_diagnostic.hpp"
1112

1213
#include "ekat/ekat_parameter_list.hpp"

components/eamxx/src/share/io/scream_io_file_specs.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct StorageSpecs {
5656
default:
5757
EKAT_ERROR_MSG ("Error! Unrecognized/unsupported file storage type.\n");
5858
}
59+
return false;
5960
}
6061

6162
void update_storage (const util::TimeStamp& t) {

0 commit comments

Comments
 (0)