Commit 77f50eaa authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

netcdf: added support for GRID_TRAJECTORY.

parent 285a76ca
......@@ -2,6 +2,10 @@
* Version 1.9.1 released
2017-09-05 Uwe Schulzweida
* netcdf: added support for GRID_TRAJECTORY
2017-09-01 Uwe Schulzweida
* Implementation of CDI_reduce_dim for z axis
......
......@@ -24,8 +24,8 @@ void cdfReadGridTraj(stream_t *streamptr, int gridID)
int fileID = streamptr->fileID;
int gridindex = vlistGridIndex(vlistID, gridID);
int lonID = streamptr->ncgrid[gridindex].ncIDs[CDF_DIMID_X];
int latID = streamptr->ncgrid[gridindex].ncIDs[CDF_DIMID_Y];
int lonID = streamptr->ncgrid[gridindex].ncIDs[CDF_VARID_X];
int latID = streamptr->ncgrid[gridindex].ncIDs[CDF_VARID_Y];
int tsID = streamptr->curTsID;
size_t index = (size_t)tsID;
......
......@@ -587,7 +587,7 @@ int cdfDefVar(stream_t *streamptr, int varID)
if ( gridtype == GRID_TRAJECTORY )
{
cdf_put_att_text(fileID, ncvarid, "coordinates", 9, "tlon tlat" );
cdf_put_att_text(fileID, ncvarid, "coordinates", 9, "lon lat" );
}
else if ( gridtype == GRID_LONLAT && xid == CDI_UNDEFID && yid == CDI_UNDEFID && gridsize == 1 )
{
......@@ -1002,8 +1002,6 @@ void cdf_write_var(stream_t *streamptr, int varID, int memtype, const void *data
long ntsteps = streamptr->ntsteps;
if ( CDI_Debug ) Message("ntsteps = %ld", ntsteps);
if ( vlistHasTime(vlistID) ) cdfDefTime(streamptr);
int ncvarid = cdfDefVar(streamptr, varID);
int gridID = vlistInqVarGrid(vlistID, varID);
......@@ -1097,10 +1095,7 @@ void cdf_write_var_chunk(stream_t *streamptr, int varID, int memtype,
int fileID = streamInqFileID(streamID);
long ntsteps = streamptr->ntsteps;
if ( CDI_Debug )
Message("ntsteps = %ld", ntsteps);
if ( vlistHasTime(vlistID) ) cdfDefTime(streamptr);
if ( CDI_Debug ) Message("ntsteps = %ld", ntsteps);
int ncvarid = cdfDefVar(streamptr, varID);
......@@ -1197,8 +1192,6 @@ void cdf_write_var_slice(stream_t *streamptr, int varID, int levelID, int memtyp
long ntsteps = streamptr->ntsteps;
if ( CDI_Debug ) Message("ntsteps = %ld", ntsteps);
if ( vlistHasTime(vlistID) ) cdfDefTime(streamptr);
int ncvarid = cdfDefVar(streamptr, varID);
int gridID = vlistInqVarGrid(vlistID, varID);
......
......@@ -1184,10 +1184,12 @@ int cdiStreamDefTimestep_(stream_t *streamptr, int tsID)
}
}
int newtsID = tstepsNewEntry(streamptr);
if ( tsID != newtsID )
Error("Internal problem: tsID = %d newtsID = %d", tsID, newtsID);
if ( tsID > 0 )
{
int newtsID = tstepsNewEntry(streamptr);
if ( tsID != newtsID )
Error("Internal problem: tsID = %d newtsID = %d", tsID, newtsID);
}
streamptr->curTsID = tsID;
......@@ -1607,32 +1609,36 @@ void cdiStreamSetupVlist_(stream_t *streamptr, int vlistID)
}
if (streamptr->filemode == 'w')
switch (streamptr->filetype)
{
#ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC:
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC4:
case CDI_FILETYPE_NC4C:
{
tstepsNewEntry(streamptr); // timestep 0
switch (streamptr->filetype)
{
/* calls cdfDefVars in serial mode but
* cdiPioClientStreamNOP (i.e. nothing) on client ranks
* and cdiPioServerCdfDefVars on server ranks in parallel mode*/
void (*myCdfDefVars)(stream_t *streamptr)
= (void (*)(stream_t *)) namespaceSwitchGet(NSSWITCH_CDF_STREAM_SETUP).func;
myCdfDefVars(streamptr);
}
break;
#ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC:
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC4:
case CDI_FILETYPE_NC4C:
{
/* calls cdfDefVars in serial mode but
* cdiPioClientStreamNOP (i.e. nothing) on client ranks
* and cdiPioServerCdfDefVars on server ranks in parallel mode*/
void (*myCdfDefVars)(stream_t *streamptr)
= (void (*)(stream_t *)) namespaceSwitchGet(NSSWITCH_CDF_STREAM_SETUP).func;
myCdfDefVars(streamptr);
}
break;
#endif
#ifdef HAVE_LIBGRIB
case CDI_FILETYPE_GRB:
case CDI_FILETYPE_GRB2:
gribContainersNew(streamptr);
break;
case CDI_FILETYPE_GRB:
case CDI_FILETYPE_GRB2:
gribContainersNew(streamptr);
break;
#endif
default:
;
}
default:
;
}
}
}
......
......@@ -2771,6 +2771,11 @@ int cdf_define_all_grids(ncgrid_t *ncgrid, int vlistID, ncdim_t *ncdims, int nva
ncgrid[gridindex].gridID = gridID;
ncgrid[gridindex].ncIDs[CDF_DIMID_X] = xdimid;
ncgrid[gridindex].ncIDs[CDF_DIMID_Y] = ydimid;
if ( grid->type == GRID_TRAJECTORY )
{
ncgrid[gridindex].ncIDs[CDF_VARID_X] = xvarid;
ncgrid[gridindex].ncIDs[CDF_VARID_Y] = yvarid;
}
if ( xdimid == CDI_UNDEFID && ydimid == CDI_UNDEFID && grid->size == 1 )
gridDefHasDims(gridID, FALSE);
......@@ -4133,7 +4138,7 @@ int cdfInqTimestep(stream_t * streamptr, int tsID)
if ( nctimevarid != CDI_UNDEFID )
{
int fileID = streamptr->fileID;
size_t index = (size_t)tsID;
size_t index = (size_t)tsID;
if ( streamptr->basetime.lwrf )
{
......
......@@ -97,10 +97,6 @@ void cdfDefTimeValue(stream_t *streamptr, int tsID)
void cdfDefTimestep(stream_t *streamptr, int tsID)
{
int vlistID = streamptr->vlistID;
if ( vlistHasTime(vlistID) ) cdfDefTime(streamptr);
cdfDefTimeValue(streamptr, tsID);
}
......@@ -308,8 +304,7 @@ cdfDefTrajLatLon(stream_t *streamptr, int gridID, int gridindex,
if ( dimlen != 1 )
Error("%c size isn't 1 for %s grid!", dimtype, gridNamePtr(gridInqType(gridID)));
int ncvarid
= ncgrid[gridindex].ncIDs[dimtype == 'X' ? CDF_DIMID_X : CDF_DIMID_Y];
int ncvarid = ncgrid[gridindex].ncIDs[dimtype == 'X' ? CDF_DIMID_X : CDF_DIMID_Y];
if ( ncvarid == CDI_UNDEFID )
{
......@@ -1982,6 +1977,8 @@ void cdfDefVars(stream_t *streamptr)
if ( vlistID == CDI_UNDEFID )
Error("Internal problem! vlist undefined for streamptr %p", streamptr);
if ( vlistHasTime(vlistID) ) cdfDefTime(streamptr);
int ngrids = vlistNgrids(vlistID);
if ( 2*ngrids > MAX_GRIDS_PS ) Error("Internal problem! Too many grids per stream (max=%d)\n", MAX_GRIDS_PS);
for ( int index = 0; index < 2*ngrids; ++index )
......
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