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

merged branch charxy.

parent cb021b37
......@@ -2,6 +2,10 @@
* Version 1.8.2 released
2017-05-12 Uwe Schulzweida
* merged branch charxy [Fabian Wachsmann]
2017-04-25 Uwe Schulzweida
* initialize taxisptr->units to NULL after calling delete_refcount_string() [Bug #7691]
......
......@@ -163,6 +163,7 @@ extern "C" {
#define GRID_CURVILINEAR 10 /* Curvilinear grid */
#define GRID_LCC 11 /* Lambert Conformal Conic (GRIB) */
#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_LCC 22 /* Lambert Conformal Conic */
......@@ -197,6 +198,7 @@ extern "C" {
#define ZAXIS_SEDIMENT_BOTTOM_TW 23 /* Bottom Of Sediment Layer Penetrated By Thermal Wave */
#define ZAXIS_MIX_LAYER 24 /* Mixing Layer */
#define ZAXIS_REFERENCE 25 /* zaxis reference number */
#define ZAXIS_CHAR 26 /* Area types */
/* SUBTYPE types */
......@@ -788,12 +790,24 @@ void gridDefXvals(int gridID, const double xvals[]);
/* gridInqXvals: Get all values of a X-axis */
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 */
void gridDefYvals(int gridID, const double yvals[]);
/* gridInqYvals: Get all values of a Y-axis */
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 */
#define CDI_KEY_XNAME 901 // X-axis name
#define CDI_KEY_XDIMNAME 902 // X-axis dimension name
......@@ -996,6 +1010,9 @@ void zaxisPrint(int zaxisID);
/* zaxisDefLevels: Define the levels of a Z-axis */
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 */
int zaxisInqLevels(int zaxisID, double levels[]);
......
......@@ -40,6 +40,7 @@ static const char Grids[][17] = {
/* 10 */ "curvilinear",
/* 11 */ "lcc",
/* 12 */ "projection",
/* 13 */ "characterXY",
};
/* must match table below */
......@@ -47,6 +48,7 @@ enum xystdname_idx {
grid_xystdname_grid_latlon,
grid_xystdname_latlon,
grid_xystdname_projection,
grid_xystdname_char,
};
static const char xystdname_tab[][2][24] = {
[grid_xystdname_grid_latlon] = { "grid_longitude",
......@@ -55,7 +57,8 @@ static const char xystdname_tab[][2][24] = {
"latitude" },
[grid_xystdname_projection] = { "projection_x_coordinate",
"projection_y_coordinate" },
[grid_xystdname_char] = { "region",
"region" },
};
......@@ -119,7 +122,11 @@ void grid_init(grid_t *gridptr)
gridptr->mask = NULL;
gridptr->mask_gme = NULL;
gridptr->x.vals = NULL;
gridptr->x.cvals = NULL;
gridptr->x.clength = 0;
gridptr->y.vals = NULL;
gridptr->y.cvals = NULL;
gridptr->y.clength = 0;
gridptr->x.bounds = NULL;
gridptr->y.bounds = NULL;
gridptr->area = NULL;
......@@ -191,6 +198,7 @@ void grid_free_components(grid_t *gridptr)
{
void *p2free[] = { gridptr->mask, gridptr->mask_gme,
gridptr->x.vals, gridptr->y.vals,
gridptr->x.cvals, gridptr->y.cvals,
gridptr->x.bounds, gridptr->y.bounds,
gridptr->rowlon, gridptr->area,
gridptr->reference, gridptr->name};
......@@ -321,6 +329,13 @@ void cdiGridTypeInit(grid_t *gridptr, int gridtype, int size)
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_PROJECTION:
{
......@@ -1500,7 +1515,6 @@ void gridDefMaskGME(int gridID, const int *mask)
gridMark4Update(gridID);
}
static
int gridInqXValsSerial(grid_t *gridptr, double *xvals)
{
......@@ -1529,6 +1543,37 @@ int gridInqXValsSerial(grid_t *gridptr, double *xvals)
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
@Title Get all values of a X-axis
......@@ -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
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));
}
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
@Title Define the values of a X-axis
......@@ -1650,6 +1741,20 @@ int gridInqYvals(int gridID, double *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
void gridDefYValsSerial(grid_t *gridptr, const double *yvals)
{
......@@ -3267,6 +3372,8 @@ void gridPrintKernel(int gridID, int opt, FILE *fp)
char attstr[CDI_MAX_NAME];
char attstr2[CDI_MAX_NAME];
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 nyvals = (size_t) gridInqYvals(gridID, NULL);
size_t nxbounds = (size_t) gridInqXbounds(gridID, NULL);
......@@ -3276,6 +3383,8 @@ void gridPrintKernel(int gridID, int opt, FILE *fp)
int gridsize = gridInqSize(gridID);
int xsize = gridInqXsize(gridID);
int ysize = gridInqYsize(gridID);
int xstrlen = gridInqXIscPtr(gridID);
int ystrlen = gridInqYIscPtr(gridID);
int nvertex = gridInqNvertex(gridID);
int prec = gridInqPrec(gridID);
......@@ -3291,8 +3400,9 @@ void gridPrintKernel(int gridID, int opt, FILE *fp)
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);
if ( attstr[0] ) fprintf(fp, "xname = %s\n", attstr);
attstr2[0] = 0; cdiGridInqKeyStr(gridID, CDI_KEY_XDIMNAME, CDI_MAX_NAME, attstr2);
......@@ -3303,8 +3413,9 @@ void gridPrintKernel(int gridID, int opt, FILE *fp)
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);
if ( attstr[0] ) fprintf(fp, "yname = %s\n", attstr);
attstr2[0] = 0; cdiGridInqKeyStr(gridID, CDI_KEY_YDIMNAME, CDI_MAX_NAME, attstr2);
......@@ -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 )
{
double *xbounds = (double*) Malloc(nxbounds*sizeof(double));
......@@ -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 )
{
double *ybounds = (double*) Malloc(nybounds*sizeof(double));
......@@ -3570,6 +3703,7 @@ static const double *gridInqXValsPtrSerial(grid_t *gridptr)
return gridptr->x.vals;
}
const double *gridInqXvalsPtr(int gridID)
{
grid_t *gridptr = grid_to_pointer(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)
{
return gridptr->y.vals;
......@@ -3588,6 +3735,18 @@ const double *gridInqYvalsPtr(int gridID)
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
@Title Define the parameter of a Lambert Conformal Conic grid
......@@ -4730,7 +4889,11 @@ const struct gridVirtTable cdiGridVtable
.inqXVal = gridInqXValSerial,
.inqYVal = gridInqYValSerial,
.inqXVals = gridInqXValsSerial,
.inqXCvals = gridInqXCvalsSerial,
.inqXIsc = gridInqXIscSerial,
.inqYVals = gridInqYValsSerial,
.inqYCvals = gridInqYCvalsSerial,
.inqYIsc = gridInqYIscSerial,
.inqXValsPtr = gridInqXValsPtrSerial,
.inqYValsPtr = gridInqYValsPtrSerial,
.compareXYFull = compareXYvals,
......
......@@ -30,9 +30,17 @@ struct gridVirtTable
double (*inqXVal)(grid_t *gridptr, int index);
double (*inqYVal)(grid_t *gridptr, int index);
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 (*inqYCvals)(grid_t *gridptr, char **ycvals);
int (*inqYIsc)(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 char **(*inqYCvalsPtr)(grid_t *gridptr);
int (*inqYIscPtr)(grid_t *gridptr);
/* return if for both grids, all xval and all yval are equal */
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
......@@ -59,6 +67,8 @@ struct gridaxis_t {
short flag; // 0: undefined 1:vals 2:first+inc
double first, last, inc;
double *vals;
int clength;
char **cvals;
double *bounds;
};
......@@ -126,6 +136,11 @@ void gridVerifyProj(int gridID);
const double *gridInqXvalsPtr(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 *gridInqYboundsPtr(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
}
}
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
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)
strcpy(gridaxis->name, ncvar->name);
strcpy(gridaxis->longname, ncvar->longname);
strcpy(gridaxis->units, ncvar->units);
if ( gridaxis->cvals )
gridaxis->stdname = ncvar->stdname;
}
static
......@@ -2130,7 +2146,13 @@ bool cdf_read_xcoord(struct cdfLazyGrid *restrict lazyGrid, ncdim_t *ncdims, ncv
int prec = cdfInqDatatype(axisvar->xtype, axisvar->lunsigned);
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, axisvar, &grid->x.vals, &lazyGrid->xValsGet, ntdims, start, count);
cdf_copy_axis_attr(axisvar, &grid->x);
......@@ -2182,7 +2204,13 @@ bool cdf_read_ycoord(struct cdfLazyGrid *restrict lazyGrid, ncdim_t *ncdims, ncv
int prec = cdfInqDatatype(axisvar->xtype, axisvar->lunsigned);
if ( prec != -1 ) grid->prec = prec;
cdf_load_vals(size, ndims, yvarid, axisvar, &grid->y.vals, &lazyGrid->yValsGet, ntdims, start, count);
if ( prec == CDI_DATATYPE_UINT8 && !CDI_netcdf_lazy_grid_load )
{
cdf_load_cvals(size, yvarid, axisvar, &grid->y.cvals, *ysize);
grid->y.clength = size / (*ysize) ;
}
else
cdf_load_vals(size, ndims, yvarid, axisvar, &grid->y.vals, &lazyGrid->yValsGet, ntdims, start, count);
cdf_copy_axis_attr(axisvar, &grid->y);
......@@ -2748,6 +2776,7 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( CDI_Debug ) Message("nlevs = %d", zsize);
double *zvar = NULL;
char **zcvals = NULL;
int zaxisType = CDI_UNDEFID;
if ( zvarid != CDI_UNDEFID ) zaxisType = ncvars[zvarid].zaxistype;
......@@ -2770,6 +2799,16 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( pname[len-2] == '_' && isdigit((int) pname[len-1]) )
pname[len-2] = 0;
*/
if ( zaxisType == ZAXIS_CHAR )
{
if ( ncvars[zvarid].ndims == 2 )
{
zprec = CDI_DATATYPE_UINT8;
size_t strlength = ncdims[ncvars[zvarid].dimids[1]].len;
cdf_load_cvals(zsize*strlength, zvarid, ncvar, &zcvals, zsize);
}
}
if ( zaxisType == ZAXIS_HYBRID && ncvars[zvarid].vct )
{
vct = ncvars[zvarid].vct;
......@@ -2779,8 +2818,11 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if ( ncvars[zvarid].p0varid != -1 ) p0varid = ncvars[zvarid].p0varid;
}
zvar = (double*) Malloc((size_t)zsize*sizeof(double));
cdf_get_var_double(ncvars[zvarid].ncid, zvarid, zvar);
if ( zaxisType != ZAXIS_CHAR )
{
zvar = (double*) Malloc((size_t)zsize*sizeof(double));
cdf_get_var_double(ncvars[zvarid].ncid, zvarid, zvar);
}
if ( ncvars[zvarid].bounds != CDI_UNDEFID )
{
......@@ -2828,7 +2870,7 @@ int cdf_define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
return CDI_EDIMSIZE;
}
ncvar->zaxisID = varDefZaxis(vlistID, zaxisType, (int) zsize, zvar, with_bounds, lbounds, ubounds,
ncvar->zaxisID = varDefZaxis(vlistID, zaxisType, (int) zsize, zvar, (const char **)zcvals, with_bounds, lbounds, ubounds,
(int)vctsize, vct, pname, plongname, punits, zprec, 1, 0);
int zaxisID = ncvar->zaxisID;
......
......@@ -1598,6 +1598,114 @@ void cdf_def_mapping(stream_t *streamptr, int gridID)
}
}
static
void cdfDefCharacter(stream_t *streamptr, int gridID, int gridindex, int xory, int strlen)
{
if ( streamptr->ncgrid[gridindex].ncIDs[CDF_DIMID_X] != CDI_UNDEFID ) return;
int dimlen = ( xory == 0 ) ? gridInqXsize(gridID) : gridInqYsize(gridID);
int dimID, strlenID;
ncgrid_t *ncgrid = streamptr->ncgrid;
/* Check for all grids up to gridindex whether it already is defined */
for ( int index = 0; index < gridindex; index++ )
{
int gridID0 = ncgrid[index].gridID;
int gridtype0 = gridInqType(gridID0);
if ( gridtype0 == GRID_CHARXY )
{
if ( gridInqXIsc(gridID0) == strlen &&
gridInqXsize(gridID0) == dimlen )
return;
else if ( gridInqYIsc(gridID0) == strlen &&
gridInqYsize(gridID0) == dimlen )
return;
}
}
int fileID = streamptr->fileID;
if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
/* Define Dims */
char dimname[CDI_MAX_NAME+3];
dimname[0] = 0;
if ( xory == 0 )
cdiGridInqKeyStr(gridID, CDI_KEY_XDIMNAME, CDI_MAX_NAME, dimname);
else
cdiGridInqKeyStr(gridID, CDI_KEY_YDIMNAME, CDI_MAX_NAME, dimname);
if ( dimname[0] == 0 ) { memcpy(dimname, "region", 7); dimname[6] = 0; }
dimID = checkDimName(fileID, dimlen, dimname);
if ( dimID == CDI_UNDEFID ) cdf_def_dim(fileID, dimname, dimlen, &dimID);
/* Define strlength dim */
strcpy(dimname, "strlen");
strlenID = checkDimName(fileID, strlen, dimname);
if ( strlenID == CDI_UNDEFID ) cdf_def_dim(fileID, dimname, strlen, &strlenID);
/* Define Variable */
int dimIDs[2];
dimIDs[0] = dimID;
dimIDs[1] = strlenID;
char axisname[CDI_MAX_NAME]; axisname[0] = 0;
char **cvals = (char **) Malloc(dimlen * sizeof(char *));
for ( int i = 0; i < dimlen; i++ )
cvals[i] = Malloc(strlen * sizeof(char) );
int ncaxisid;
if ( xory == 0 )
{
cdiGridInqKeyStr(gridID, CDI_KEY_XNAME, CDI_MAX_NAME, axisname);
gridInqXCvals(gridID, cvals);
}
else
{
cdiGridInqKeyStr(gridID, CDI_KEY_YNAME, CDI_MAX_NAME, axisname);
gridInqXCvals(gridID, cvals);
}
int status = nc_inq_varid(fileID, axisname, &ncaxisid);
if ( status != NC_NOERR )
{
cdf_def_var(fileID, axisname, NC_CHAR, 2, dimIDs, &ncaxisid);
if ( xory == 0 )
cdfPutGridStdAtts(fileID, ncaxisid, gridID, 'X', &gridInqsX);
else
cdfPutGridStdAtts(fileID, ncaxisid, gridID, 'Y', &gridInqsY);
}
else
return;
cdf_enddef(fileID);
/* Write Var */
size_t start[2], count[2];
start[1] = 0;
count[0] = 1;
count[1] = strlen;
for (int i = 0; i < dimlen; i++)
{
start[0] = i;
status = nc_put_vara_text(fileID, ncaxisid, start, count, cvals[i]);
}
ncgrid[gridindex].gridID = gridID;
if ( xory == 0 )
{
ncgrid[gridindex].ncIDs[CDF_DIMID_X] = dimID;