Commit 4200a8fe authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

stream_gribapi: changed type of date to int64_t.

parent 2af1dde1
......@@ -138,24 +138,24 @@ void gribapiGetSteps(grib_handle *gh, int timeunits, int *startStep, int *endSte
}
static
void gribapiGetDataDateTime(grib_handle *gh, int *datadate, int *datatime)
void gribapiGetDataDateTime(grib_handle *gh, int64_t *datadate, int *datatime)
{
long lpar;
GRIB_CHECK(grib_get_long(gh, "dataDate", &lpar), 0);
*datadate = (int) lpar;
*datadate = (int64_t) lpar;
GRIB_CHECK(grib_get_long(gh, "dataTime", &lpar), 0); //FIXME: This looses the seconds in GRIB2 files.
*datatime = (int) lpar*100;
}
static
void gribapiSetDataDateTime(grib_handle *gh, int datadate, int datatime)
void gribapiSetDataDateTime(grib_handle *gh, int64_t datadate, int datatime)
{
GRIB_CHECK(my_grib_set_long(gh, "dataDate", datadate), 0);
GRIB_CHECK(my_grib_set_long(gh, "dataDate", (long)datadate), 0);
GRIB_CHECK(my_grib_set_long(gh, "dataTime", datatime/100), 0);
}
static
int gribapiGetValidityDateTime(grib_handle *gh, int *vdate, int *vtime)
int gribapiGetValidityDateTime(grib_handle *gh, int64_t *vdate, int *vtime)
{
int tstepRange = 0;
......@@ -171,7 +171,8 @@ int gribapiGetValidityDateTime(grib_handle *gh, int *vdate, int *vtime)
}
else
{
int rdate, rtime;
int64_t rdate;
int rtime;
gribapiGetDataDateTime(gh, &rdate, &rtime);
int timeUnits = gribapiGetTimeUnits(gh);
......@@ -852,7 +853,8 @@ int gribapiScanTimestep1(stream_t * streamptr)
int nrecs_scanned = 0; //Only used for debug output.
bool warn_time = true;
// bool warn_numavg = true;
int rdate = 0, rtime = 0, tunit = 0, fcast = 0;
int64_t rdate = 0;
int rtime = 0, tunit = 0, fcast = 0;
grib_handle *gh = NULL;
streamptr->curTsID = 0;
......@@ -901,7 +903,8 @@ int gribapiScanTimestep1(stream_t * streamptr)
int tsteptype = gribapiGetTsteptype(gh);
int vdate = 0, vtime = 0;
int64_t vdate = 0;
int vtime = 0;
gribapiGetValidityDateTime(gh, &vdate, &vtime);
DateTime datetime = { .date = vdate, .time = vtime };
......@@ -960,7 +963,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
{
char paramstr[32];
cdiParamToString(param, paramstr, sizeof(paramstr));
Message("%4u %8d name=%s id=%s ltype=%d lev1=%d lev2=%d vdate=%d vtime=%d",
Message("%4u %8d name=%s id=%s ltype=%d lev1=%d lev2=%d vdate=%lld vtime=%d",
nrecs, (int)recpos, varname, paramstr, leveltype1, level1, level2, vdate, vtime);
}
......@@ -988,7 +991,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
taxisID = taxisCreate(taxis->type);
taxis->rdate = rdate;
taxis->rtime = rtime;
taxis->vdate = (int)datetime0.date;
taxis->vdate = (int64_t)datetime0.date;
taxis->vtime = (int)datetime0.time;
int vlistID = streamptr->vlistID;
......@@ -1111,7 +1114,8 @@ int gribapiScanTimestep2(stream_t * streamptr)
varname[0] = 0;
gribapiGetString(gh, "shortName", varname, sizeof(varname));
int vdate = 0, vtime = 0;
int64_t vdate = 0;
int vtime = 0;
gribapiGetValidityDateTime(gh, &vdate, &vtime);
if ( rindex == 0 )
......@@ -1186,7 +1190,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
{
char paramstr[32];
cdiParamToString(param, paramstr, sizeof(paramstr));
Message("%4d %8d name=%s id=%s ltype=%d lev1=%d lev2=%d vdate=%d vtime=%d",
Message("%4d %8d name=%s id=%s ltype=%d lev1=%d lev2=%d vdate=%lld vtime=%d",
nrecs_scanned, (int)recpos, varname, paramstr, leveltype1, level1, level2, vdate, vtime);
}
......@@ -1339,7 +1343,8 @@ int gribapiScanTimestep(stream_t * streamptr)
varname[0] = 0;
gribapiGetString(gh, "shortName", varname, sizeof(varname));
int vdate = 0, vtime = 0;
int64_t vdate = 0;
int vtime = 0;
gribapiGetValidityDateTime(gh, &vdate, &vtime);
if ( rindex == nrecs ) break;
......@@ -1422,7 +1427,7 @@ int gribapiScanTimestep(stream_t * streamptr)
streamptr->tsteps[tsID].recIDs[rindex] = recID;
if ( CDI_Debug )
Message("%4d %8d %4d %8d %8d %6d", rindex+1, (int)recpos, param, level1, vdate, vtime);
Message("%4d %8d %4d %8d %8lld %6d", rindex+1, (int)recpos, param, level1, vdate, vtime);
if ( gribapiVarCompare(compVar, streamptr->tsteps[tsID].records[recID], 0) != 0 )
{
......@@ -1437,7 +1442,7 @@ int gribapiScanTimestep(stream_t * streamptr)
streamptr->tsteps[tsID].records[recID].size = recsize;
if ( CDI_Debug )
Message("%4d %8d %4d %8d %8d %6d", rindex, (int)recpos, param, level1, vdate, vtime);
Message("%4d %8d %4d %8d %8lld %6d", rindex, (int)recpos, param, level1, vdate, vtime);
grib_handle_delete(gh);
gh = NULL;
......@@ -1780,7 +1785,7 @@ int gribapiDefSteptype(int editionNumber, grib_handle *gh, int productDefinition
}
static
void gribapiDefDateTimeAbs(int editionNumber, grib_handle *gh, int date, int time, int productDefinitionTemplate, int typeOfGeneratingProcess, int tsteptype, int gcinit)
void gribapiDefDateTimeAbs(int editionNumber, grib_handle *gh, int64_t date, int time, int productDefinitionTemplate, int typeOfGeneratingProcess, int tsteptype, int gcinit)
{
(void ) gribapiDefSteptype(editionNumber, gh, productDefinitionTemplate, typeOfGeneratingProcess, tsteptype, gcinit);
......@@ -1792,7 +1797,7 @@ void gribapiDefDateTimeAbs(int editionNumber, grib_handle *gh, int date, int tim
}
static
int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rtime, int vdate, int vtime,
int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int64_t rdate, int rtime, int vdate, int vtime,
int productDefinitionTemplate, int typeOfGeneratingProcess, int tsteptype, int timeunit, int calendar, int gcinit)
{
int status = -1;
......@@ -1849,7 +1854,7 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti
static
void gribapiDefTime(int editionNumber, int productDefinitionTemplate, int typeOfGeneratingProcess, grib_handle *gh,
int vdate, int vtime, int tsteptype, int numavg, int taxisID, int gcinit)
int64_t vdate, int vtime, int tsteptype, int numavg, int taxisID, int gcinit)
{
UNUSED(numavg);
......@@ -1871,7 +1876,7 @@ void gribapiDefTime(int editionNumber, int productDefinitionTemplate, int typeOf
if ( taxistype == TAXIS_RELATIVE )
{
int calendar = taxisInqCalendar(taxisID);
int rdate = taxisInqRdate(taxisID);
int64_t rdate = taxisInqRdate(taxisID);
int rtime = taxisInqRtime(taxisID);
int timeunit = taxisInqTunit(taxisID);
......@@ -2969,7 +2974,7 @@ void gribapiSetExtMode(grib_handle *gh, int gridID, size_t datasize, const doubl
/* #define GRIBAPIENCODETEST 1 */
size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisID,
int vdate, int vtime, int tsteptype, int numavg,
int64_t vdate, int vtime, int tsteptype, int numavg,
size_t datasize, const double *data, size_t nmiss, void **gribbuffer, size_t *gribbuffersize,
int comptype, void *gribContainer)
{
......@@ -3110,7 +3115,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
my_grib_set_double(gh, vlistptr->vars[varID].opt_grib_kvpair[i].keyword,
vlistptr->vars[varID].opt_grib_kvpair[i].dbl_val);
GRIB_CHECK(ret, 0);
}
}
if (vlistptr->vars[varID].opt_grib_kvpair[i].data_type == t_int)
{
if ( CDI_Debug )
......
......@@ -13,7 +13,7 @@ int gribapiDecode(void *gribbuffer, size_t gribsize, double *data, size_t datasi
int unreduced, size_t *nmiss, double missval, int vlistID, int varID);
size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisID,
int vdate, int vtime, int tsteptype, int numavg,
int64_t vdate, int vtime, int tsteptype, int numavg,
size_t datasize, const double *data, size_t nmiss, void **gribbuffer, size_t *gribbuffersize,
int ljpeg, void *gribContainer);
......
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