12
12
13
13
#include " GribEncoder.h"
14
14
15
+ #include " atlas/grid/SpecRegistry.h"
15
16
#include " atlas/grid/Grid.h"
16
17
#include " atlas/grid/Iterator.h"
17
18
#include " atlas/library.h"
@@ -79,6 +80,10 @@ AtlasInstance& AtlasInstance::instance() {
79
80
GridDownloader::GridDownloader (const config::ComponentConfiguration& compConf) :
80
81
encoder_ (createEncoder(compConf)), templateMetadata_(), gridCoordinatesCache_(), gridUIDCache_() {
81
82
83
+ ScopedAtlasInstance scopedAtlasInstance;
84
+
85
+ populateUIDCache (compConf);
86
+
82
87
if (encoder_ != nullptr ) {
83
88
initTemplateMetadata ();
84
89
@@ -109,6 +114,23 @@ std::optional<GridCoordinates> GridDownloader::getGridCoords(const GridDownloade
109
114
return GridCoordinates{encodedLat, encodedLon};
110
115
}
111
116
117
+ void GridDownloader::populateUIDCache (const config::ComponentConfiguration& compConf) {
118
+ if (compConf.parsedConfig ().has (" unstructured-grid-type" )) {
119
+ atlas::mpi::Scope mpi_scope (" self" );
120
+
121
+ const auto baseGridName = compConf.parsedConfig ().getString (" unstructured-grid-type" );
122
+ for (auto const & unstructuredGridSubtype : {" T" , " U" , " V" , " W" , " F" }) {
123
+ const auto completeGridName = baseGridName + " _" + unstructuredGridSubtype;
124
+
125
+ const auto gridSpec = atlas::grid::SpecRegistry::get (completeGridName);
126
+ const auto gridUID = gridSpec.getString (" uid" );
127
+
128
+ gridUIDCache_.emplace (std::piecewise_construct, std::tuple (std::string (unstructuredGridSubtype) + " grid" ),
129
+ std::tuple (gridUID));
130
+ }
131
+ }
132
+ }
133
+
112
134
void GridDownloader::initTemplateMetadata () {
113
135
templateMetadata_.set (" step" , 0 );
114
136
templateMetadata_.set (" typeOfLevel" , " oceanSurface" );
@@ -133,8 +155,6 @@ multio::message::Metadata GridDownloader::createMetadataFromCoordsData(size_t gr
133
155
}
134
156
135
157
void GridDownloader::downloadOrcaGridCoordinates (const config::ComponentConfiguration& compConf) {
136
- ScopedAtlasInstance scopedAtlasInstance;
137
-
138
158
const auto baseGridName = compConf.parsedConfig ().getString (" unstructured-grid-type" );
139
159
for (auto const & unstructuredGridSubtype : {" T" , " U" , " V" , " W" , " F" }) {
140
160
const auto completeGridName = baseGridName + " _" + unstructuredGridSubtype;
@@ -147,9 +167,6 @@ void GridDownloader::downloadOrcaGridCoordinates(const config::ComponentConfigur
147
167
148
168
const auto gridUID = grid.uid ();
149
169
150
- gridUIDCache_.emplace (std::piecewise_construct, std::tuple (std::string (unstructuredGridSubtype) + " grid" ),
151
- std::tuple (gridUID));
152
-
153
170
if (encoder_ != nullptr ) {
154
171
const auto gridSize = grid.size ();
155
172
0 commit comments