Skip to content
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

EAMxx: Allow to save a dictionary of fields in the FieldManager #6842

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/eamxx/cime_config/namelist_defaults_scream.xml
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ be lost if SCREAM_HACK_XML is not enabled.
<!-- driver_options options for scream -->
<driver_options>
<atmosphere_dag_verbosity_level>0</atmosphere_dag_verbosity_level>
<save_field_manager_dictionary type="logical">false</save_field_manager_dictionary>
<atm_log_level type="string"
valid_values="trace,debug,info,warn,error"
doc="Verbosity level for the atm logger">
Expand Down
41 changes: 41 additions & 0 deletions components/eamxx/src/control/atmosphere_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,47 @@ void AtmosphereDriver::create_fields()

m_ad_status |= s_fields_created;

// If the user requested it, we can save a dictionary of the FM fields to file
auto& driver_options_pl = m_atm_params.sublist("driver_options");
if (driver_options_pl.get("save_field_manager_content",false)) {
auto pg = m_grids_manager->get_grid("Physics");
const auto& fm = m_field_mgrs.at(pg->name());
ekat::ParameterList pl_out("field_manager_content");
pl_out.sublist("provenance") = m_atm_params.sublist("provenance");
DefaultMetadata std_names;
std::string desc;
desc = "content of the EAMxx FieldManager corresponding to the 'Physics' grid.\n"
"The dict keys are the field names as used in EAMxx.\n"
"For each field, we add the following entries:\n"
" - standard_name: the name commonly used to refer to this field in atm sciences (if applicable)\n"
" - units: the units for this field used in EAMxx\n"
" - layout: the names of the dimensions for this field (time excluded)\n"
" - providers: the atm processes that update/compute this field\n"
" - customers: the atm processes that require this field as an input\n";
pl_out.set("description", desc);
auto& dict = pl_out.sublist("fields");
for (const auto& it : *fm) {
const auto& fid = it.second->get_header().get_identifier();
auto& pl = dict.sublist(fid.name());

pl.set("units",fid.get_units().to_string());
pl.set("layout",fid.get_layout().names());
pl.set("standard_name",std_names.get_standardname(fid.name()));
std::vector<std::string> providers,customers;
const auto& track = it.second->get_header().get_tracking();
for (auto ap : track.get_providers()) {
providers.push_back(ap.lock()->name());
}
for (auto ap : track.get_customers()) {
customers.push_back(ap.lock()->name());
}
pl.set("providers",providers);
pl.set("customers",customers);
}

ekat::write_yaml_file("eamxx_field_manager_content.yaml",pl_out);
}

stop_timer("EAMxx::create_fields");
stop_timer("EAMxx::init");
m_atm_logger->info("[EAMxx] create_fields ... done!");
Expand Down
3 changes: 2 additions & 1 deletion components/eamxx/src/share/io/scorpio_output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include "share/field/field_manager.hpp"
#include "share/grid/abstract_grid.hpp"
#include "share/grid/grids_manager.hpp"
#include "share/util//scream_time_stamp.hpp"
#include "share/util/scream_time_stamp.hpp"
#include "share/util/scream_utils.hpp"
#include "share/atm_process/atmosphere_diagnostic.hpp"

#include "ekat/ekat_parameter_list.hpp"
Expand Down
105 changes: 0 additions & 105 deletions components/eamxx/src/share/io/scream_io_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,111 +75,6 @@ std::string find_filename_in_rpointer (
const OutputAvgType avg_type = OutputAvgType::Instant,
const IOControl& control = {});

