From 21f772850f57bc371f493bdc8926fc8fd3864760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domokos=20S=C3=A1rm=C3=A1ny?= Date: Wed, 17 Jul 2024 16:54:33 +0100 Subject: [PATCH 1/2] MUL-131: Set additional keys for ensemble ocean output --- src/multio/action/encode/GribEncoder.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/multio/action/encode/GribEncoder.cc b/src/multio/action/encode/GribEncoder.cc index df88969f..2840fbcc 100644 --- a/src/multio/action/encode/GribEncoder.cc +++ b/src/multio/action/encode/GribEncoder.cc @@ -450,6 +450,14 @@ QueriedMarsKeys setMarsKeys(GribEncoder& g, const eckit::Configuration& md) { withFirstOf(valueSetter(g, "lengthOf4DvarWindow"), LookUpLong(md, "lengthOf4DvarWindow"), LookUpLong(md, "anlength")); + // Metadata for ensemble forecast + withFirstOf(valueSetter(g, "oceanAtmosphereCoupling"), LookUpLong(md, "oceanAtmosphereCoupling")); + withFirstOf(valueSetter(g, "legBaseDate"), LookUpLong(md, "legBaseDate")); + withFirstOf(valueSetter(g, "legBaseTime"), LookUpLong(md, "legBaseTime")); + withFirstOf(valueSetter(g, "legNumber"), LookUpLong(md, "legNumber")); + withFirstOf(valueSetter(g, "referenceDate"), LookUpLong(md, "referenceDate")); + withFirstOf(valueSetter(g, "climateDateFrom"), LookUpLong(md, "climateDateFrom")); + withFirstOf(valueSetter(g, "climateDateTo"), LookUpLong(md, "climateDateTo")); withFirstOf(valueSetter(g, "componentIndex"), LookUpLong(md, "componentIndex")); withFirstOf(valueSetter(g, "numberOfComponents"), LookUpLong(md, "numberOfComponents")); From ad3a0b754fec2e60f069f48db4b8f83ec9aae672 Mon Sep 17 00:00:00 2001 From: Razvan Aguridan Date: Tue, 16 Jul 2024 14:46:53 +0000 Subject: [PATCH 2/2] MUL-132: Populate the (e)ORCA UID cache without reading the grids --- src/multio/action/encode/GridDownloader.cc | 27 ++++++++++++++++++---- src/multio/action/encode/GridDownloader.h | 2 ++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/multio/action/encode/GridDownloader.cc b/src/multio/action/encode/GridDownloader.cc index cfed5dcd..e92d31b0 100644 --- a/src/multio/action/encode/GridDownloader.cc +++ b/src/multio/action/encode/GridDownloader.cc @@ -12,6 +12,7 @@ #include "GribEncoder.h" +#include "atlas/grid/SpecRegistry.h" #include "atlas/grid/Grid.h" #include "atlas/grid/Iterator.h" #include "atlas/library.h" @@ -79,6 +80,10 @@ AtlasInstance& AtlasInstance::instance() { GridDownloader::GridDownloader(const config::ComponentConfiguration& compConf) : encoder_(createEncoder(compConf)), templateMetadata_(), gridCoordinatesCache_(), gridUIDCache_() { + ScopedAtlasInstance scopedAtlasInstance; + + populateUIDCache(compConf); + if (encoder_ != nullptr) { initTemplateMetadata(); @@ -109,6 +114,23 @@ std::optional GridDownloader::getGridCoords(const GridDownloade return GridCoordinates{encodedLat, encodedLon}; } +void GridDownloader::populateUIDCache(const config::ComponentConfiguration& compConf) { + if (compConf.parsedConfig().has("unstructured-grid-type")) { + atlas::mpi::Scope mpi_scope("self"); + + const auto baseGridName = compConf.parsedConfig().getString("unstructured-grid-type"); + for (auto const& unstructuredGridSubtype : {"T", "U", "V", "W", "F"}) { + const auto completeGridName = baseGridName + "_" + unstructuredGridSubtype; + + const auto gridSpec = atlas::grid::SpecRegistry::get(completeGridName); + const auto gridUID = gridSpec.getString("uid"); + + gridUIDCache_.emplace(std::piecewise_construct, std::tuple(std::string(unstructuredGridSubtype) + " grid"), + std::tuple(gridUID)); + } + } +} + void GridDownloader::initTemplateMetadata() { templateMetadata_.set("step", 0); templateMetadata_.set("typeOfLevel", "oceanSurface"); @@ -133,8 +155,6 @@ multio::message::Metadata GridDownloader::createMetadataFromCoordsData(size_t gr } void GridDownloader::downloadOrcaGridCoordinates(const config::ComponentConfiguration& compConf) { - ScopedAtlasInstance scopedAtlasInstance; - const auto baseGridName = compConf.parsedConfig().getString("unstructured-grid-type"); for (auto const& unstructuredGridSubtype : {"T", "U", "V", "W", "F"}) { const auto completeGridName = baseGridName + "_" + unstructuredGridSubtype; @@ -147,9 +167,6 @@ void GridDownloader::downloadOrcaGridCoordinates(const config::ComponentConfigur const auto gridUID = grid.uid(); - gridUIDCache_.emplace(std::piecewise_construct, std::tuple(std::string(unstructuredGridSubtype) + " grid"), - std::tuple(gridUID)); - if (encoder_ != nullptr) { const auto gridSize = grid.size(); diff --git a/src/multio/action/encode/GridDownloader.h b/src/multio/action/encode/GridDownloader.h index b7c8f46b..89a5c56b 100644 --- a/src/multio/action/encode/GridDownloader.h +++ b/src/multio/action/encode/GridDownloader.h @@ -76,6 +76,8 @@ class GridDownloader : eckit::NonCopyable { using GridCoordinateCache = std::unordered_map; using GridUIDCache = std::unordered_map; + void populateUIDCache(const config::ComponentConfiguration& compConf); + void initTemplateMetadata(); multio::message::Metadata createMetadataFromCoordsData(size_t gridSize, const std::string& unstructuredGridSubtype, const std::string& gridUID, int paramId);