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