struct DefaultMetadata {

std::string get_longname (const std::string& name) {
if (name_2_longname.count(name)>0) {
return name_2_longname.at(name);
} else {
// TODO: Do we want to print a Warning message? I'm not sure if its needed.
return name;
}
}

std::string get_standardname (const std::string& name) {
if (name_2_standardname.count(name)>0) {
return name_2_standardname.at(name);
} else {
// TODO: Do we want to print a Warning message? I'm not sure if its needed.
return name;
}
}

// Create map of longnames, can be added to as developers see fit.
std::map<std::string,std::string> name_2_longname = {
{"lev","hybrid level at midpoints (1000*(A+B))"},
{"ilev","hybrid level at interfaces (1000*(A+B))"},
{"hyai","hybrid A coefficient at layer interfaces"},
{"hybi","hybrid B coefficient at layer interfaces"},
{"hyam","hybrid A coefficient at layer midpoints"},
{"hybm","hybrid B coefficient at layer midpoints"}
};

// Create map of longnames, can be added to as developers see fit.
std::map<std::string,std::string> name_2_standardname = {
{"p_mid" , "air_pressure"},
{"p_mid_at_cldtop" , "air_pressure_at_cloud_top"},
{"T_2m" , "air_temperature"},
{"T_mid" , "air_temperature"},
{"T_mid_at_cldtop" , "air_temperature_at_cloud_top"},
{"aero_g_sw" , "asymmetry_factor_of_ambient_aerosol_particles"},
{"pbl_height" , "atmosphere_boundary_layer_thickness"},
{"precip_liq_surf_mass" , "atmosphere_mass_content_of_liquid_precipitation"},
{"cldlow" , "low_type_cloud_area_fraction"},
{"cldmed" , "medium_type_cloud_area_fraction"},
{"cldhgh" , "high_type_cloud_area_fraction"},
{"cldtot" , "cloud_area_fraction"},
{"cldfrac_tot_at_cldtop" , "cloud_area_fraction"},
{"cldfrac_tot" , "cloud_area_fraction_in_atmosphere_layer"},
{"cldfrac_tot_for_analysis" , "cloud_area_fraction_in_atmosphere_layer"},
{"cldfrac_rad" , "cloud_area_fraction_in_atmosphere_layer"},
{"qi" , "cloud_ice_mixing_ratio"},
{"qc" , "cloud_liquid_water_mixing_ratio"},
{"U" , "eastward_wind"},
{"eff_radius_qi" , "effective_radius_of_cloud_ice_particles"},
{"eff_radius_qc" , "effective_radius_of_cloud_liquid_water_particles"},
{"eff_radius_qc_at_cldtop" , "effective_radius_of_cloud_liquid_water_particles_at_liquid_water_cloud_top"},
{"eff_radius_qr" , "effective_radius_of_cloud_rain_particles"},
{"qv" , "humidity_mixing_ratio"},
{"cldfrac_ice_at_cldtop" , "ice_cloud_area_fraction"},
{"cldfrac_ice" , "ice_cloud_area_fraction_in_atmosphere_layer"},
{"omega" , "lagrangian_tendency_of_air_pressure"},
{"landfrac" , "land_area_fraction"},
{"latitude" , "latitude"},
{"cldfrac_liq_at_cldtop" , "liquid_water_cloud_area_fraction"},
{"cldfrac_liq" , "liquid_water_cloud_area_fraction_in_atmosphere_layer"},
{"longitude" , "longitude"},
{"rainfrac" , "mass_fraction_of_liquid_precipitation_in_air"},
{"V" , "northward_wind"},
{"nc" , "number_concentration_of_cloud_liquid_water_particles_in_air"},
{"cdnc_at_cldtop" , "number_concentration_of_cloud_liquid_water_particles_in_air_at_liquid_water_cloud_top"},
{"ni" , "number_concentration_of_ice_crystals_in_air"},
{"aero_tau_sw" , "optical_thickness_of_atmosphere_layer_due_to_ambient_aerosol_particles"},
{"aero_tau_lw" , "optical_thickness_of_atmosphere_layer_due_to_ambient_aerosol_particles"},
{"aero_ssa_sw" , "single_scattering_albedo_in_air_due_to_ambient_aerosol_particles"},
{"sunlit" , "sunlit_binary_mask"},
{"ps" , "surface_air_pressure"},
{"LW_flux_dn_at_model_bot" , "surface_downwelling_longwave_flux_in_air"},
{"SW_flux_dn_at_model_bot" , "surface_downwelling_shortwave_flux_in_air"},
{"SW_clrsky_flux_dn_at_model_bot" , "surface_downwelling_shortwave_flux_in_air_assuming_clear_sky"},
{"phis" , "surface_geopotential"},
{"surf_radiative_T" , "surface_temperature"},
{"surf_sens_flux" , "surface_upward_sensible_heat_flux"},
{"SW_flux_dn_at_model_top" , "toa_incoming_shortwave_flux"},
{"LW_flux_up_at_model_top" , "toa_outgoing_longwave_flux"},
{"LW_clrsky_flux_up_at_model_top" , "toa_outgoing_longwave_flux_assuming_clear_sky"},
{"surf_evap" , "water_evapotranspiration_flux"},
{"AtmosphereDensity" , "air_density"},
{"PotentialTemperature" , "air_potential_temperature"},
{"SeaLevelPressure" , "air_pressure_at_mean_sea_level"},
{"IceWaterPath" , "atmosphere_mass_content_of_cloud_ice"},
{"LiqWaterPath" , "atmosphere_mass_content_of_cloud_liquid_water"},
{"VapWaterPath" , "atmosphere_mass_content_of_water_vapor"},
{"AerosolOpticalDepth550nm" , "atmosphere_optical_thickness_due_to_ambient_aerosol_particles"},
{"Exner" , "dimensionless_exner_function"},
{"z_mid" , "geopotential_height"},
{"geopotential_mid" , "geopotential_height"},
{"RelativeHumidity" , "relative_humidity"},
{"surface_upward_latent_heat_flux" , "surface_upward_latent_heat_flux"},
{"LongwaveCloudForcing" , "toa_longwave_cloud_radiative_effect"},
{"ShortwaveCloudForcing" , "toa_shortwave_cloud_radiative_effect"},
{"VirtualTemperature" , "virtual_temperature"},
{"VaporFlux" , "water_evapotranspiration_flux"},
{"wind_speed" , "wind_speed"}
};

};

// Shortcut to write/read to/from YYYYMMDD/HHMMSS attributes in the NC file
void write_timestamp (const std::string& filename, const std::string& ts_name,
const util::TimeStamp& ts, const bool write_nsteps = false);
Expand Down
Loading
Loading