Commit 5f01cbca authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Replaced xdimID/ydimID by ncgrid.

parent b3335c81
......@@ -27,8 +27,8 @@ void cdfReadGridTraj(stream_t *streamptr, int gridID)
int fileID = streamptr->fileID;
int gridindex = vlistGridIndex(vlistID, gridID);
int lonID = streamptr->xdimID[gridindex];
int latID = streamptr->ydimID[gridindex];
int lonID = streamptr->ncgrid[gridindex].xdimID;
int latID = streamptr->ncgrid[gridindex].ydimID;
int tsID = streamptr->curTsID;
size_t index = (size_t)tsID;
......@@ -60,8 +60,8 @@ void cdfGetSlapDescription(stream_t *streamptr, int varID, size_t (*start)[4], s
}
else
{
xid = streamptr->xdimID[gridindex];
yid = streamptr->ydimID[gridindex];
xid = streamptr->ncgrid[gridindex].xdimID;
yid = streamptr->ncgrid[gridindex].ydimID;
}
int zaxisindex = vlistZaxisIndex(vlistID, zaxisID);
int zid = streamptr->zaxisID[zaxisindex];
......@@ -373,12 +373,12 @@ void cdfInqDimIds(stream_t *streamptr, int varId, int (*outDimIds)[3])
break;
case GRID_UNSTRUCTURED:
(*outDimIds)[0] = streamptr->xdimID[gridindex];
(*outDimIds)[0] = streamptr->ncgrid[gridindex].xdimID;
break;
default:
(*outDimIds)[0] = streamptr->xdimID[gridindex];
(*outDimIds)[1] = streamptr->ydimID[gridindex];
(*outDimIds)[0] = streamptr->ncgrid[gridindex].xdimID;
(*outDimIds)[1] = streamptr->ncgrid[gridindex].ydimID;
break;
}
......
......@@ -245,9 +245,7 @@ typedef struct {
int ncmode;
int vlistID;
#ifdef HAVE_LIBNETCDF
ncgrid_t *ncgrid;
int xdimID[MAX_GRIDS_PS];
int ydimID[MAX_GRIDS_PS];
ncgrid_t ncgrid[MAX_GRIDS_PS];
int zaxisID[MAX_ZAXES_PS]; //Warning: synchronous array to vlist_to_pointer(vlistID)->zaxisIDs
int nczvarID[MAX_ZAXES_PS];
VCT vct;
......
......@@ -637,7 +637,7 @@ int streamOpenA(const char *filename, const char *filemode, int filetype)
if ( status < 0 ) return status;
vlist_t *vlistptr = vlist_to_pointer(streamptr->vlistID);
vlistptr->ntsteps = (int)cdiInqTimeSize(streamID);
if(!strcmp(filemode, "r")) cdiVlistMakeImmutable(streamptr->vlistID);
if ( !strcmp(filemode, "r") ) cdiVlistMakeImmutable(streamptr->vlistID);
{
void (*streamCloseDelegate)(stream_t *streamptr, int recordBufIsToBeDeleted)
......@@ -880,13 +880,18 @@ void streamDefaultValue ( stream_t * streamptr )
basetimeInit(&streamptr->basetime);
#ifdef HAVE_LIBNETCDF
int i;
for ( i = 0; i < MAX_GRIDS_PS; i++ ) streamptr->xdimID[i] = CDI_UNDEFID;
for ( i = 0; i < MAX_GRIDS_PS; i++ ) streamptr->ydimID[i] = CDI_UNDEFID;
for ( i = 0; i < MAX_ZAXES_PS; i++ ) streamptr->zaxisID[i] = CDI_UNDEFID;
for ( i = 0; i < MAX_ZAXES_PS; i++ ) streamptr->nczvarID[i] = CDI_UNDEFID;
for ( int i = 0; i < MAX_ZAXES_PS; i++ ) streamptr->zaxisID[i] = CDI_UNDEFID;
for ( int i = 0; i < MAX_ZAXES_PS; i++ ) streamptr->nczvarID[i] = CDI_UNDEFID;
streamptr->ncgrid = NULL;
for ( int i = 0; i < MAX_GRIDS_PS; i++ )
{
streamptr->ncgrid[i].gridID = CDI_UNDEFID;
streamptr->ncgrid[i].xdimID = CDI_UNDEFID;
streamptr->ncgrid[i].ydimID = CDI_UNDEFID;
streamptr->ncgrid[i].xvarID = CDI_UNDEFID;
streamptr->ncgrid[i].yvarID = CDI_UNDEFID;
streamptr->ncgrid[i].avarID = CDI_UNDEFID;
}
streamptr->vct.ilev = 0;
streamptr->vct.mlev = 0;
......@@ -966,7 +971,6 @@ void cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDelet
case CDI_FILETYPE_NC4C:
{
cdfClose(fileID);
if ( streamptr->ncgrid ) { Free(streamptr->ncgrid); streamptr->ncgrid = NULL; }
break;
}
#endif
......
......@@ -2529,7 +2529,7 @@ void cdf_set_grid_to_similar_vars(ncvar_t *ncvar1, ncvar_t *ncvar2, int gridtype
}
static
void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nvars, ncvar_t *ncvars,
void cdf_define_all_grids(ncgrid_t *ncgrid, int vlistID, ncdim_t *ncdims, int nvars, ncvar_t *ncvars,
int timedimid, unsigned char *uuidOfHGrid, char *gridfile, int number_of_grid_used)
{
for ( int ncvarid = 0; ncvarid < nvars; ++ncvarid )
......@@ -2655,8 +2655,10 @@ void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( ncvar->chunked ) grid_set_chunktype(grid, ncvar);
int gridindex = vlistGridIndex(vlistID, gridID);
streamptr->xdimID[gridindex] = xdimid;
streamptr->ydimID[gridindex] = ydimid;
ncgrid[gridindex].gridID = gridID;
ncgrid[gridindex].xdimID = xdimid;
ncgrid[gridindex].ydimID = ydimid;
if ( xdimid == UNDEFID && ydimid == UNDEFID && grid->size == 1 )
gridDefHasDims(gridID, FALSE);
......@@ -2997,8 +2999,8 @@ void cdf_define_all_vars(stream_t *streamptr, int vlistID, int instID, int model
vlistInqVarGrid(vlistID, varID), vlistInqVarZaxis(vlistID, varID));
int gridindex = vlistGridIndex(vlistID, gridID);
int xdimid = streamptr->xdimID[gridindex];
int ydimid = streamptr->ydimID[gridindex];
int xdimid = streamptr->ncgrid[gridindex].xdimID;
int ydimid = streamptr->ncgrid[gridindex].ydimID;
int zaxisindex = vlistZaxisIndex(vlistID, zaxisID);
int zdimid = streamptr->zaxisID[zaxisindex];
......@@ -3749,7 +3751,7 @@ int cdfInqContents(stream_t *streamptr)
if ( CDI_Debug ) cdf_print_vars(ncvars, nvars, "cdf_define_all_grids");
/* define all grids */
cdf_define_all_grids(streamptr, vlistID, ncdims, nvars, ncvars, timedimid, uuidOfHGrid, gridfile, number_of_grid_used);
cdf_define_all_grids(streamptr->ncgrid, vlistID, ncdims, nvars, ncvars, timedimid, uuidOfHGrid, gridfile, number_of_grid_used);
/* define all zaxes */
......
......@@ -2058,7 +2058,7 @@ void cdfDefVars(stream_t *streamptr)
Error("Internal problem! vlist undefined for streamptr %p", streamptr);
int ngrids = vlistNgrids(vlistID);
streamptr->ncgrid = (ncgrid_t*) Malloc(2*ngrids*sizeof(ncgrid_t));
if ( 2*ngrids > MAX_GRIDS_PS ) Error("Internaal problem! Too many grids per stream (max=%d)\n", MAX_GRIDS_PS);
for ( index = 0; index < 2*ngrids; ++index )
{
streamptr->ncgrid[index].gridID = CDI_UNDEFID;
......
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