Commit 86974e7c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdfDefGrid: bug fix for generic grid names

parent 62d1d764
......@@ -154,9 +154,11 @@ void printGridInfo(int vlistID)
gridtype == GRID_LCC2 ||
gridtype == GRID_LAEA ||
gridtype == GRID_SINUSOIDAL ||
gridtype == GRID_GENERIC ||
gridtype == GRID_GAUSSIAN ||
gridtype == GRID_GAUSSIAN_REDUCED )
{
int lxcoord = 1, lycoord = 1;
double xfirst = 0.0, xlast = 0.0;
double yfirst = 0.0, ylast = 0.0;
double xinc = 0.0, yinc = 0.0;
......@@ -168,14 +170,17 @@ void printGridInfo(int vlistID)
if ( gridtype == GRID_GAUSSIAN_REDUCED )
fprintf(stdout, "size : dim = %d nlat = %d", gridsize, ysize);
else
fprintf(stdout, "size : dim = %d nlon = %d nlat = %d", gridsize, xsize, ysize);
fprintf(stdout, "size : dim = %d nx = %d ny = %d", gridsize, xsize, ysize);
if ( gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED )
fprintf(stdout, " np = %d", gridInqNP(gridID));
fprintf(stdout, "\n");
if ( xsize > 0 )
if ( gridInqXvals(gridID, NULL) == 0 ) lxcoord = 0;
if ( gridInqYvals(gridID, NULL) == 0 ) lycoord = 0;
if ( xsize > 0 && lxcoord )
{
if ( gridtype == GRID_GAUSSIAN_REDUCED )
{
......@@ -194,19 +199,18 @@ void printGridInfo(int vlistID)
if ( IS_NOT_EQUAL(xinc, 0) )
fprintf(stdout, " inc = %.9g", xinc);
fprintf(stdout, " %s", xunits);
if ( gridIsCircular(gridID) )
fprintf(stdout, " circular");
if ( gridIsCircular(gridID) ) fprintf(stdout, " circular");
fprintf(stdout, "\n");
}
}
if ( ysize > 0 )
if ( ysize > 0 && lycoord )
{
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, "%-9s : first = %.9g", yname, yfirst);
if ( ysize > 1 ) fprintf(stdout, " last = %.9g", ylast);
if ( IS_NOT_EQUAL(yinc, 0) &&
(gridtype == GRID_LONLAT || gridtype == GRID_SINUSOIDAL ||
if ( IS_NOT_EQUAL(yinc, 0) &&
(gridtype == GRID_LONLAT || gridtype == GRID_SINUSOIDAL ||
gridtype == GRID_LCC2 || gridtype == GRID_LAEA) )
fprintf(stdout, " inc = %.9g", yinc);
fprintf(stdout, " %s", yunits);
......@@ -231,6 +235,7 @@ void printGridInfo(int vlistID)
fprintf(stdout, "available :");
if ( gridInqXbounds(gridID, NULL) ) fprintf(stdout, " xbounds");
if ( gridInqYbounds(gridID, NULL) ) fprintf(stdout, " ybounds");
if ( gridHasArea(gridID) ) fprintf(stdout, " area");
if ( gridInqMask(gridID, NULL) ) fprintf(stdout, " mask");
fprintf(stdout, "\n");
}
......@@ -317,12 +322,11 @@ void printGridInfo(int vlistID)
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, "%-9s : min = %.9g max = %.9g %s", xname, xfirst, xlast, xunits);
if ( gridIsCircular(gridID) )
fprintf(stdout, " circular");
if ( gridIsCircular(gridID) ) fprintf(stdout, " circular");
fprintf(stdout, "\n");
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, "%-9s : min = %.9g max = %.9g %s\n", yname, yfirst, ylast, yunits);
free(xvals);
free(yvals);
}
......@@ -354,16 +358,10 @@ void printGridInfo(int vlistID)
else
{
fprintf(stdout, "size : dim = %d nx = %d ny = %d\n", gridsize, xsize, ysize);
if ( gridIsCircular(gridID) )
{
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, "longitude : circular\n");
}
}
}
if ( gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED ||
gridtype == GRID_GENERIC || gridtype == GRID_LCC )
if ( gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED || gridtype == GRID_LCC )
{
if ( gridInqXvals(gridID, NULL) || gridInqYvals(gridID, NULL) || gridHasArea(gridID) ||
gridInqXbounds(gridID, NULL) || gridInqYbounds(gridID, NULL) )
......
......@@ -2531,14 +2531,29 @@ void cdfDefGrid(stream_t *streamptr, int gridID)
gridtype == GRID_LONLAT ||
gridtype == GRID_GENERIC )
{
if ( gridtype == GRID_GENERIC && size == 1 &&
gridInqXsize(gridID) == 0 && gridInqYsize(gridID) == 0 )
if ( gridtype == GRID_GENERIC )
{
/* no grid information */
}
else if ( gridtype == GRID_GENERIC && (gridInqXsize(gridID) == 0 || gridInqYsize(gridID) == 0) )
{
cdfDefGdim(streamptr, gridID);
if ( size == 1 && gridInqXsize(gridID) == 0 && gridInqYsize(gridID) == 0 )
{
/* no grid information */
}
else
{
int lx = 0, ly = 0;
if ( gridInqXsize(gridID) > 0 && gridInqXvals(gridID, NULL) > 0 )
{
cdfDefXaxis(streamptr, gridID);
lx = 1;
}
if ( gridInqYsize(gridID) > 0 && gridInqYvals(gridID, NULL) > 0 )
{
cdfDefYaxis(streamptr, gridID);
ly = 1;
}
if ( lx == 0 && ly == 0 ) cdfDefGdim(streamptr, gridID);
}
}
else
{
......
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