diff --git a/ChangeLog b/ChangeLog index 240ed72d4acaec9948906a1133bca936f52ce3f0..df40b1956cc2d900104cb1572a1db6d3b433c8fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ * Version 2.5.1 released +2025-02-01 Uwe Schulzweida + + * Added support for READ_CELL_CENTER=false + 2025-01-30 Uwe Schulzweida * Added CDI_KEY_CHUNKSIZE_DIMX diff --git a/src/cdf_lazy_grid.c b/src/cdf_lazy_grid.c index af1315bddd49e2a1735dc04af15e27df67d50ecc..5af2914aa0132c2fafa26348491da9ad63cfdc65 100644 --- a/src/cdf_lazy_grid.c +++ b/src/cdf_lazy_grid.c @@ -42,7 +42,7 @@ static void cdfLazyGridDelete(grid_t *grid) { struct cdfLazyGrid *cdfGrid = (struct cdfLazyGrid *) grid; - void (*baseDestroy)(grid_t * grid) = cdfGrid->baseVtable->destroy; + void (*baseDestroy)(grid_t *grid) = cdfGrid->baseVtable->destroy; cdfLazyGridDestroy(cdfGrid); baseDestroy(grid); } @@ -194,7 +194,7 @@ cdfLazyGridInqXVal(grid_t *grid, SizeType index) { struct cdfLazyGrid *lazyGrid = (struct cdfLazyGrid *) grid; lock_lazy_load(lazyGrid); - const double rv = cdfLazyGridInqXYVal(grid, (size_t) index, &lazyGrid->xValsGet, grid->x.vals, grid->vtable->inqXValsPtr); + double rv = cdfLazyGridInqXYVal(grid, (size_t) index, &lazyGrid->xValsGet, grid->x.vals, grid->vtable->inqXValsPtr); unlock_lazy_load(lazyGrid); return rv; } @@ -204,7 +204,7 @@ cdfLazyGridInqYVal(grid_t *grid, SizeType index) { struct cdfLazyGrid *lazyGrid = (struct cdfLazyGrid *) grid; lock_lazy_load(lazyGrid); - const double rv = cdfLazyGridInqXYVal(grid, (size_t) index, &lazyGrid->yValsGet, grid->y.vals, grid->vtable->inqYValsPtr); + double rv = cdfLazyGridInqXYVal(grid, (size_t) index, &lazyGrid->yValsGet, grid->y.vals, grid->vtable->inqYValsPtr); unlock_lazy_load(lazyGrid); return rv; } @@ -315,10 +315,10 @@ cdfLazyGridCopyScalarFields(grid_t *gridptrOrig, grid_t *gridptrDup) static void cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup) { - const size_t reducedPointsSize = (size_t) gridptrOrig->reducedPointsSize; - const size_t gridsize = gridptrOrig->size; - const int gridtype = gridptrOrig->type; - const int irregular = (gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED); + size_t reducedPointsSize = (size_t) gridptrOrig->reducedPointsSize; + size_t gridsize = gridptrOrig->size; + int gridtype = gridptrOrig->type; + int irregular = (gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED); if (reducedPointsSize) { @@ -328,28 +328,28 @@ cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup) if (gridptrOrig->x.vals != NULL && gridptrOrig->x.vals != cdfPendingLoad) { - const size_t size = irregular ? gridsize : gridptrOrig->x.size; + size_t size = irregular ? gridsize : gridptrOrig->x.size; gridptrDup->x.vals = (double *) Malloc(size * sizeof(double)); memcpy(gridptrDup->x.vals, gridptrOrig->x.vals, size * sizeof(double)); } if (gridptrOrig->y.vals != NULL && gridptrOrig->y.vals != cdfPendingLoad) { - const size_t size = irregular ? gridsize : gridptrOrig->y.size; + size_t size = irregular ? gridsize : gridptrOrig->y.size; gridptrDup->y.vals = (double *) Malloc(size * sizeof(double)); memcpy(gridptrDup->y.vals, gridptrOrig->y.vals, size * sizeof(double)); } if (gridptrOrig->x.bounds != NULL && gridptrOrig->x.bounds != cdfPendingLoad) { - const size_t size = (irregular ? gridsize : gridptrOrig->x.size) * (size_t) gridptrOrig->nvertex; + size_t size = (irregular ? gridsize : gridptrOrig->x.size) * (size_t) gridptrOrig->nvertex; gridptrDup->x.bounds = (double *) Malloc(size * sizeof(double)); memcpy(gridptrDup->x.bounds, gridptrOrig->x.bounds, size * sizeof(double)); } if (gridptrOrig->y.bounds != NULL && gridptrOrig->y.bounds != cdfPendingLoad) { - const size_t size = (irregular ? gridsize : gridptrOrig->y.size) * (size_t) gridptrOrig->nvertex; + size_t size = (irregular ? gridsize : gridptrOrig->y.size) * (size_t) gridptrOrig->nvertex; gridptrDup->y.bounds = (double *) Malloc(size * sizeof(double)); memcpy(gridptrDup->y.bounds, gridptrOrig->y.bounds, size * sizeof(double)); } @@ -357,7 +357,7 @@ cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup) { if (gridptrOrig->area != NULL && gridptrOrig->area != cdfPendingLoad) { - const size_t size = gridsize; + size_t size = gridsize; gridptrDup->area = (double *) Malloc(size * sizeof(double)); memcpy(gridptrDup->area, gridptrOrig->area, size * sizeof(double)); } @@ -365,14 +365,14 @@ cdfLazyGridCopyArrayFields(grid_t *gridptrOrig, grid_t *gridptrDup) if (gridptrOrig->mask != NULL) { - const size_t size = gridsize; + size_t size = gridsize; gridptrDup->mask = (mask_t *) Malloc(size * sizeof(mask_t)); memcpy(gridptrDup->mask, gridptrOrig->mask, size * sizeof(mask_t)); } if (gridptrOrig->mask_gme != NULL) { - const size_t size = gridsize; + size_t size = gridsize; gridptrDup->mask_gme = (mask_t *) Malloc(size * sizeof(mask_t)); memcpy(gridptrDup->mask_gme, gridptrOrig->mask_gme, size * sizeof(mask_t)); } diff --git a/src/cdi_fdb.h b/src/cdi_fdb.h index 9baf530494deeef70c26ad2f78643cc96922f856..1d3549c761a33c7e74019b5e896a7639ae605cb6 100644 --- a/src/cdi_fdb.h +++ b/src/cdi_fdb.h @@ -5,8 +5,6 @@ #include "config.h" #endif -extern int cdi_fdb_dummy; - #ifdef HAVE_LIBFDB5 #include <fdb5/api/fdb_c.h> diff --git a/src/cdi_int.c b/src/cdi_int.c index 13bb05067315986b2536aa0ef9c36b75a60e994c..188d8a431dea2df522599a6a67d7d89d41ec648a 100644 --- a/src/cdi_int.c +++ b/src/cdi_int.c @@ -41,6 +41,7 @@ int CDI_Inventory_Mode = 1; int CDI_Version_Info = 1; int CDI_Query_Abort = 1; int CDI_Convert_Cubesphere = 1; +int CDI_Read_Cell_Center = 1; int CDI_Read_Cell_Corners = 1; int CDI_CMOR_Mode = 0; int CDI_Reduce_Dim = 0; @@ -348,6 +349,9 @@ cdiInitialize(void) value = cdi_getenv_int("CDI_LOCK_IO"); if (value >= 0) CDI_Lock_IO = (bool) value; + value = cdi_getenv_int("CDI_READ_CELL_CENTER"); + if (value >= 0) CDI_Read_Cell_Center = (int) value; + value = cdi_getenv_int("CDI_READ_CELL_CORNERS"); if (value >= 0) CDI_Read_Cell_Corners = (int) value; @@ -519,6 +523,7 @@ cdiDefGlobal(const char *string, int value) else if (str_is_equal(string, "SORTNAME")) cdiSortName = value; else if (str_is_equal(string, "HAVE_MISSVAL")) cdiHaveMissval = value; else if (str_is_equal(string, "NC_CHUNKSIZEHINT")) CDI_Netcdf_Chunksizehint = value; + else if (str_is_equal(string, "READ_CELL_CENTER")) CDI_Read_Cell_Center = value; else if (str_is_equal(string, "READ_CELL_CORNERS")) CDI_Read_Cell_Corners = value; else if (str_is_equal(string, "CMOR_MODE")) CDI_CMOR_Mode = value; else if (str_is_equal(string, "REDUCE_DIM")) CDI_Reduce_Dim = value; diff --git a/src/cdi_int.h b/src/cdi_int.h index d6912d0b482a0f0dc63280e663d40e9f386e6814..40ac701e7c94736045e284d24b770787704f579c 100644 --- a/src/cdi_int.h +++ b/src/cdi_int.h @@ -417,6 +417,7 @@ extern int CDI_Inventory_Mode; extern int CDI_Query_Abort; extern int CDI_Version_Info; extern int CDI_Convert_Cubesphere; +extern int CDI_Read_Cell_Center; extern int CDI_Read_Cell_Corners; extern int CDI_CMOR_Mode; extern int CDI_Reduce_Dim; diff --git a/src/stream_cdf_i.c b/src/stream_cdf_i.c index 83d8a5f5c1339eb3699efb17882d6cc850913bc4..b1ad6dc404db7c97b8a7126389fc9ef03c9960d1 100644 --- a/src/stream_cdf_i.c +++ b/src/stream_cdf_i.c @@ -2295,6 +2295,7 @@ cdf_check_gridtype(int *gridtype, bool isLon, bool isLat, size_t xsize, size_t y { if (isLat && (isLon || xsize == 0)) { + // Failed with CDI_Netcdf_Lazy_Grid_Load double yinc = 0.0; if (isLon && ysize > 1) { @@ -2397,8 +2398,10 @@ cdf_read_xcoord(stream_t *streamptr, struct cdfLazyGrid *lazyGrid, ncdim_t *ncdi grid->x.clength = size / (*xsize); #endif } - else - cdf_load_vals(size, ndims, xvarid, axisvar, &grid->x.vals, &lazyGrid->xValsGet, hasTimeDim, readPart, start, count); + else if (CDI_Read_Cell_Center) + { + cdf_load_vals(size, ndims, xvarid, axisvar, &grid->x.vals, &lazyGrid->xValsGet, hasTimeDim, readPart, start, count); + } cdf_copy_grid_axis_attr(axisvar, &grid->x); @@ -2479,8 +2482,10 @@ cdf_read_ycoord(stream_t *streamptr, struct cdfLazyGrid *lazyGrid, ncdim_t *ncdi grid->y.clength = size / (*ysize); #endif } - else - cdf_load_vals(size, ndims, yvarid, axisvar, &grid->y.vals, &lazyGrid->yValsGet, hasTimeDim, readPart, start, count); + else if (CDI_Read_Cell_Center) + { + cdf_load_vals(size, ndims, yvarid, axisvar, &grid->y.vals, &lazyGrid->yValsGet, hasTimeDim, readPart, start, count); + } cdf_copy_grid_axis_attr(axisvar, &grid->y);