Commit 70ceb220 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Optimized error handling.

parent 316f8d14
......@@ -30,7 +30,6 @@
Ensstat enspctl Ensemble percentiles
*/
#include <cdi.h>
#include "cdo.h"
#include "cdo_int.h"
......@@ -41,7 +40,6 @@
void *Ensstat(void *argument)
{
int nrecs0;
int nmiss;
typedef struct
{
int streamID;
......@@ -78,10 +76,10 @@ void *Ensstat(void *argument)
argc--;
}
int count_data = FALSE;
bool count_data = false;
if ( argc == 1 )
{
if ( strcmp("count", operatorArgv()[nargc-1]) == 0 ) count_data = TRUE;
if ( strcmp("count", operatorArgv()[nargc-1]) == 0 ) count_data = true;
else cdoAbort("Unknown parameter: >%s<", operatorArgv()[nargc-1]);
}
......@@ -153,6 +151,8 @@ void *Ensstat(void *argument)
streamDefVlist(streamID2, vlistID2);
bool lwarning = false;
bool lerror = false;
int tsID = 0;
do
{
......@@ -164,11 +164,23 @@ void *Ensstat(void *argument)
if ( nrecs != nrecs0 )
{
if ( nrecs == 0 )
cdoAbort("Inconsistent ensemble file, too few time steps in %s!", cdoStreamName(fileID)->args);
{
lwarning = true;
cdoWarning("Inconsistent ensemble file, too few time steps in %s!", cdoStreamName(fileID)->args);
}
else if ( nrecs0 == 0 )
{
lwarning = true;
cdoWarning("Inconsistent ensemble file, too few time steps in %s!", cdoStreamName(0)->args);
}
else
cdoAbort("Inconsistent ensemble file, number of records at time step %d of %s and %s differ!",
{
lerror = true;
cdoWarning("Inconsistent ensemble file, number of records at time step %d of %s and %s differ!",
tsID+1, cdoStreamName(0)->args, cdoStreamName(fileID)->args);
}
goto CLEANUP;
}
}
if ( nrecs0 > 0 )
......@@ -196,7 +208,7 @@ void *Ensstat(void *argument)
gridsize = gridInqSize(gridID);
double missval = vlistInqVarMissval(vlistID1, varID);
nmiss = 0;
int nmiss = 0;
#if defined(_OPENMP)
#pragma omp parallel for default(shared)
#endif
......@@ -246,6 +258,11 @@ void *Ensstat(void *argument)
}
while ( nrecs0 > 0 );
CLEANUP:
if ( lwarning ) cdoWarning("Inconsistent ensemble, processed only the first %d timesteps!", tsID);
if ( lerror ) cdoAbort("Inconsistent ensemble, processed only the first %d timesteps!", tsID);
for ( int fileID = 0; fileID < nfiles; fileID++ )
streamClose(ef[fileID].streamID);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment