Commit 039619c6 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

merged branch charxy.

parent cb021b37
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
* Version 1.8.2 released * Version 1.8.2 released
2017-05-12 Uwe Schulzweida
* merged branch charxy [Fabian Wachsmann]
2017-04-25 Uwe Schulzweida 2017-04-25 Uwe Schulzweida
* initialize taxisptr->units to NULL after calling delete_refcount_string() [Bug #7691] * initialize taxisptr->units to NULL after calling delete_refcount_string() [Bug #7691]
......
...@@ -163,6 +163,7 @@ extern "C" { ...@@ -163,6 +163,7 @@ extern "C" {
#define GRID_CURVILINEAR 10 /* Curvilinear grid */ #define GRID_CURVILINEAR 10 /* Curvilinear grid */
#define GRID_LCC 11 /* Lambert Conformal Conic (GRIB) */ #define GRID_LCC 11 /* Lambert Conformal Conic (GRIB) */
#define GRID_PROJECTION 12 /* Projected coordinates */ #define GRID_PROJECTION 12 /* Projected coordinates */
#define GRID_CHARXY 13 /* One horizontal character dimension */
#define CDI_PROJ_RLL 21 /* Rotated Latitude Longitude */ #define CDI_PROJ_RLL 21 /* Rotated Latitude Longitude */
#define CDI_PROJ_LCC 22 /* Lambert Conformal Conic */ #define CDI_PROJ_LCC 22 /* Lambert Conformal Conic */
...@@ -197,6 +198,7 @@ extern "C" { ...@@ -197,6 +198,7 @@ extern "C" {
#define ZAXIS_SEDIMENT_BOTTOM_TW 23 /* Bottom Of Sediment Layer Penetrated By Thermal Wave */ #define ZAXIS_SEDIMENT_BOTTOM_TW 23 /* Bottom Of Sediment Layer Penetrated By Thermal Wave */
#define ZAXIS_MIX_LAYER 24 /* Mixing Layer */ #define ZAXIS_MIX_LAYER 24 /* Mixing Layer */
#define ZAXIS_REFERENCE 25 /* zaxis reference number */ #define ZAXIS_REFERENCE 25 /* zaxis reference number */
#define ZAXIS_CHAR 26 /* Area types */
/* SUBTYPE types */ /* SUBTYPE types */
...@@ -788,12 +790,24 @@ void gridDefXvals(int gridID, const double xvals[]); ...@@ -788,12 +790,24 @@ void gridDefXvals(int gridID, const double xvals[]);
/* gridInqXvals: Get all values of a X-axis */ /* gridInqXvals: Get all values of a X-axis */
int gridInqXvals(int gridID, double xvals[]); int gridInqXvals(int gridID, double xvals[]);
/* gridInqXIsc: Find out whether X-coordinate is of type CHAR */
int gridInqXIsc(int gridID);
/* gridInqXCvals: Get strings from X-axis in case grid is of type GRID_CHARXY */
int gridInqXCvals(int gridID, char *xcvals[]);
/* gridDefYvals: Define the values of a Y-axis */ /* gridDefYvals: Define the values of a Y-axis */
void gridDefYvals(int gridID, const double yvals[]); void gridDefYvals(int gridID, const double yvals[]);
/* gridInqYvals: Get all values of a Y-axis */ /* gridInqYvals: Get all values of a Y-axis */
int gridInqYvals(int gridID, double yvals[]); int gridInqYvals(int gridID, double yvals[]);
/* gridInqYIsc: Find out whether Y-coordinate is of type CHAR */
int gridInqYIsc(int gridID);
/* gridInqYCvals: Get strings from Y-axis in case grid is of type GRID_CHARXY */
int gridInqYCvals(int gridID, char *ycvals[]);
/* CDI grid string key values */ /* CDI grid string key values */
#define CDI_KEY_XNAME 901 // X-axis name #define CDI_KEY_XNAME 901 // X-axis name
#define CDI_KEY_XDIMNAME 902 // X-axis dimension name #define CDI_KEY_XDIMNAME 902 // X-axis dimension name
...@@ -996,6 +1010,9 @@ void zaxisPrint(int zaxisID); ...@@ -996,6 +1010,9 @@ void zaxisPrint(int zaxisID);
/* zaxisDefLevels: Define the levels of a Z-axis */ /* zaxisDefLevels: Define the levels of a Z-axis */
void zaxisDefLevels(int zaxisID, const double levels[]); void zaxisDefLevels(int zaxisID, const double levels[]);
/* zaxisDefCvals: Define area types of a Z-axis */
void zaxisDefCvals(int zaxisID, const char *cvals[]);
/* zaxisInqLevels: Get all levels of a Z-axis */ /* zaxisInqLevels: Get all levels of a Z-axis */
int zaxisInqLevels(int zaxisID, double levels[]); int zaxisInqLevels(int zaxisID, double levels[]);
......
...@@ -40,6 +40,7 @@ static const char Grids[][17] = { ...@@ -40,6 +40,7 @@ static const char Grids[][17] = {
/* 10 */ "curvilinear", /* 10 */ "curvilinear",
/* 11 */ "lcc", /* 11 */ "lcc",
/* 12 */ "projection", /* 12 */ "projection",
/* 13 */ "characterXY",
}; };
/* must match table below */ /* must match table below */
...@@ -47,6 +48,7 @@ enum xystdname_idx { ...@@ -47,6 +48,7 @@ enum xystdname_idx {
grid_xystdname_grid_latlon, grid_xystdname_grid_latlon,
grid_xystdname_latlon, grid_xystdname_latlon,
grid_xystdname_projection, grid_xystdname_projection,
grid_xystdname_char,
}; };
static const char xystdname_tab[][2][24] = { static const char xystdname_tab[][2][24] = {
[grid_xystdname_grid_latlon] = { "grid_longitude", [grid_xystdname_grid_latlon] = { "grid_longitude",
...@@ -55,7 +57,8 @@ static const char xystdname_tab[][2][24] = { ...@@ -55,7 +57,8 @@ static const char xystdname_tab[][2][24] = {
"latitude" }, "latitude" },
[grid_xystdname_projection] = { "projection_x_coordinate", [grid_xystdname_projection] = { "projection_x_coordinate",
"projection_y_coordinate" }, "projection_y_coordinate" },
[grid_xystdname_char] = { "region",
"region" },
}; };
...@@ -119,7 +122,11 @@ void grid_init(grid_t *gridptr) ...@@ -119,7 +122,11 @@ void grid_init(grid_t *gridptr)
gridptr->mask = NULL; gridptr->mask = NULL;
gridptr->mask_gme = NULL; gridptr->mask_gme = NULL;
gridptr->x.vals = NULL; gridptr->x.vals = NULL;
gridptr->x.cvals = NULL;
gridptr->x.clength = 0;
gridptr->y.vals = NULL; gridptr->y.vals = NULL;
gridptr->y.cvals = NULL;
gridptr->y.clength = 0;
gridptr->x.bounds = NULL; gridptr->x.bounds = NULL;
gridptr->y.bounds = NULL; gridptr->y.bounds = NULL;
gridptr->area = NULL; gridptr->area = NULL;
...@@ -191,6 +198,7 @@ void grid_free_components(grid_t *gridptr) ...@@ -191,6 +198,7 @@ void grid_free_components(grid_t *gridptr)
{ {
void *p2free[] = { gridptr->mask, gridptr->mask_gme, void *p2free[] = { gridptr->mask, gridptr->mask_gme,
gridptr->x.vals, gridptr->y.vals, gridptr->x.vals, gridptr->y.vals,
gridptr->x.cvals, gridptr->y.cvals,
gridptr->x.bounds, gridptr->y.bounds, gridptr->x.bounds, gridptr->y.bounds,
gridptr->rowlon, gridptr->area, gridptr->rowlon, gridptr->area,
gridptr->reference, gridptr->name}; gridptr->reference, gridptr->name};
...@@ -321,6 +329,13 @@ void cdiGridTypeInit(grid_t *gridptr, int gridtype, int size) ...@@ -321,6 +329,13 @@ void cdiGridTypeInit(grid_t *gridptr, int gridtype, int size)
break; break;
} }
case GRID_CHARXY:
{
if ( gridptr->x.cvals )
gridptr->x.stdname = xystdname_tab[grid_xystdname_char][0];
if ( gridptr->y.cvals )
gridptr->y.stdname = xystdname_tab[grid_xystdname_char][0];
}
case GRID_GENERIC: case GRID_GENERIC:
case GRID_PROJECTION: case GRID_PROJECTION:
{ {
...@@ -1500,7 +1515,6 @@ void gridDefMaskGME(int gridID, const int *mask) ...@@ -1500,7 +1515,6 @@ void gridDefMaskGME(int gridID, const int *mask)
gridMark4Update(gridID); gridMark4Update(gridID);
} }
static static
int gridInqXValsSerial(grid_t *gridptr, double *xvals) int gridInqXValsSerial(grid_t *gridptr, double *xvals)
{ {
...@@ -1529,6 +1543,37 @@ int gridInqXValsSerial(grid_t *gridptr, double *xvals) ...@@ -1529,6 +1543,37 @@ int gridInqXValsSerial(grid_t *gridptr, double *xvals)
return (int)size; return (int)size;
} }
static
int gridInqXCvalsSerial(grid_t *gridptr, char **xcvals)
{
if ( gridptr->type != GRID_CHARXY )
Error("Function only valid for grid type 'GRID_CHARXY'.");
int size = gridptr->x.size;
const char **gridptr_xcvals = gridptr->vtable->inqXCvalsPtr(gridptr);
if ( size == 0 || !gridptr_xcvals )
Error("No string coordinates found!");
int stringlen = strlen(gridptr_xcvals[0]);
if ( stringlen == 0 )
Error("Length of string coordinates not defined.");
if ( xcvals )
for ( int i = 0; i < size; i++ )
memcpy(xcvals[i], gridptr_xcvals[i], (size_t)stringlen * sizeof(char));
return (int)stringlen;
}
static
int gridInqXIscSerial(grid_t *gridptr)
{
int clen = gridptr->x.clength;
if ( gridptr->type != GRID_CHARXY )
Error("Axis type is 'char' but grid is not type 'GRID_CHARXY'.");
return clen;
}
/* /*
@Function gridInqXvals @Function gridInqXvals
@Title Get all values of a X-axis @Title Get all values of a X-axis
...@@ -1556,6 +1601,19 @@ int gridInqXvals(int gridID, double *xvals) ...@@ -1556,6 +1601,19 @@ int gridInqXvals(int gridID, double *xvals)
} }
int gridInqXCvals(int gridID, char **xcvals)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->vtable->inqXCvals(gridptr, xcvals);
}
int gridInqXIsc(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->vtable->inqXIsc(gridptr);
}
static static
void gridDefXValsSerial(grid_t *gridptr, const double *xvals) void gridDefXValsSerial(grid_t *gridptr, const double *xvals)
{ {
...@@ -1579,6 +1637,39 @@ void gridDefXValsSerial(grid_t *gridptr, const double *xvals) ...@@ -1579,6 +1637,39 @@ void gridDefXValsSerial(grid_t *gridptr, const double *xvals)
memcpy(gridptr->x.vals, xvals, (size_t)size * sizeof (double)); memcpy(gridptr->x.vals, xvals, (size_t)size * sizeof (double));
} }
static
int gridInqYCvalsSerial(grid_t *gridptr, char **ycvals)
{
if ( gridptr->type != GRID_CHARXY )
Error("Function only valid for grid type 'GRID_CHARXY'.");
int size = gridptr->y.size;
int stringlen = 0;
if ( gridptr->y.cvals )
{
if ( size && ycvals )
{
const char **gridptr_ycvals = gridptr->vtable->inqYCvalsPtr(gridptr);
stringlen = strlen(gridptr_ycvals[0]);
memcpy(ycvals, gridptr_ycvals, (size_t)size * sizeof ( (size_t)stringlen * sizeof(char)));
}
}
else
size = 0;
return (int)stringlen;
}
static
int gridInqYIscSerial(grid_t *gridptr)
{
int clen = gridptr->y.clength;
if ( gridptr->type != GRID_CHARXY )
Error("Axis type is 'char' but grid is not type 'GRID_CHARXY'.");
return clen;
}
/* /*
@Function gridDefXvals @Function gridDefXvals
@Title Define the values of a X-axis @Title Define the values of a X-axis
...@@ -1650,6 +1741,20 @@ int gridInqYvals(int gridID, double *yvals) ...@@ -1650,6 +1741,20 @@ int gridInqYvals(int gridID, double *yvals)
return gridptr->vtable->inqYVals(gridptr, yvals); return gridptr->vtable->inqYVals(gridptr, yvals);
} }
int gridInqYCvals(int gridID, char **ycvals)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->vtable->inqYCvals(gridptr, ycvals);
}
int gridInqYIsc(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->vtable->inqYIsc(gridptr);
}
static static
void gridDefYValsSerial(grid_t *gridptr, const double *yvals) void gridDefYValsSerial(grid_t *gridptr, const double *yvals)
{ {
...@@ -3267,6 +3372,8 @@ void gridPrintKernel(int gridID, int opt, FILE *fp) ...@@ -3267,6 +3372,8 @@ void gridPrintKernel(int gridID, int opt, FILE *fp)
char attstr[CDI_MAX_NAME]; char attstr[CDI_MAX_NAME];
char attstr2[CDI_MAX_NAME]; char attstr2[CDI_MAX_NAME];
unsigned char uuidOfHGrid[CDI_UUID_SIZE]; unsigned char uuidOfHGrid[CDI_UUID_SIZE];
const char **xcvals = gridInqXCvalsPtr(gridID);
const char **ycvals = gridInqYCvalsPtr(gridID);
size_t nxvals = (size_t) gridInqXvals(gridID, NULL); size_t nxvals = (size_t) gridInqXvals(gridID, NULL);
size_t nyvals = (size_t) gridInqYvals(gridID, NULL); size_t nyvals = (size_t) gridInqYvals(gridID, NULL);
size_t nxbounds = (size_t) gridInqXbounds(gridID, NULL); size_t nxbounds = (size_t) gridInqXbounds(gridID, NULL);
...@@ -3276,6 +3383,8 @@ void gridPrintKernel(int gridID, int opt, FILE *fp) ...@@ -3276,6 +3383,8 @@ void gridPrintKernel(int gridID, int opt, FILE *fp)
int gridsize = gridInqSize(gridID); int gridsize = gridInqSize(gridID);
int xsize = gridInqXsize(gridID); int xsize = gridInqXsize(gridID);
int ysize = gridInqYsize(gridID); int ysize = gridInqYsize(gridID);
int xstrlen = gridInqXIscPtr(gridID);
int ystrlen = gridInqYIscPtr(gridID);
int nvertex = gridInqNvertex(gridID); int nvertex = gridInqNvertex(gridID);
int prec = gridInqPrec(gridID); int prec = gridInqPrec(gridID);
...@@ -3291,8 +3400,9 @@ void gridPrintKernel(int gridID, int opt, FILE *fp) ...@@ -3291,8 +3400,9 @@ void gridPrintKernel(int gridID, int opt, FILE *fp)
if ( ysize > 0 ) fprintf(fp, "ysize = %d\n", ysize); if ( ysize > 0 ) fprintf(fp, "ysize = %d\n", ysize);
} }
if ( nxvals > 0 ) if ( nxvals > 0 || xcvals )
{ {
if ( xstrlen ) fprintf(fp, "xstringlen= %d\n", xstrlen);
attstr[0] = 0; cdiGridInqKeyStr(gridID, CDI_KEY_XNAME, CDI_MAX_NAME, attstr); attstr[0] = 0; cdiGridInqKeyStr(gridID, CDI_KEY_XNAME, CDI_MAX_NAME, attstr);
if ( attstr[0] ) fprintf(fp, "xname = %s\n", attstr); if ( attstr[0] ) fprintf(fp, "xname = %s\n", attstr);
attstr2[0] = 0; cdiGridInqKeyStr(gridID, CDI_KEY_XDIMNAME, CDI_MAX_NAME, attstr2); attstr2[0] = 0; cdiGridInqKeyStr(gridID, CDI_KEY_XDIMNAME, CDI_MAX_NAME, attstr2);
...@@ -3303,8 +3413,9 @@ void gridPrintKernel(int gridID, int opt, FILE *fp) ...@@ -3303,8 +3413,9 @@ void gridPrintKernel(int gridID, int opt, FILE *fp)
if ( attstr[0] ) fprintf(fp, "xunits = %s\n", attstr); if ( attstr[0] ) fprintf(fp, "xunits = %s\n", attstr);
} }
if ( nyvals > 0 ) if ( nyvals > 0 || ycvals )
{ {
if ( ystrlen ) fprintf(fp, "ystringlen= %d\n", ystrlen);
attstr[0] = 0; cdiGridInqKeyStr(gridID, CDI_KEY_YNAME, CDI_MAX_NAME, attstr); attstr[0] = 0; cdiGridInqKeyStr(gridID, CDI_KEY_YNAME, CDI_MAX_NAME, attstr);
if ( attstr[0] ) fprintf(fp, "yname = %s\n", attstr); if ( attstr[0] ) fprintf(fp, "yname = %s\n", attstr);
attstr2[0] = 0; cdiGridInqKeyStr(gridID, CDI_KEY_YDIMNAME, CDI_MAX_NAME, attstr2); attstr2[0] = 0; cdiGridInqKeyStr(gridID, CDI_KEY_YDIMNAME, CDI_MAX_NAME, attstr2);
...@@ -3402,6 +3513,17 @@ void gridPrintKernel(int gridID, int opt, FILE *fp) ...@@ -3402,6 +3513,17 @@ void gridPrintKernel(int gridID, int opt, FILE *fp)
} }
} }
if ( xcvals )
{
attstr[0] = 0; cdiGridInqKeyStr(gridID, CDI_KEY_XNAME, CDI_MAX_NAME, attstr);
if ( attstr[0] )
fprintf(fp, "x%ss = %.*s\n", attstr, xstrlen, xcvals[0]);
else
fprintf(fp, "xstrings = %.*s\n", xstrlen, xcvals[0]);
for ( int i = 1; i < xsize; i++ )
fprintf(fp, " = %.*s\n", xstrlen, xcvals[i]);
}
if ( nxbounds ) if ( nxbounds )
{ {
double *xbounds = (double*) Malloc(nxbounds*sizeof(double)); double *xbounds = (double*) Malloc(nxbounds*sizeof(double));
...@@ -3437,6 +3559,17 @@ void gridPrintKernel(int gridID, int opt, FILE *fp) ...@@ -3437,6 +3559,17 @@ void gridPrintKernel(int gridID, int opt, FILE *fp)
} }
} }
if ( ycvals )
{
attstr[0] = 0; cdiGridInqKeyStr(gridID, CDI_KEY_YNAME, CDI_MAX_NAME, attstr);
if ( attstr[0] )
fprintf(fp, "x%ss = %.*s\n", attstr, ystrlen, ycvals[0]);
else
fprintf(fp, "ystrings = %.*s\n", ystrlen, ycvals[0]);
for ( int i = 1; i < ysize; i++ )
fprintf(fp, " = %.*s\n", ystrlen, ycvals[i]);
}
if ( nybounds ) if ( nybounds )
{ {
double *ybounds = (double*) Malloc(nybounds*sizeof(double)); double *ybounds = (double*) Malloc(nybounds*sizeof(double));
...@@ -3570,6 +3703,7 @@ static const double *gridInqXValsPtrSerial(grid_t *gridptr) ...@@ -3570,6 +3703,7 @@ static const double *gridInqXValsPtrSerial(grid_t *gridptr)
return gridptr->x.vals; return gridptr->x.vals;
} }
const double *gridInqXvalsPtr(int gridID) const double *gridInqXvalsPtr(int gridID)
{ {
grid_t *gridptr = grid_to_pointer(gridID); grid_t *gridptr = grid_to_pointer(gridID);
...@@ -3577,6 +3711,19 @@ const double *gridInqXvalsPtr(int gridID) ...@@ -3577,6 +3711,19 @@ const double *gridInqXvalsPtr(int gridID)
} }
const char **gridInqXCvalsPtr(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->vtable->inqXCvalsPtr(gridptr);
}
int gridInqXIscPtr(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->vtable->inqXIscPtr(gridptr);
}
static const double *gridInqYValsPtrSerial(grid_t *gridptr) static const double *gridInqYValsPtrSerial(grid_t *gridptr)
{ {
return gridptr->y.vals; return gridptr->y.vals;
...@@ -3588,6 +3735,18 @@ const double *gridInqYvalsPtr(int gridID) ...@@ -3588,6 +3735,18 @@ const double *gridInqYvalsPtr(int gridID)
return gridptr->vtable->inqYValsPtr(gridptr); return gridptr->vtable->inqYValsPtr(gridptr);
} }
const char **gridInqYCvalsPtr(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->vtable->inqYCvalsPtr(gridptr);
}
int gridInqYIscPtr(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->vtable->inqYIscPtr(gridptr);
}
/* /*
@Function gridDefParamLCC @Function gridDefParamLCC
@Title Define the parameter of a Lambert Conformal Conic grid @Title Define the parameter of a Lambert Conformal Conic grid
...@@ -4730,7 +4889,11 @@ const struct gridVirtTable cdiGridVtable ...@@ -4730,7 +4889,11 @@ const struct gridVirtTable cdiGridVtable
.inqXVal = gridInqXValSerial, .inqXVal = gridInqXValSerial,
.inqYVal = gridInqYValSerial, .inqYVal = gridInqYValSerial,
.inqXVals = gridInqXValsSerial, .inqXVals = gridInqXValsSerial,
.inqXCvals = gridInqXCvalsSerial,
.inqXIsc = gridInqXIscSerial,
.inqYVals = gridInqYValsSerial, .inqYVals = gridInqYValsSerial,
.inqYCvals = gridInqYCvalsSerial,
.inqYIsc = gridInqYIscSerial,
.inqXValsPtr = gridInqXValsPtrSerial, .inqXValsPtr = gridInqXValsPtrSerial,
.inqYValsPtr = gridInqYValsPtrSerial, .inqYValsPtr = gridInqYValsPtrSerial,
.compareXYFull = compareXYvals, .compareXYFull = compareXYvals,
......
...@@ -30,9 +30,17 @@ struct gridVirtTable ...@@ -30,9 +30,17 @@ struct gridVirtTable
double (*inqXVal)(grid_t *gridptr, int index); double (*inqXVal)(grid_t *gridptr, int index);
double (*inqYVal)(grid_t *gridptr, int index); double (*inqYVal)(grid_t *gridptr, int index);
int (*inqXVals)(grid_t *gridptr, double *xvals); int (*inqXVals)(grid_t *gridptr, double *xvals);
int (*inqXCvals)(grid_t *gridptr, char **xcvals);
int (*inqXIsc)(grid_t *gridptr);
int (*inqYVals)(grid_t *gridptr, double *yvals); int (*inqYVals)(grid_t *gridptr, double *yvals);
int (*inqYCvals)(grid_t *gridptr, char **ycvals);
int (*inqYIsc)(grid_t *gridptr);
const double *(*inqXValsPtr)(grid_t *gridptr); const double *(*inqXValsPtr)(grid_t *gridptr);
const char **(*inqXCvalsPtr)(grid_t *gridptr);
int (*inqXIscPtr)(grid_t *gridptr);
const double *(*inqYValsPtr)(grid_t *gridptr); const double *(*inqYValsPtr)(grid_t *gridptr);
const char **(*inqYCvalsPtr)(grid_t *gridptr);
int (*inqYIscPtr)(grid_t *gridptr);
/* return if for both grids, all xval and all yval are equal */ /* return if for both grids, all xval and all yval are equal */
bool (*compareXYFull)(grid_t *gridRef, grid_t *gridTest); bool (*compareXYFull)(grid_t *gridRef, grid_t *gridTest);
/* return if for both grids, x[0], y[0], x[size-1] and y[size-1] are /* return if for both grids, x[0], y[0], x[size-1] and y[size-1] are
...@@ -59,6 +67,8 @@ struct gridaxis_t { ...@@ -59,6 +67,8 @@ struct gridaxis_t {
short flag; // 0: undefined 1:vals 2:first+inc short flag; // 0: undefined 1:vals 2:first+inc
double first, last, inc; double first, last, inc;
double *vals; double *vals;
int clength;
char **cvals;
double *bounds; double *bounds;
}; };
...@@ -126,6 +136,11 @@ void gridVerifyProj(int gridID); ...@@ -126,6 +136,11 @@ void gridVerifyProj(int gridID);
const double *gridInqXvalsPtr(int gridID); const double *gridInqXvalsPtr(int gridID);
const double *gridInqYvalsPtr(int gridID); const double *gridInqYvalsPtr(int gridID);
const char **gridInqXCvalsPtr(int gridID);
int gridInqXIscPtr(int gridID);
const char **gridInqYCvalsPtr(int gridID);
int gridInqYIscPtr(int gridID);
const double *gridInqXboundsPtr(int gridID); const double *gridInqXboundsPtr(int gridID);
const double *gridInqYboundsPtr(int gridID); const double *gridInqYboundsPtr(int gridID);
const double *gridInqAreaPtr(int gridID); const double *gridInqAreaPtr(int gridID);
......
...@@ -1975,6 +1975,20 @@ void cdf_load_vals(size_t size, int ndims, int varid, ncvar_t *ncvar, double **g ...@@ -1975,6 +1975,20 @@ void cdf_load_vals(size_t size, int ndims, int varid, ncvar_t *ncvar, double **g
} }
} }
static
void cdf_load_cvals(size_t size, int varid, ncvar_t *ncvar, char ***gridvals, size_t dimlength)
{
size_t startc[] = {0, 0};
size_t countc[] = {1, size/dimlength};
*gridvals = (char **) Malloc(dimlength * sizeof(char *));
for ( size_t i = 0; i < dimlength; i++ )
{
(*gridvals)[i] = (char*) Malloc((size/dimlength) * sizeof(char));
cdf_get_vara_text(ncvar->ncid, varid, startc, countc, (*gridvals)[i]);
startc[0] = i+1;
}
}
static static
void cdf_load_bounds(size_t size, ncvar_t *ncvar, double **gridbounds, struct cdfLazyGridIds *cellBoundsGet) void cdf_load_bounds(size_t size, ncvar_t *ncvar, double **gridbounds, struct cdfLazyGridIds *cellBoundsGet)
{ {
...@@ -2013,6 +2027,8 @@ void cdf_copy_axis_attr(ncvar_t *ncvar, struct gridaxis_t *gridaxis) ...@@ -2013,6 +2027,8 @@ void cdf_copy_axis_attr(ncvar_t *ncvar, struct gridaxis_t *gridaxis)
strcpy(gridaxis->name, ncvar->name); strcpy(gridaxis->name, ncvar->name);
strcpy(gridaxis->longname, ncvar->longname); strcpy(gridaxis->longname, ncvar->longname);
strcpy(gridaxis->units, ncvar->units); strcpy(gridaxis->units, ncvar->units);
if ( gridaxis->cvals )
gridaxis->stdname = ncvar->stdname;
} }
static static
...@@ -2130,7 +2146,13 @@ bool cdf_read_xcoord(struct cdfLazyGrid *restrict lazyGrid, ncdim_t *ncdims, ncv ...@@ -2130,7 +2146,13 @@ bool cdf_read_xcoord(struct cdfLazyGrid *restrict lazyGrid, ncdim_t *ncdims, ncv
int prec = cdfInqDatatype(axisvar->xtype, axisvar->lunsigned); int prec = cdfInqDatatype(axisvar->xtype, axisvar->lunsigned);
if ( prec != -1 ) grid->prec = prec; if ( prec != -1 ) grid->prec = prec;
cdf_load_vals(size, ndims, xvarid, axisvar, &grid->x.vals, &lazyGrid->xValsGet, ntdims, start, count); if ( prec == CDI_DATATYPE_UINT8 && !CDI_netcdf_lazy_grid_load )
{
cdf_load_cvals(size, xvarid, axisvar, &grid->x.cvals, *xsize);
grid->x.clength = size / (*xsize) ;
}
else
cdf_load_vals(size, ndims, xvarid,