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

added code to test performance of 2D GRIB container

parent 8cf3ab98
......@@ -39,9 +39,12 @@ const char *gribapiLibraryVersion(void)
void gribContainersNew(int streamID)
{
stream_t *streamptr;
int editionNumber = 2;
streamptr = stream_to_pointer(streamID);
if ( streamptr->filetype == FILETYPE_GRB ) editionNumber = 1;
#if defined (HAVE_LIBCGRIBEX)
if ( streamptr->filetype == FILETYPE_GRB )
{
......@@ -49,19 +52,37 @@ void gribContainersNew(int streamID)
else
#endif
{
int i, editionNumber = 2;
int nvars = streamptr->nvars;
#if defined (GRIBCONTAINER2D)
gribContainer_t **gribContainers;
gribContainers = (gribContainer_t **) malloc(nvars*sizeof(gribContainer_t *));
for ( int varID = 0; varID < nvars; ++varID )
{
int nlevs = streamptr->vars[varID].nlevs;
gribContainers[varID] = (gribContainer_t *) malloc(nlevs*sizeof(gribContainer_t));
for ( int levelID = 0; levelID < nlevs; ++levelID )
{
gribContainers[varID][levelID].gribHandle = gribHandleNew(editionNumber);
gribContainers[varID][levelID].init = FALSE;
}
}
streamptr->gribContainers = (void **) gribContainers;
#else
gribContainer_t *gribContainers;
gribContainers = (gribContainer_t *) malloc(nvars*sizeof(gribContainer_t));
if ( streamptr->filetype == FILETYPE_GRB ) editionNumber = 1;
for ( int varID = 0; varID < nvars; ++varID )
{
gribContainers[varID].gribHandle = gribHandleNew(editionNumber);
gribContainers[varID].init = FALSE;
}
gribContainers = (gribContainer_t *) malloc(streamptr->nvars*sizeof(gribContainer_t));
streamptr->gribContainers = (void *) gribContainers;
for ( i = 0; i < streamptr->nvars; ++i )
{
gribContainers[i].gribHandle = gribHandleNew(editionNumber);
gribContainers[i].init = FALSE;
}
#endif
}
}
......@@ -74,14 +95,31 @@ void gribContainersDelete(int streamID)
if ( streamptr->gribContainers )
{
int i;
int nvars = streamptr->nvars;
#if defined (GRIBCONTAINER2D)
gribContainer_t **gribContainers = (gribContainer_t **) streamptr->gribContainers;
for ( int varID = 0; varID < nvars; ++varID )
{
int nlevs = streamptr->vars[varID].nlevs;
for ( int levelID = 0; levelID < nlevs; ++levelID )
{
gribHandleDelete(gribContainers[varID][levelID].gribHandle);
}
free(gribContainers[varID]);
}
#else
gribContainer_t *gribContainers = (gribContainer_t *) streamptr->gribContainers;
for ( i = 0; i < streamptr->nvars; ++i )
for ( int varID = 0; varID < nvars; ++varID )
{
gribHandleDelete(gribContainers[i].gribHandle);
gribHandleDelete(gribContainers[varID].gribHandle);
}
free(streamptr->gribContainers);
#endif
free(gribContainers);
streamptr->gribContainers = NULL;
}
}
......
......@@ -554,8 +554,13 @@ int grbWriteVarSliceDP(int streamID, int varID, int levelID, const double *data,
else
#endif
{
#if defined (GRIBCONTAINER2D)
gribContainer_t **gribContainers = (gribContainer_t **) streamptr->gribContainers;
gc = (void *) &gribContainers[varID][levelID];
#else
gribContainer_t *gribContainers = (gribContainer_t *) streamptr->gribContainers;
gc = (void *) &gribContainers[varID];
#endif
}
if ( streamptr->comptype == COMPRESS_JPEG )
......
......@@ -618,7 +618,7 @@ void streamPrintP ( void * streamptr, FILE * fp )
fprintf ( fp, "curfile = %d\n", sp->curfile );
fprintf ( fp, "nfiles = %d\n", sp->nfiles );
fprintf ( fp, "// char **fnames;\n" );
fprintf ( fp, "// void *gribContainers;\n" );
fprintf ( fp, "// void **gribContainers;\n" );
fprintf ( fp, "vlistIDorig = %d\n", sp->vlistIDorig );
}
......
......@@ -186,7 +186,6 @@ typedef struct {
int gridID;
int zaxisID;
int tsteptype; /* TSTEP_* */
int nlevel;
}
svarinfo_t;
......@@ -246,7 +245,11 @@ typedef struct {
int curfile;
int nfiles;
char **fnames;
#if defined (GRIBCONTAINER2D)
void **gribContainers;
#else
void *gribContainers;
#endif
int vlistIDorig;
}
stream_t;
......
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