Commit 0086bbd7 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added function cdfDefineStartAndChunk().

parent ac1b6f91
...@@ -1067,9 +1067,6 @@ void cdf_write_var(stream_t *streamptr, int varID, int memtype, const void *data ...@@ -1067,9 +1067,6 @@ void cdf_write_var(stream_t *streamptr, int varID, int memtype, const void *data
const int vlistID = streamptr->vlistID; const int vlistID = streamptr->vlistID;
const int fileID = streamptr->fileID; const int fileID = streamptr->fileID;
const long ntsteps = streamptr->ntsteps;
if ( CDI_Debug ) Message("ntsteps = %ld", ntsteps);
const int ncvarid = cdfDefVar(streamptr, varID); const int ncvarid = cdfDefVar(streamptr, varID);
const int gridID = vlistInqVarGrid(vlistID, varID); const int gridID = vlistInqVarGrid(vlistID, varID);
...@@ -1098,49 +1095,38 @@ void cdf_write_var(stream_t *streamptr, int varID, int memtype, const void *data ...@@ -1098,49 +1095,38 @@ void cdf_write_var(stream_t *streamptr, int varID, int memtype, const void *data
cdf_write_var_data(fileID, vlistID, varID, ncvarid, dtype, nvals, xsize, ysize, swapxy, start, count, memtype, data, nmiss); cdf_write_var_data(fileID, vlistID, varID, ncvarid, dtype, nvals, xsize, ysize, swapxy, start, count, memtype, data, nmiss);
} }
static
void cdf_write_var_chunk(stream_t *streamptr, int varID, int memtype, void cdfDefineStartAndCountChunk(stream_t *streamptr, const int rect[][2], int varID, int xid, int yid, int zid, size_t start[5], size_t count[5], size_t *xsize, size_t *ysize)
const int rect[][2], const void *data, size_t nmiss)
{ {
if ( streamptr->accessmode == 0 ) cdfEndDef(streamptr);
size_t xsize = 0, ysize = 0;
size_t start[5], count[5];
size_t ndims = 0; size_t ndims = 0;
const int streamID = streamptr->self; *xsize = 0;
*ysize = 0;
if ( CDI_Debug )
Message("streamID = %d varID = %d", streamID, varID);
const int vlistID = streamInqVlist(streamID); const int vlistID = streamptr->vlistID;
const int fileID = streamInqFileID(streamID); const int fileID = streamptr->fileID;
const long ntsteps = streamptr->ntsteps; const long ntsteps = streamptr->ntsteps;
if ( CDI_Debug ) Message("ntsteps = %ld", ntsteps); if ( CDI_Debug ) Message("ntsteps = %ld", ntsteps);
const int ncvarid = cdfDefVar(streamptr, varID);
const int gridID = vlistInqVarGrid(vlistID, varID);
const int zaxisID = vlistInqVarZaxis(vlistID, varID);
const int timetype = vlistInqVarTimetype(vlistID, varID); const int timetype = vlistInqVarTimetype(vlistID, varID);
int xid, yid, zid;
cdfGetXYZid(streamptr, gridID, zaxisID, &xid, &yid, &zid);
if ( vlistHasTime(vlistID) && timetype != TIME_CONSTANT ) if ( vlistHasTime(vlistID) && timetype != TIME_CONSTANT )
{ {
start[ndims] = (size_t)ntsteps - 1; start[ndims] = (size_t)ntsteps - 1;
count[ndims] = 1; count[ndims] = 1;
ndims++; ndims++;
} }
if ( zid != CDI_UNDEFID ) if ( zid != CDI_UNDEFID )
{ {
const int zaxisID = vlistInqVarZaxis(vlistID, varID);
int size = zaxisInqSize(zaxisID); int size = zaxisInqSize(zaxisID);
xassert(rect[2][0] >= 0 && rect[2][0] <= rect[2][1] && rect[2][1] <= size); xassert(rect[2][0] >= 0 && rect[2][0] <= rect[2][1] && rect[2][1] <= size);
start[ndims] = (size_t)rect[2][0]; start[ndims] = (size_t)rect[2][0];
count[ndims] = (size_t)rect[2][1] - (size_t)rect[2][0] + 1; count[ndims] = (size_t)rect[2][1] - (size_t)rect[2][0] + 1;
ndims++; ndims++;
} }
if ( yid != CDI_UNDEFID ) if ( yid != CDI_UNDEFID )
{ {
size_t size; size_t size;
...@@ -1150,6 +1136,7 @@ void cdf_write_var_chunk(stream_t *streamptr, int varID, int memtype, ...@@ -1150,6 +1136,7 @@ void cdf_write_var_chunk(stream_t *streamptr, int varID, int memtype,
count[ndims] = (size_t)rect[1][1] - (size_t)rect[1][0] + 1; count[ndims] = (size_t)rect[1][1] - (size_t)rect[1][0] + 1;
ndims++; ndims++;
} }
if ( xid != CDI_UNDEFID ) if ( xid != CDI_UNDEFID )
{ {
size_t size; size_t size;
...@@ -1163,6 +1150,32 @@ void cdf_write_var_chunk(stream_t *streamptr, int varID, int memtype, ...@@ -1163,6 +1150,32 @@ void cdf_write_var_chunk(stream_t *streamptr, int varID, int memtype,
if ( CDI_Debug ) if ( CDI_Debug )
for (size_t idim = 0; idim < ndims; idim++) for (size_t idim = 0; idim < ndims; idim++)
Message("dim = %d start = %d count = %d", idim, start[idim], count[idim]); Message("dim = %d start = %d count = %d", idim, start[idim], count[idim]);
}
void cdf_write_var_chunk(stream_t *streamptr, int varID, int memtype,
const int rect[][2], const void *data, size_t nmiss)
{
if ( streamptr->accessmode == 0 ) cdfEndDef(streamptr);
const int streamID = streamptr->self;
if ( CDI_Debug )
Message("streamID = %d varID = %d", streamID, varID);
const int vlistID = streamInqVlist(streamID);
const int fileID = streamInqFileID(streamID);
const int ncvarid = cdfDefVar(streamptr, varID);
const int gridID = vlistInqVarGrid(vlistID, varID);
const int zaxisID = vlistInqVarZaxis(vlistID, varID);
int xid, yid, zid;
cdfGetXYZid(streamptr, gridID, zaxisID, &xid, &yid, &zid);
size_t xsize, ysize;
size_t start[5], count[5];
cdfDefineStartAndCountChunk(streamptr, rect, varID, xid, yid, zid, start, count, &xsize, &ysize);
if ( streamptr->ncmode == 1 ) if ( streamptr->ncmode == 1 )
{ {
...@@ -1241,9 +1254,6 @@ void cdf_write_var_slice(stream_t *streamptr, int varID, int levelID, int memtyp ...@@ -1241,9 +1254,6 @@ void cdf_write_var_slice(stream_t *streamptr, int varID, int levelID, int memtyp
const int vlistID = streamptr->vlistID; const int vlistID = streamptr->vlistID;
const int fileID = streamptr->fileID; const int fileID = streamptr->fileID;
const long ntsteps = streamptr->ntsteps;
if ( CDI_Debug ) Message("ntsteps = %ld", ntsteps);
const int ncvarid = cdfDefVar(streamptr, varID); const int ncvarid = cdfDefVar(streamptr, varID);
const int gridID = vlistInqVarGrid(vlistID, varID); const int gridID = vlistInqVarGrid(vlistID, varID);
......
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