@@ -137,6 +137,13 @@ AtmosphereOutput::AtmosphereOutput(const ekat::Comm &comm, const ekat::Parameter
137137 m_fields_names.clear ();
138138 }
139139 }
140+ if (pl.isParameter (" aliases" )) {
141+ if (pl.isType <vos_t >(" aliases" )) {
142+ m_intermediate_aliases = pl.get <vos_t >(" aliases" );
143+ } else {
144+ m_intermediate_aliases.push_back (pl.get <std::string>(" aliases" ));
145+ }
146+ }
140147 }
141148 }
142149 EKAT_REQUIRE_MSG (grid_found,
@@ -982,40 +989,31 @@ process_requested_fields()
982989 auto fm_model = m_field_mgrs[FromModel];
983990 auto fm_grid = m_field_mgrs[FromModel]->get_grid ();
984991
985- // First, find intermediate-only fields declared with the ':=:' syntax.
986- // These are created and added to the field manager (so dependents can use them),
987- // but are NOT registered with scorpio and do NOT appear in NC output.
992+ // Process intermediate-only fields declared in the 'aliases' YAML section.
993+ // Each entry has the form "alias:=original". These are created and registered
994+ // in the field manager so that dependents can use them, but are NOT written
995+ // to the NC output file.
988996 std::set<std::string> intermediate_names;
989- for (auto & name : m_fields_names) {
990- auto sep3 = name.find (" :=:" );
991- if (sep3 != std::string::npos) {
992- auto alias = name.substr (0 , sep3);
993- auto orig = name.substr (sep3 + 3 );
994- EKAT_REQUIRE_MSG (!alias.empty () && !orig.empty (),
995- " Error! Invalid intermediate field request. Should be 'alias:=:original'.\n "
996- " - request: " + name + " \n " );
997- EKAT_REQUIRE_MSG (m_alias_to_orig.count (alias)==0 ,
998- " Error! Intermediate-only alias conflicts with an existing alias.\n "
999- " - stream name: " + m_stream_name + " \n "
1000- " - alias: " + alias + " \n " );
1001- m_alias_to_orig[alias] = orig;
1002- intermediate_names.insert (alias);
1003- name = " " ; // mark for removal from m_fields_names
1004- }
1005- }
1006- // Remove blanked entries (intermediate-only fields)
1007- {
1008- std::vector<std::string> tmp;
1009- for (const auto & n : m_fields_names)
1010- if (!n.empty ()) tmp.push_back (n);
1011- m_fields_names = std::move (tmp);
997+ for (const auto & spec : m_intermediate_aliases) {
998+ auto tokens = ekat::split (spec, " :=" );
999+ EKAT_REQUIRE_MSG (tokens.size ()==2 && !tokens[0 ].empty () && !tokens[1 ].empty (),
1000+ " Error! Invalid entry in 'aliases' section. Should be 'alias:=original'.\n "
1001+ " - entry: " + spec + " \n " );
1002+ const auto & alias = tokens[0 ];
1003+ const auto & orig = tokens[1 ];
1004+ EKAT_REQUIRE_MSG (m_alias_to_orig.count (alias)==0 ,
1005+ " Error! Intermediate alias conflicts with an existing alias.\n "
1006+ " - stream name: " + m_stream_name + " \n "
1007+ " - alias: " + alias + " \n " );
1008+ m_alias_to_orig[alias] = orig;
1009+ intermediate_names.insert (alias);
10121010 }
10131011
10141012 // Check that no intermediate name also appears as a regular output field
10151013 for (const auto & iname : intermediate_names) {
10161014 for (const auto & fname : m_fields_names) {
10171015 EKAT_REQUIRE_MSG (fname != iname,
1018- " Error! A field declared as intermediate-only (':=:') also appears as a regular output .\n "
1016+ " Error! A field declared in the 'aliases' section also appears in 'field_names' .\n "
10191017 " - stream name: " + m_stream_name + " \n "
10201018 " - field name: " + iname + " \n " );
10211019 }
0 commit comments