Commit f45c8837 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Handle record read errors in specific functions.

parent e29c7952
......@@ -829,10 +829,8 @@ void cdf_write_record(stream_t *streamptr, int memtype, const void *data, int nm
#endif
}
int cdfReadRecord(stream_t *streamptr, double *data, int *nmiss)
void cdfReadRecord(stream_t *streamptr, double *data, int *nmiss)
{
int ierr = 0;
int levelID, varID, tsID, recID, vrecID;
if ( CDI_Debug ) Message("streamID = %d", streamptr->self);
......@@ -844,8 +842,6 @@ int cdfReadRecord(stream_t *streamptr, double *data, int *nmiss)
levelID = streamptr->tsteps[tsID].records[recID].levelID;
cdfReadVarSliceDP(streamptr, varID, levelID, data, nmiss);
return (ierr);
}
#if defined (HAVE_LIBNETCDF)
......
......@@ -14,7 +14,7 @@ void cdfDefRecord(stream_t * streamptr);
int cdfCopyRecord(stream_t *streamptr2, stream_t *streamptr1);
int cdfReadRecord(stream_t *streamptr, double *data, int *nmiss);
void cdfReadRecord(stream_t *streamptr, double *data, int *nmiss);
void cdf_write_record(stream_t *streamptr, int memtype, const void *data, int nmiss);
void cdfReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss);
......
......@@ -106,7 +106,7 @@ int extInqRecord(stream_t *streamptr, int *varID, int *levelID)
}
*/
int extReadRecord(stream_t *streamptr, double *data, int *nmiss)
void extReadRecord(stream_t *streamptr, double *data, int *nmiss)
{
int vlistID, fileID;
int status;
......@@ -129,7 +129,8 @@ int extReadRecord(stream_t *streamptr, double *data, int *nmiss)
fileSetPos(fileID, recpos, SEEK_SET);
status = extRead(fileID, extp);
if ( status != 0 ) return (0);
if ( status != 0 )
Error("Failed to read EXTRA record");
extInqHeader(extp, header);
extInqDataDP(extp, data);
......@@ -159,8 +160,6 @@ int extReadRecord(stream_t *streamptr, double *data, int *nmiss)
(*nmiss)++;
}
}
return (1);
}
......
......@@ -11,7 +11,7 @@ int extInqTimestep(stream_t *streamptr, int tsID);
int extInqRecord(stream_t *streamptr, int *varID, int *levelID);
void extDefRecord(stream_t *streamptr);
int extCopyRecord(stream_t *streamptr2, stream_t *streamptr1);
int extReadRecord(stream_t *streamptr, double *data, int *nmiss);
void extReadRecord(stream_t *streamptr, double *data, int *nmiss);
int extWriteRecord(stream_t *streamptr, const double *data);
void extReadVarDP (stream_t *streamptr, int varID, double *data, int *nmiss);
......
......@@ -212,9 +212,8 @@ int grbDecode(int filetype, unsigned char *gribbuffer, int gribsize, double *dat
}
int grbReadRecord(stream_t * streamptr, double *data, int *nmiss)
void grbReadRecord(stream_t * streamptr, double *data, int *nmiss)
{
int status = 0;
unsigned char *gribbuffer;
int fileID;
int recID, vrecID, tsID, gridID, varID;
......@@ -246,15 +245,14 @@ int grbReadRecord(stream_t * streamptr, double *data, int *nmiss)
fileSetPos(fileID, recpos, SEEK_SET);
fileRead(fileID, gribbuffer, (size_t) recsize);
if (fileRead(fileID, gribbuffer, (size_t) recsize) != recsize)
Error("Failed to read GRIB record");
missval = vlistInqVarMissval(vlistID, varID);
grbDecode(filetype, gribbuffer, recsize, data, gridsize, streamptr->unreduced, nmiss, &zip, missval, vlistID, varID);
streamptr->tsteps[tsID].records[recID].zip = zip;
return (status);
}
static
......
......@@ -8,7 +8,7 @@ int grbInqTimestep(stream_t * streamptr, int tsID);
int grbInqRecord(stream_t * streamptr, int *varID, int *levelID);
void grbDefRecord(stream_t * streamptr);
int grbReadRecord(stream_t * streamptr, double *data, int *nmiss);
void grbReadRecord(stream_t * streamptr, double *data, int *nmiss);
int grb_write_record(stream_t * streamptr, int memtype, const void *data, int nmiss);
int grbCopyRecord(stream_t * streamptr2, stream_t * streamptr1);
......
......@@ -99,7 +99,7 @@ int iegInqRecord(stream_t *streamptr, int *varID, int *levelID)
}
*/
int iegReadRecord(stream_t *streamptr, double *data, int *nmiss)
void iegReadRecord(stream_t *streamptr, double *data, int *nmiss)
{
int vlistID, fileID;
int status;
......@@ -121,7 +121,8 @@ int iegReadRecord(stream_t *streamptr, double *data, int *nmiss)
fileSetPos(fileID, recpos, SEEK_SET);
status = iegRead(fileID, iegp);
if ( status != 0 ) return (0);
if ( status != 0 )
Error("Could not read IEG record!");
iegInqDataDP(iegp, data);
......@@ -138,8 +139,6 @@ int iegReadRecord(stream_t *streamptr, double *data, int *nmiss)
data[i] = missval;
(*nmiss)++;
}
return (1);
}
static
......
......@@ -11,7 +11,7 @@ int iegInqTimestep(stream_t *streamptr, int tsID);
int iegInqRecord(stream_t *streamptr, int *varID, int *levelID);
void iegDefRecord(stream_t *streamptr);
int iegCopyRecord(stream_t *streamptr2, stream_t *streamptr1);
int iegReadRecord(stream_t *streamptr, double *data, int *nmiss);
void iegReadRecord(stream_t *streamptr, double *data, int *nmiss);
int iegWriteRecord(stream_t *streamptr, const double *data);
void iegReadVarDP (stream_t *streamptr, int varID, double *data, int *nmiss);
......
......@@ -276,7 +276,6 @@ void streamDefRecord(int streamID, int varID, int levelID)
void streamReadRecord(int streamID, double *data, int *nmiss)
{
int status = 0;
int filetype;
stream_t *streamptr;
......@@ -296,46 +295,31 @@ void streamReadRecord(int streamID, double *data, int *nmiss)
#if defined (HAVE_LIBGRIB)
case FILETYPE_GRB:
case FILETYPE_GRB2:
{
/* FIXME: return value not inspected */
status = grbReadRecord(streamptr, data, nmiss);
break;
}
grbReadRecord(streamptr, data, nmiss);
break;
#endif
#if defined (HAVE_LIBSERVICE)
case FILETYPE_SRV:
{
/* FIXME: return value not inspected */
status = srvReadRecord(streamptr, data, nmiss);
break;
}
srvReadRecord(streamptr, data, nmiss);
break;
#endif
#if defined (HAVE_LIBEXTRA)
case FILETYPE_EXT:
{
/* FIXME: return value not inspected */
status = extReadRecord(streamptr, data, nmiss);
break;
}
extReadRecord(streamptr, data, nmiss);
break;
#endif
#if defined (HAVE_LIBIEG)
case FILETYPE_IEG:
{
/* FIXME: return value not inspected */
status = iegReadRecord(streamptr, data, nmiss);
break;
}
iegReadRecord(streamptr, data, nmiss);
break;
#endif
#if defined (HAVE_LIBNETCDF)
case FILETYPE_NC:
case FILETYPE_NC2:
case FILETYPE_NC4:
case FILETYPE_NC4C:
{
/* FIXME: return value not inspected */
status = cdfReadRecord(streamptr, data, nmiss);
break;
}
cdfReadRecord(streamptr, data, nmiss);
break;
#endif
default:
{
......
......@@ -96,7 +96,7 @@ int srvInqRecord(stream_t *streamptr, int *varID, int *levelID)
}
*/
int srvReadRecord(stream_t *streamptr, double *data, int *nmiss)
void srvReadRecord(stream_t *streamptr, double *data, int *nmiss)
{
int vlistID, fileID;
int status;
......@@ -119,7 +119,8 @@ int srvReadRecord(stream_t *streamptr, double *data, int *nmiss)
fileSetPos(fileID, recpos, SEEK_SET);
status = srvRead(fileID, srvp);
if ( status != 0 ) return (0);
if ( status != 0 )
Error("Failed to read record from SRV file");
srvInqHeader(srvp, header);
srvInqDataDP(srvp, data);
......@@ -137,8 +138,6 @@ int srvReadRecord(stream_t *streamptr, double *data, int *nmiss)
data[i] = missval;
(*nmiss)++;
}
return (1);
}
......
......@@ -11,7 +11,7 @@ int srvInqTimestep(stream_t *streamptr, int tsID);
int srvInqRecord(stream_t *streamptr, int *varID, int *levelID);
void srvDefRecord(stream_t *streamptr);
int srvCopyRecord(stream_t *streamptr2, stream_t *streamptr1);
int srvReadRecord(stream_t *streamptr, double *data, int *nmiss);
void srvReadRecord(stream_t *streamptr, double *data, int *nmiss);
int srvWriteRecord(stream_t *streamptr, const double *data);
void srvReadVarDP (stream_t *streamptr, int varID, double *data, int *nmiss);
......
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