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) ...@@ -1168,19 +1168,18 @@ void streamSync(int streamID)
int cdiStreamDefTimestep_(stream_t *streamptr, int tsID) int cdiStreamDefTimestep_(stream_t *streamptr, int tsID)
{ {
int taxisID = 0;
stream_check_ptr(__func__, streamptr); stream_check_ptr(__func__, streamptr);
if ( CDI_Debug ) Message("streamID = %d tsID = %d", streamptr->self, tsID); if ( CDI_Debug ) Message("streamID = %d tsID = %d", streamptr->self, tsID);
int vlistID = streamptr->vlistID; int vlistID = streamptr->vlistID;
int time_is_varying = vlistHasTime(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 ) if ( time_is_varying )
{ {
taxisID = vlistInqTaxis(vlistID);
if ( taxisID == CDI_UNDEFID ) if ( taxisID == CDI_UNDEFID )
{ {
Warning("taxisID undefined for fileID = %d! Using absolute time axis.", streamptr->self); Warning("taxisID undefined for fileID = %d! Using absolute time axis.", streamptr->self);
...@@ -1188,7 +1187,7 @@ int cdiStreamDefTimestep_(stream_t *streamptr, int tsID) ...@@ -1188,7 +1187,7 @@ int cdiStreamDefTimestep_(stream_t *streamptr, int tsID)
vlistDefTaxis(vlistID, taxisID); vlistDefTaxis(vlistID, taxisID);
} }
} }
*/
if ( tsID > 0 ) if ( tsID > 0 )
{ {
int newtsID = tstepsNewEntry(streamptr); int newtsID = tstepsNewEntry(streamptr);
...@@ -1196,15 +1195,10 @@ int cdiStreamDefTimestep_(stream_t *streamptr, int tsID) ...@@ -1196,15 +1195,10 @@ int cdiStreamDefTimestep_(stream_t *streamptr, int tsID)
Error("Internal problem: tsID = %d newtsID = %d", tsID, newtsID); Error("Internal problem: tsID = %d newtsID = %d", tsID, newtsID);
} }
streamptr->curTsID = tsID;
if ( time_is_varying ) if ( time_is_varying )
{ ptaxisCopy(&streamptr->tsteps[tsID].taxis, taxisPtr(taxisID));
taxis_t *taxisptr1 = taxisPtr(taxisID);
taxis_t *taxisptr2 = &streamptr->tsteps[tsID].taxis;
ptaxisCopy(taxisptr2, taxisptr1);
}
streamptr->curTsID = tsID;
streamptr->ntsteps = tsID + 1; streamptr->ntsteps = tsID + 1;
#ifdef HAVE_LIBNETCDF #ifdef HAVE_LIBNETCDF
...@@ -1616,6 +1610,37 @@ void cdiStreamSetupVlist_(stream_t *streamptr, int vlistID) ...@@ -1616,6 +1610,37 @@ void cdiStreamSetupVlist_(stream_t *streamptr, int vlistID)
if (streamptr->filemode == 'w') if (streamptr->filemode == 'w')
{ {
tstepsNewEntry(streamptr); // timestep 0 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) switch (streamptr->filetype)
{ {
......
...@@ -57,7 +57,7 @@ int cdfDefTimeBounds(int fileID, int nctimevarid, int nctimedimid, const char *t ...@@ -57,7 +57,7 @@ int cdfDefTimeBounds(int fileID, int nctimevarid, int nctimedimid, const char *t
} }
static 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] ) if ( taxis->units && taxis->units[0] )
{ {
...@@ -80,14 +80,12 @@ void cdfDefTimeUnits(char *unitstr, taxis_t* taxis0, taxis_t* taxis) ...@@ -80,14 +80,12 @@ void cdfDefTimeUnits(char *unitstr, taxis_t* taxis0, taxis_t* taxis)
} }
else 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; int year, month, day, hour, minute, second;
cdiDecodeDate(rdate, &year, &month, &day); cdiDecodeDate(taxis->rdate, &year, &month, &day);
cdiDecodeTime(rtime, &hour, &minute, &second); cdiDecodeTime(taxis->rtime, &hour, &minute, &second);
if ( timeunit == TUNIT_QUARTER ) timeunit = TUNIT_MINUTE; 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_30MINUTES ) timeunit = TUNIT_MINUTE;
else if ( timeunit == TUNIT_3HOURS else if ( timeunit == TUNIT_3HOURS
|| timeunit == TUNIT_6HOURS || timeunit == TUNIT_6HOURS
......
...@@ -379,6 +379,7 @@ void taxisDefRdate(int taxisID, int rdate) ...@@ -379,6 +379,7 @@ void taxisDefRdate(int taxisID, int rdate)
if (taxisptr->rdate != rdate) if (taxisptr->rdate != rdate)
{ {
taxisptr->rdate = rdate; taxisptr->rdate = rdate;
if ( taxisptr->units ) if ( taxisptr->units )
{ {
delete_refcount_string(taxisptr->units); delete_refcount_string(taxisptr->units);
...@@ -1084,8 +1085,8 @@ double vtime2timeval(int vdate, int vtime, taxis_t *taxis) ...@@ -1084,8 +1085,8 @@ double vtime2timeval(int vdate, int vtime, taxis_t *taxis)
int rtime = (*taxis).rtime; int rtime = (*taxis).rtime;
if ( rdate == -1 ) if ( rdate == -1 )
{ {
rdate = (*taxis).vdate; rdate = (*taxis).vdate;
rtime = (*taxis).vtime; rtime = (*taxis).vtime;
} }
if ( rdate == 0 && rtime == 0 && vdate == 0 && vtime == 0 ) return value; if ( rdate == 0 && rtime == 0 && vdate == 0 && vtime == 0 ) return value;
...@@ -1392,6 +1393,7 @@ void ptaxisCopy(taxis_t *dest, taxis_t *source) ...@@ -1392,6 +1393,7 @@ void ptaxisCopy(taxis_t *dest, taxis_t *source)
dest->units = dup_refcount_string(source->units); dest->units = dup_refcount_string(source->units);
if (dest->self != CDI_UNDEFID) if (dest->self != CDI_UNDEFID)
reshSetStatus(dest->self, &taxisOps, RESH_DESYNC_IN_USE); reshSetStatus(dest->self, &taxisOps, RESH_DESYNC_IN_USE);
reshUnlock (); 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