Commit 8b3df29b authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

merge declaration and definition

parent 9d2fb4f1
...@@ -578,18 +578,15 @@ cgribexScanTsConstAdjust(stream_t *streamptr, taxis_t *taxis) ...@@ -578,18 +578,15 @@ cgribexScanTsConstAdjust(stream_t *streamptr, taxis_t *taxis)
int cgribexScanTimestep1(stream_t * streamptr) int cgribexScanTimestep1(stream_t * streamptr)
{ {
int *isec0, *isec1, *isec2, *isec3, *isec4;
double fsec2[512], fsec3[2], *fsec4 = NULL; double fsec2[512], fsec3[2], *fsec4 = NULL;
int lmv = 0, iret = 0; int lmv = 0, iret = 0;
off_t recpos = 0; off_t recpos = 0;
void *gribbuffer = NULL; void *gribbuffer = NULL;
size_t buffersize = 0; size_t buffersize = 0;
int rstatus; int rstatus;
int fileID;
int param = 0; int param = 0;
int level1 = 0, level2 = 0, vdate = 0, vtime = 0; int level1 = 0, level2 = 0, vdate = 0, vtime = 0;
DateTime datetime, datetime0 = { LONG_MIN, LONG_MIN }; DateTime datetime, datetime0 = { LONG_MIN, LONG_MIN };
int tsID;
size_t readsize; size_t readsize;
unsigned nrecords, recID; unsigned nrecords, recID;
int nrecs_scanned = 0; int nrecs_scanned = 0;
...@@ -599,7 +596,6 @@ int cgribexScanTimestep1(stream_t * streamptr) ...@@ -599,7 +596,6 @@ int cgribexScanTimestep1(stream_t * streamptr)
int warn_numavg = TRUE; int warn_numavg = TRUE;
int taxisID = -1; int taxisID = -1;
int rdate = 0, rtime = 0, tunit = 0, fcast = 0; int rdate = 0, rtime = 0, tunit = 0, fcast = 0;
taxis_t *taxis;
int vlistID; int vlistID;
int comptype; int comptype;
long unzipsize; long unzipsize;
...@@ -608,19 +604,19 @@ int cgribexScanTimestep1(stream_t * streamptr) ...@@ -608,19 +604,19 @@ int cgribexScanTimestep1(stream_t * streamptr)
streamptr->curTsID = 0; streamptr->curTsID = 0;
isec0 = streamptr->record->sec0; int *isec0 = streamptr->record->sec0;
isec1 = streamptr->record->sec1; int *isec1 = streamptr->record->sec1;
isec2 = streamptr->record->sec2; int *isec2 = streamptr->record->sec2;
isec3 = streamptr->record->sec3; int *isec3 = streamptr->record->sec3;
isec4 = streamptr->record->sec4; int *isec4 = streamptr->record->sec4;
tsID = tstepsNewEntry(streamptr); int tsID = tstepsNewEntry(streamptr);
taxis = &streamptr->tsteps[tsID].taxis; taxis_t *taxis = &streamptr->tsteps[tsID].taxis;
if ( tsID != 0 ) if ( tsID != 0 )
Error("Internal problem! tstepsNewEntry returns %d", tsID); Error("Internal problem! tstepsNewEntry returns %d", tsID);
fileID = streamptr->fileID; int fileID = streamptr->fileID;
while ( nskip-- > 0 ) while ( nskip-- > 0 )
{ {
...@@ -700,9 +696,7 @@ int cgribexScanTimestep1(stream_t * streamptr) ...@@ -700,9 +696,7 @@ int cgribexScanTimestep1(stream_t * streamptr)
{ {
datetime.date = vdate; datetime.date = vdate;
datetime.time = vtime; datetime.time = vtime;
compvar_t compVar = cgribexVarSet(param, level1, level2, ISEC1_LevelType, ISEC1_TimeRange); compvar_t compVar = cgribexVarSet(param, level1, level2, ISEC1_LevelType, ISEC1_TimeRange);
for ( recID = 0; recID < nrecs; recID++ ) for ( recID = 0; recID < nrecs; recID++ )
{ {
if ( cgribexVarCompare(compVar, streamptr->tsteps[0].records[recID], 0) == 0 ) break; if ( cgribexVarCompare(compVar, streamptr->tsteps[0].records[recID], 0) == 0 ) break;
...@@ -805,56 +799,47 @@ int cgribexScanTimestep1(stream_t * streamptr) ...@@ -805,56 +799,47 @@ int cgribexScanTimestep1(stream_t * streamptr)
int cgribexScanTimestep2(stream_t * streamptr) int cgribexScanTimestep2(stream_t * streamptr)
{ {
int rstatus = 0; int rstatus = 0;
int *isec0, *isec1, *isec2, *isec3, *isec4;
double fsec2[512], fsec3[2], *fsec4 = NULL; double fsec2[512], fsec3[2], *fsec4 = NULL;
int lmv = 0, iret = 0; int lmv = 0, iret = 0;
off_t recpos = 0; off_t recpos = 0;
void *gribbuffer = NULL;
size_t buffersize = 0;
int fileID;
int param = 0; int param = 0;
int level1 = 0, level2 = 0, vdate = 0, vtime = 0; int level1 = 0, level2 = 0, vdate = 0, vtime = 0;
DateTime datetime, datetime0 = { LONG_MIN, LONG_MIN }; DateTime datetime, datetime0 = { LONG_MIN, LONG_MIN };
int tsID;
int varID, gridID; int varID, gridID;
size_t readsize; size_t readsize;
int nrecords, nrecs, recID, rindex; int nrecs, recID;
int nrecs_scanned = 0;
long recsize = 0; long recsize = 0;
int warn_numavg = TRUE; int warn_numavg = TRUE;
int tsteptype; int tsteptype;
int taxisID = -1;
taxis_t *taxis;
int vlistID;
long unzipsize; long unzipsize;
char paramstr[32]; char paramstr[32];
streamptr->curTsID = 1; streamptr->curTsID = 1;
isec0 = streamptr->record->sec0; int *isec0 = streamptr->record->sec0;
isec1 = streamptr->record->sec1; int *isec1 = streamptr->record->sec1;
isec2 = streamptr->record->sec2; int *isec2 = streamptr->record->sec2;
isec3 = streamptr->record->sec3; int *isec3 = streamptr->record->sec3;
isec4 = streamptr->record->sec4; int *isec4 = streamptr->record->sec4;
fileID = streamptr->fileID; int fileID = streamptr->fileID;
vlistID = streamptr->vlistID; int vlistID = streamptr->vlistID;
taxisID = vlistInqTaxis(vlistID); int taxisID = vlistInqTaxis(vlistID);
gribbuffer = streamptr->record->buffer; void *gribbuffer = streamptr->record->buffer;
buffersize = streamptr->record->buffersize; size_t buffersize = streamptr->record->buffersize;
tsID = streamptr->rtsteps; int tsID = streamptr->rtsteps;
if ( tsID != 1 ) if ( tsID != 1 )
Error("Internal problem! unexpected timestep %d", tsID+1); Error("Internal problem! unexpected timestep %d", tsID+1);
taxis = &streamptr->tsteps[tsID].taxis; taxis_t *taxis = &streamptr->tsteps[tsID].taxis;
fileSetPos(fileID, streamptr->tsteps[tsID].position, SEEK_SET); fileSetPos(fileID, streamptr->tsteps[tsID].position, SEEK_SET);
cdi_create_records(streamptr, tsID); cdi_create_records(streamptr, tsID);
nrecords = streamptr->tsteps[tsID].nallrecs; int nrecords = streamptr->tsteps[tsID].nallrecs;
if ( nrecords ) streamptr->tsteps[1].recIDs = (int *) Malloc((size_t)nrecords * sizeof(int)); if ( nrecords ) streamptr->tsteps[1].recIDs = (int *) Malloc((size_t)nrecords * sizeof(int));
streamptr->tsteps[1].nrecs = 0; streamptr->tsteps[1].nrecs = 0;
for ( recID = 0; recID < nrecords; recID++ ) for ( recID = 0; recID < nrecords; recID++ )
...@@ -867,8 +852,8 @@ int cgribexScanTimestep2(stream_t * streamptr) ...@@ -867,8 +852,8 @@ int cgribexScanTimestep2(stream_t * streamptr)
streamptr->tsteps[tsID].records[recID].size = streamptr->tsteps[0].records[recID].size; streamptr->tsteps[tsID].records[recID].size = streamptr->tsteps[0].records[recID].size;
} }
nrecs_scanned = nrecords; int nrecs_scanned = nrecords;
rindex = 0; int rindex = 0;
while ( TRUE ) while ( TRUE )
{ {
if ( rindex > nrecords ) break; if ( rindex > nrecords ) break;
......
...@@ -427,29 +427,23 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh, ...@@ -427,29 +427,23 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
int leveltype1, int leveltype2, int lbounds, int level1, int level2, int level_sf, int level_unit, int leveltype1, int leveltype2, int lbounds, int level1, int level2, int level_sf, int level_unit,
const var_tile_t *tiles, int lread_additional_keys) const var_tile_t *tiles, int lread_additional_keys)
{ {
int zaxistype; int varID;
int gridID = CDI_UNDEFID, varID;
int levelID = 0; int levelID = 0;
int tsID, recID;
int numavg;
int tsteptype;
record_t *record;
grid_t grid; grid_t grid;
int vlistID;
long lpar; long lpar;
int status; int status;
char stdname[CDI_MAX_NAME], longname[CDI_MAX_NAME], units[CDI_MAX_NAME]; char stdname[CDI_MAX_NAME], longname[CDI_MAX_NAME], units[CDI_MAX_NAME];
size_t vlen; size_t vlen;
long ens_index = 0, ens_count = 0, ens_forecast_type = 0; long ens_index = 0, ens_count = 0, ens_forecast_type = 0;
vlistID = streamptr->vlistID; int vlistID = streamptr->vlistID;
tsID = streamptr->curTsID; int tsID = streamptr->curTsID;
recID = recordNewEntry(streamptr, tsID); int recID = recordNewEntry(streamptr, tsID);
record = &streamptr->tsteps[tsID].records[recID]; record_t *record = &streamptr->tsteps[tsID].records[recID];
tsteptype = gribapiGetTsteptype(gh); int tsteptype = gribapiGetTsteptype(gh);
// numavg = ISEC1_AvgNum; // numavg = ISEC1_AvgNum;
numavg = 0; int numavg = 0;
// fprintf(stderr, "param %d %d %d %d\n", param, level1, level2, leveltype1); // fprintf(stderr, "param %d %d %d %d\n", param, level1, level2, leveltype1);
...@@ -477,9 +471,9 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh, ...@@ -477,9 +471,9 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
gribapiGetGrid(gh, &grid); gribapiGetGrid(gh, &grid);
gridID = varDefGrid(vlistID, &grid, 0); int gridID = varDefGrid(vlistID, &grid, 0);
zaxistype = gribapiGetZaxisType(gribEditionNumber(gh), leveltype1); int zaxistype = gribapiGetZaxisType(gribEditionNumber(gh), leveltype1);
switch (zaxistype) switch (zaxistype)
{ {
...@@ -1006,9 +1000,6 @@ int gribapiScanTimestep2(stream_t * streamptr) ...@@ -1006,9 +1000,6 @@ int gribapiScanTimestep2(stream_t * streamptr)
{ {
int rstatus = 0; int rstatus = 0;
off_t recpos = 0; off_t recpos = 0;
unsigned char *gribbuffer = NULL;
size_t buffersize = 0;
int fileID;
DateTime datetime0 = { LONG_MIN, LONG_MIN }; DateTime datetime0 = { LONG_MIN, LONG_MIN };
// int gridID; // int gridID;
int recID; int recID;
...@@ -1017,12 +1008,12 @@ int gribapiScanTimestep2(stream_t * streamptr) ...@@ -1017,12 +1008,12 @@ int gribapiScanTimestep2(stream_t * streamptr)
streamptr->curTsID = 1; streamptr->curTsID = 1;
fileID = streamptr->fileID; int fileID = streamptr->fileID;
int vlistID = streamptr->vlistID; int vlistID = streamptr->vlistID;
int taxisID = vlistInqTaxis(vlistID); int taxisID = vlistInqTaxis(vlistID);
gribbuffer = (unsigned char *) streamptr->record->buffer; unsigned char *gribbuffer = (unsigned char *) streamptr->record->buffer;
buffersize = streamptr->record->buffersize; size_t buffersize = streamptr->record->buffersize;
int tsID = streamptr->rtsteps; int tsID = streamptr->rtsteps;
if ( tsID != 1 ) if ( tsID != 1 )
...@@ -1471,8 +1462,7 @@ int gribapiDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri ...@@ -1471,8 +1462,7 @@ int gribapiDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri
int status = 0; int status = 0;
long lpar; long lpar;
long numberOfPoints; long numberOfPoints;
size_t datasize, dummy, recsize; size_t datasize;
grib_handle *gh = NULL;
UNUSED(vlistID); UNUSED(vlistID);
UNUSED(varID); UNUSED(varID);
...@@ -1488,8 +1478,8 @@ int gribapiDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri ...@@ -1488,8 +1478,8 @@ int gribapiDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri
} }
} }
recsize = (size_t)gribsize; size_t recsize = (size_t)gribsize;
gh = grib_handle_new_from_message(NULL, (void *) gribbuffer, recsize); grib_handle *gh = grib_handle_new_from_message(NULL, (void *) gribbuffer, recsize);
GRIB_CHECK(my_grib_set_double(gh, "missingValue", missval), 0); GRIB_CHECK(my_grib_set_double(gh, "missingValue", missval), 0);
/* get the size of the values array*/ /* get the size of the values array*/
...@@ -1500,12 +1490,11 @@ int gribapiDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri ...@@ -1500,12 +1490,11 @@ int gribapiDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri
if ( gridsize != (int) datasize ) if ( gridsize != (int) datasize )
Error("Internal problem: gridsize(%d) != datasize(%d)!", gridsize, datasize); Error("Internal problem: gridsize(%d) != datasize(%d)!", gridsize, datasize);
dummy = datasize; size_t dummy = datasize;
GRIB_CHECK(grib_get_double_array(gh, "values", data, &dummy), 0); GRIB_CHECK(grib_get_double_array(gh, "values", data, &dummy), 0);
int gridtype;
GRIB_CHECK(grib_get_long(gh, "gridDefinitionTemplateNumber", &lpar), 0); GRIB_CHECK(grib_get_long(gh, "gridDefinitionTemplateNumber", &lpar), 0);
gridtype = (int) lpar; int gridtype = (int) lpar;
*nmiss = 0; *nmiss = 0;
if ( gridtype < 50 || gridtype > 53 ) if ( gridtype < 50 || gridtype > 53 )
...@@ -1735,7 +1724,6 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti ...@@ -1735,7 +1724,6 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti
int status = -1; int status = -1;
int year, month, day, hour, minute, second; int year, month, day, hour, minute, second;
int julday1, secofday1, julday2, secofday2, days, secs; int julday1, secofday1, julday2, secofday2, days, secs;
int factor;
long startStep = 0, endStep; long startStep = 0, endStep;
cdiDecodeDate(rdate, &year, &month, &day); cdiDecodeDate(rdate, &year, &month, &day);
...@@ -1750,7 +1738,7 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti ...@@ -1750,7 +1738,7 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti
(void) julday_sub(julday1, secofday1, julday2, secofday2, &days, &secs); (void) julday_sub(julday1, secofday1, julday2, secofday2, &days, &secs);
factor = getTimeunitFactor(timeunit); int factor = getTimeunitFactor(timeunit);
if ( !(int) fmod(days*86400.0 + secs, factor) ) if ( !(int) fmod(days*86400.0 + secs, factor) )
{ {
...@@ -1828,13 +1816,12 @@ void gribapiDefTime(int editionNumber, int productDefinitionTemplate, int typeOf ...@@ -1828,13 +1816,12 @@ void gribapiDefTime(int editionNumber, int productDefinitionTemplate, int typeOf
static static
void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype, int lieee, int datatype, int nmiss, int gcinit) void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype, int lieee, int datatype, int nmiss, int gcinit)
{ {
int gridtype;
int status; int status;
static short lwarn = TRUE; static short lwarn = TRUE;
UNUSED(nmiss); UNUSED(nmiss);
gridtype = gridInqType(gridID); int gridtype = gridInqType(gridID);
if ( editionNumber <= 1 ) if ( editionNumber <= 1 )
if ( gridtype == GRID_GME || gridtype == GRID_UNSTRUCTURED ) if ( gridtype == GRID_GME || gridtype == GRID_UNSTRUCTURED )
......
Markdown is supported
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