Commit 1778bb43 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdfDefXaxis/cdfDefYaxis: added support for user defined dimension name

parent 85a47acd
......@@ -282,13 +282,13 @@ cdiGridTypeInit(grid_t *gridptr, int gridtype, int size)
{
if ( gridtype == GRID_TRAJECTORY )
{
gridSetName(gridptr->xname, "tlon");
gridSetName(gridptr->yname, "tlat");
if ( gridptr->xname[0] == 0 ) gridSetName(gridptr->xname, "tlon");
if ( gridptr->yname[0] == 0 ) gridSetName(gridptr->yname, "tlat");
}
else
{
gridSetName(gridptr->xname, "lon");
gridSetName(gridptr->yname, "lat");
if ( gridptr->xname[0] == 0 ) gridSetName(gridptr->xname, "lon");
if ( gridptr->yname[0] == 0 ) gridSetName(gridptr->yname, "lat");
}
gridSetName(gridptr->xlongname, "longitude");
gridSetName(gridptr->ylongname, "latitude");
......@@ -317,8 +317,8 @@ cdiGridTypeInit(grid_t *gridptr, int gridtype, int size)
/* Fall through */
case GRID_GME:
{
gridSetName(gridptr->xname, "lon");
gridSetName(gridptr->yname, "lat");
if ( gridptr->xname[0] == 0 ) gridSetName(gridptr->xname, "lon");
if ( gridptr->yname[0] == 0 ) gridSetName(gridptr->yname, "lat");
gridptr->xstdname = xystdname_tab[grid_xystdname_latlon][0];
gridptr->ystdname = xystdname_tab[grid_xystdname_latlon][1];
gridSetName(gridptr->xunits, "degrees_east");
......@@ -329,8 +329,8 @@ cdiGridTypeInit(grid_t *gridptr, int gridtype, int size)
{
/* gridptr->xsize = size; */
gridSetName(gridptr->xname, "x");
gridSetName(gridptr->yname, "y");
if ( gridptr->xname[0] == 0 ) gridSetName(gridptr->xname, "x");
if ( gridptr->yname[0] == 0 ) gridSetName(gridptr->yname, "y");
/*
strcpy(gridptr->xstdname, "grid_longitude");
strcpy(gridptr->ystdname, "grid_latitude");
......@@ -345,8 +345,8 @@ cdiGridTypeInit(grid_t *gridptr, int gridtype, int size)
case GRID_SINUSOIDAL:
case GRID_LAEA:
{
gridSetName(gridptr->xname, "x");
gridSetName(gridptr->yname, "y");
if ( gridptr->xname[0] == 0 ) gridSetName(gridptr->xname, "x");
if ( gridptr->yname[0] == 0 ) gridSetName(gridptr->yname, "y");
gridptr->xstdname = xystdname_tab[grid_xystdname_projection][0];
gridptr->ystdname = xystdname_tab[grid_xystdname_projection][1];
gridSetName(gridptr->xunits, "m");
......@@ -354,7 +354,6 @@ cdiGridTypeInit(grid_t *gridptr, int gridtype, int size)
break;
}
}
}
......
......@@ -1241,13 +1241,18 @@ void cdfDefXaxis(stream_t *streamptr, int gridID, int ndims)
if ( dimID == UNDEFID )
{
char dimname[CDI_MAX_NAME+3];
dimname[0] = 0;
cdiGridInqString(gridID, CDI_GRID_XDIMNAME, CDI_MAX_NAME, dimname);
if ( dimname[0] == 0 ) strcpy(dimname, axisname);
int status = checkGridName('V', axisname, fileID, vlistID, gridID, ngrids, 'X');
if ( status == 0 && ndims )
status = checkGridName('D', axisname, fileID, vlistID, gridID, ngrids, 'X');
status = checkGridName('D', dimname, fileID, vlistID, gridID, ngrids, 'X');
if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
if ( ndims ) cdf_def_dim(fileID, axisname, dimlen, &dimID);
if ( ndims ) cdf_def_dim(fileID, dimname, dimlen, &dimID);
int gen_bounds = FALSE;
int grid_is_cyclic = gridIsCircular(gridID);
......@@ -1383,14 +1388,18 @@ void cdfDefYaxis(stream_t *streamptr, int gridID, int ndims)
if ( dimID == UNDEFID )
{
int status;
status = checkGridName('V', axisname, fileID, vlistID, gridID, ngrids, 'Y');
char dimname[CDI_MAX_NAME+3];
dimname[0] = 0;
cdiGridInqString(gridID, CDI_GRID_YDIMNAME, CDI_MAX_NAME, dimname);
if ( dimname[0] == 0 ) strcpy(dimname, axisname);
int status = checkGridName('V', axisname, fileID, vlistID, gridID, ngrids, 'Y');
if ( status == 0 && ndims )
status = checkGridName('D', axisname, fileID, vlistID, gridID, ngrids, 'Y');
status = checkGridName('D', dimname, fileID, vlistID, gridID, ngrids, 'Y');
if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
if ( ndims ) cdf_def_dim(fileID, axisname, dimlen, &dimID);
if ( ndims ) cdf_def_dim(fileID, dimname, dimlen, &dimID);
int gen_bounds = FALSE;
int grid_is_cyclic = gridIsCircular(gridID);
......@@ -5529,7 +5538,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
}
}
if (grid->type != ncvars[ncvarid].gridtype)
if ( grid->type != ncvars[ncvarid].gridtype )
{
int gridtype = ncvars[ncvarid].gridtype;
grid->type = gridtype;
......
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