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

ap2pl: check number of air_pressure levels

parent bccbac99
No related branches found
No related tags found
1 merge request!245M214003/develop
......@@ -12,6 +12,7 @@
*/
#include "cdo_options.h"
#include "cdo_output.h"
#include "process_int.h"
#include "cdo_vlist.h"
#include "field_vinterp.h"
......@@ -194,8 +195,17 @@ public:
if (-1 != airPressID_FL && -1 != airPressID_HL)
{
if (varList1.vars[airPressID_FL].nlevels == varList1.vars[airPressID_HL].nlevels)
cdo_abort("Found two %s variables (%s/%s) with the same number of levels."
" Select one of them before using this operator!",
var_stdname(air_pressure), varList1.vars[airPressID_FL].name, varList1.vars[airPressID_HL].name);
if (varList1.vars[airPressID_FL].nlevels == (varList1.vars[airPressID_HL].nlevels + 1))
std::swap(airPressID_FL, airPressID_HL);
if ((varList1.vars[airPressID_FL].nlevels + 1) != varList1.vars[airPressID_HL].nlevels)
cdo_abort("Unexpected number of % levels in %s and %s. Number of half levels must be the number of full levels plus 1!",
var_stdname(air_pressure), varList1.vars[airPressID_FL].name, varList1.vars[airPressID_HL].name);
}
if (Options::cdoVerbose)
......
......@@ -305,8 +305,10 @@ pressure_level_interpolation(Varray<double> &pressureLevels, bool useHeightLevel
std::vector<int> vertIndex_HL;
if (zaxisID_ML != -1 && gridsize > 0)
{
vertIndex_FL.resize(gridsize * numPL);
if (needVertIndexHalf) vertIndex_HL.resize(gridsize * numPL);
auto num3D = gridsize * numPL;
if (num3D > std::numeric_limits<int>::max()) cdo_abort("gridSize*numLevels=%zu exceeds the limits of integer.", num3D);
vertIndex_FL.resize(num3D);
if (needVertIndexHalf) vertIndex_HL.resize(num3D);
}
if (zaxisID_ML != -1 && varIDs.gheightID != -1 && varIDs.tempID == -1)
......
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