Commit aac562b3 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added function cdfDefForecastTimeUnits()

parent 615f0678
......@@ -854,6 +854,14 @@ void cdfDefTimeValue(stream_t *streamptr, int tsID)
start[0] = tsID; count[0] = 1; start[1] = 1; count[1] = 1;
cdf_put_vara_double(fileID, ncvarid, start, count, &timevalue);
}
ncvarid = streamptr->basetime.leadtimeid;
if ( taxis->type == TAXIS_FORECAST && ncvarid != UNDEFID )
{
timevalue = taxis->fc_period;
cdf_put_var1_double(fileID, ncvarid, &index, &timevalue);
}
/*
printf("fileID = %d %d %d %f\n", fileID, time_varid, index, timevalue);
*/
......@@ -935,6 +943,21 @@ void cdfDefTimeUnits(char *unitstr, taxis_t* taxis0, taxis_t* taxis)
tunitNamePtr(timeunit), year, month, day, hour, minute, second);
}
}
static
void cdfDefForecastTimeUnits(char *unitstr, int timeunit)
{
unitstr[0] = 0;
if ( timeunit == -1 ) timeunit = TUNIT_HOUR;
if ( timeunit == TUNIT_QUARTER ) timeunit = TUNIT_MINUTE;
if ( timeunit == TUNIT_3HOURS ||
timeunit == TUNIT_6HOURS ||
timeunit == TUNIT_12HOURS ) timeunit = TUNIT_HOUR;
sprintf(unitstr, "%s", tunitNamePtr(timeunit));
}
#endif
static
......@@ -1024,6 +1047,26 @@ void cdfDefTime(stream_t* streamptr)
cdfDefCalendar(fileID, time_bndsid, taxis->calendar);
}
if ( taxis->type == TAXIS_FORECAST )
{
int leadtimeid;
cdf_def_var(fileID, "leadtime", NC_DOUBLE, 1, &time_dimid, &leadtimeid);
streamptr->basetime.leadtimeid = leadtimeid;
strcpy(tmpstr, "forecast_period");
cdf_put_att_text(fileID, leadtimeid, "standard_name", strlen(tmpstr), tmpstr);
strcpy(tmpstr, "Time elapsed since the start of the forecast");
cdf_put_att_text(fileID, leadtimeid, "long_name", strlen(tmpstr), tmpstr);
cdfDefForecastTimeUnits(unitstr, taxis->fc_unit);
len = strlen(unitstr);
if ( len ) cdf_put_att_text(fileID, leadtimeid, "units", len, unitstr);
}
if ( streamptr->ncmode == 2 ) cdf_enddef(fileID);
#endif
}
......
......@@ -625,6 +625,12 @@ void taxisCopyTimestep(int taxisID2, int taxisID1)
taxisptr2->vtime_ub = taxisptr1->vtime_ub;
}
taxisptr2->fdate = taxisptr1->fdate;
taxisptr2->ftime = taxisptr1->ftime;
taxisptr2->fc_unit = taxisptr1->fc_unit;
taxisptr2->fc_period = taxisptr1->fc_period;
reshUnlock ();
}
......
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