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

Simplify if statement.

parent 59a97521
No related branches found
No related tags found
1 merge request!34Version 2.2.0
......@@ -148,24 +148,17 @@ grb_read_raw_data(stream_t *streamptr, int recID, int memtype, void *gribbuffer,
}
else
{
if (recsize == 0) Error("Internal problem! Recordsize is zero for record %d at timestep %d", recID + 1, tsID + 1);
const int fileID = streamptr->fileID;
const off_t recpos = streamptr->tsteps[tsID].records[recID].position;
const off_t currentfilepos = (resetFilePos ? fileGetPos(fileID) : 0);
if (recsize == 0) Error("Internal problem! Recordsize is zero for record %d at timestep %d", recID + 1, tsID + 1);
fileSetPos(fileID, recpos, SEEK_SET);
if (fileRead(fileID, gribbuffer, recsize) != recsize) Error("Failed to read GRIB record!");
if (resetFilePos)
{
const off_t currentfilepos = fileGetPos(fileID);
fileSetPos(fileID, recpos, SEEK_SET);
if (fileRead(fileID, gribbuffer, recsize) != recsize) Error("Failed to read GRIB record!");
fileSetPos(fileID, currentfilepos, SEEK_SET);
}
else
{
fileSetPos(fileID, recpos, SEEK_SET);
if (fileRead(fileID, gribbuffer, recsize) != recsize) Error("Failed to read GRIB record!");
streamptr->numvals += gridsize;
}
if (resetFilePos) fileSetPos(fileID, currentfilepos, SEEK_SET);
if (!resetFilePos) streamptr->numvals += gridsize;
}
return (DecodeArgs){
......
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