Skip to content
Snippets Groups Projects
Commit a1367ce7 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Remapgrid: add support for multi remap files

parent 442ef4c8
No related branches found
No related tags found
1 merge request!143M214003/develop
......@@ -31,6 +31,7 @@
#include "griddes.h"
#include "cdo_options.h"
#include "util_string.h"
#include "util_wildcards.h"
static int
maptype_to_operfunc(const RemapSwitches &remapSwitches)
......@@ -294,7 +295,7 @@ class ModuleRemapgrid
bool remap_genweights = Options::REMAP_genweights;
int numRemaps = 0;
int numNeighbors = 0;
std::string remapWeightsFile;
std::vector<std::string> remapWeightsFiles;
CdoStreamID streamID1;
int taxisID1;
......@@ -356,7 +357,7 @@ public:
{
operator_input_arg("grid description file or name, remap weights file (SCRIP NetCDF)");
operator_check_argc(2);
remapWeightsFile = cdo_operator_argv(1);
remapWeightsFiles.push_back(cdo_operator_argv(1));
}
else
{
......@@ -408,13 +409,27 @@ public:
if (doRemap)
{
numRemaps = 1;
int gridIndex1;
for (gridIndex1 = 0; gridIndex1 < numGrids; ++gridIndex1)
if (remapGrids[gridIndex1]) break;
auto gridID1 = vlistGrid(vlistID1, gridIndex1);
remapSwitches = remap_read_weights(remapWeightsFile, gridID1, gridID2, remaps[0], extrapolateIsSet, remapExtrapolate);
operfunc = maptype_to_operfunc(remapSwitches);
remapWeightsFiles = expand_path_names(remapWeightsFiles);
for (auto &remapWeightsFile : remapWeightsFiles)
{
// printf("read remapWeightsFile %d: %s\n", numRemaps+1, remapWeightsFile.c_str());
auto &remap = remaps[numRemaps];
remapSwitches = remap_read_weights(remapWeightsFile, gridID1, gridID2, remap, extrapolateIsSet, remapExtrapolate);
if (numRemaps == 0)
{
operfunc = maptype_to_operfunc(remapSwitches);
}
else if (operfunc != maptype_to_operfunc(remapSwitches))
{
cdo_abort("Remapping method changed in input weights files!");
}
numRemaps++;
}
}
else
{
......@@ -662,7 +677,7 @@ public:
}
if (doRemap && remap_genweights && remaps[0].nused == 0)
remap_print_warning(remapWeightsFile, operfunc, remaps[0].srcGrid, remaps[0].nmiss);
remap_print_warning(remapWeightsFiles[0], operfunc, remaps[0].srcGrid, remaps[0].nmiss);
for (int remapIndex = 0; remapIndex < numRemaps; remapIndex++)
{
......
......@@ -165,6 +165,7 @@ public:
int tsID = 0;
auto nrecs = cdo_stream_inq_timestep(streamID1, tsID);
int gridIDout = -1;
for (int recID = 0; recID < nrecs; ++recID)
{
int varID, levelID;
......@@ -178,6 +179,15 @@ public:
if (remapGrids[gridIndex])
{
if (numRemaps == 0)
{
gridIDout = var.gridID;
}
else if (gridIDout != var.gridID)
{
continue;
}
if (mapType != RemapMethod::CONSERV_SCRIP && mapType != RemapMethod::CONSERV && var.gridType == GRID_GME)
cdo_abort("Only conservative remapping is available to remap between GME grids!");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment