Commit 07d24d53 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Set default reference date of netCDF data to 10101.

parent 18ce726d
......@@ -1168,19 +1168,18 @@ void streamSync(int streamID)
int cdiStreamDefTimestep_(stream_t *streamptr, int tsID)
{
int taxisID = 0;
stream_check_ptr(__func__, streamptr);
if ( CDI_Debug ) Message("streamID = %d tsID = %d", streamptr->self, tsID);
int vlistID = streamptr->vlistID;
int time_is_varying = vlistHasTime(vlistID);
int taxisID = vlistInqTaxis(vlistID) ;
/* moved to cdiStreamSetupVlist
int taxisID = time_is_varying ? vlistInqTaxis(vlistID) : CDI_UNDEFID;
if ( time_is_varying )
{
taxisID = vlistInqTaxis(vlistID);
if ( taxisID == CDI_UNDEFID )
{
Warning("taxisID undefined for fileID = %d! Using absolute time axis.", streamptr->self);
......@@ -1188,7 +1187,7 @@ int cdiStreamDefTimestep_(stream_t *streamptr, int tsID)
vlistDefTaxis(vlistID, taxisID);
}
}
*/
if ( tsID > 0 )
{
int newtsID = tstepsNewEntry(streamptr);
......@@ -1196,15 +1195,10 @@ int cdiStreamDefTimestep_(stream_t *streamptr, int tsID)
Error("Internal problem: tsID = %d newtsID = %d", tsID, newtsID);
}
streamptr->curTsID = tsID;
if ( time_is_varying )
{
taxis_t *taxisptr1 = taxisPtr(taxisID);
taxis_t *taxisptr2 = &streamptr->tsteps[tsID].taxis;
ptaxisCopy(taxisptr2, taxisptr1);
}
ptaxisCopy(&streamptr->tsteps[tsID].taxis, taxisPtr(taxisID));
streamptr->curTsID = tsID;
streamptr->ntsteps = tsID + 1;
#ifdef HAVE_LIBNETCDF
......@@ -1616,6 +1610,37 @@ void cdiStreamSetupVlist_(stream_t *streamptr, int vlistID)
if (streamptr->filemode == 'w')
{
tstepsNewEntry(streamptr); // timestep 0
int vlistID = streamptr->vlistID;
int time_is_varying = vlistHasTime(vlistID);
if ( time_is_varying )
{
int taxisID = vlistInqTaxis(vlistID);
if ( taxisID == CDI_UNDEFID )
{
Warning("taxisID undefined for fileID = %d! Using absolute time axis.", streamptr->self);
taxisID = taxisCreate(TAXIS_ABSOLUTE);
vlistDefTaxis(vlistID, taxisID);
}
if ( taxisInqType(taxisID) == TAXIS_RELATIVE )
switch (streamptr->filetype)
{
#ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC:
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC4:
case CDI_FILETYPE_NC4C:
{
taxis_t *taxisptr = taxisPtr(taxisID);
if ( taxisptr->rdate == -1 ) taxisDefRdate(taxisID, 10101);
}
break;
#endif
default:
;
}
ptaxisCopy(&streamptr->tsteps[0].taxis, taxisPtr(taxisID));
}
switch (streamptr->filetype)
{
......
......@@ -57,7 +57,7 @@ int cdfDefTimeBounds(int fileID, int nctimevarid, int nctimedimid, const char *t
}
static
void cdfDefTimeUnits(char *unitstr, taxis_t* taxis0, taxis_t* taxis)
void cdfDefTimeUnits(char *unitstr, taxis_t *taxis0, taxis_t *taxis)
{
if ( taxis->units && taxis->units[0] )
{
......@@ -80,13 +80,11 @@ void cdfDefTimeUnits(char *unitstr, taxis_t* taxis0, taxis_t* taxis)
}
else
{
int timeunit = taxis->unit != -1 ? taxis->unit : TUNIT_HOUR;
int rdate = taxis->rdate != -1 ? taxis->rdate : taxis->vdate;
int rtime = taxis->rdate != -1 ? taxis->rtime : taxis->vtime;
int year, month, day, hour, minute, second;
cdiDecodeDate(rdate, &year, &month, &day);
cdiDecodeTime(rtime, &hour, &minute, &second);
cdiDecodeDate(taxis->rdate, &year, &month, &day);
cdiDecodeTime(taxis->rtime, &hour, &minute, &second);
int timeunit = taxis->unit != -1 ? taxis->unit : TUNIT_HOUR;
if ( timeunit == TUNIT_QUARTER ) timeunit = TUNIT_MINUTE;
else if ( timeunit == TUNIT_30MINUTES ) timeunit = TUNIT_MINUTE;
else if ( timeunit == TUNIT_3HOURS
......
......@@ -379,6 +379,7 @@ void taxisDefRdate(int taxisID, int rdate)
if (taxisptr->rdate != rdate)
{
taxisptr->rdate = rdate;
if ( taxisptr->units )
{
delete_refcount_string(taxisptr->units);
......@@ -1392,6 +1393,7 @@ void ptaxisCopy(taxis_t *dest, taxis_t *source)
dest->units = dup_refcount_string(source->units);
if (dest->self != CDI_UNDEFID)
reshSetStatus(dest->self, &taxisOps, RESH_DESYNC_IN_USE);
reshUnlock ();
}
......
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