Commit 13f9fff6 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

gridPrint: print xfirst and xinc if xinc is constant

parent 701bf9c1
2006-05-?? Uwe Schulzweida <schulzweida@dkrz.de> 2006-05-?? Uwe Schulzweida <schulzweida@dkrz.de>
* using GRIB library version 0.6.6
* gridPrint: print xfirst and xinc if xinc is constant
* Version 0.9.7 released * Version 0.9.7 released
2006-03-08 Uwe Schulzweida <schulzweida@dkrz.de> 2006-03-08 Uwe Schulzweida <schulzweida@dkrz.de>
......
...@@ -2442,11 +2442,20 @@ void gridCompress(int gridID) ...@@ -2442,11 +2442,20 @@ void gridCompress(int gridID)
gridptr->xsize = gridsize; gridptr->xsize = gridsize;
gridptr->ysize = gridsize; gridptr->ysize = gridsize;
gridptr->xvals = (double *) realloc(gridptr->xvals, gridsize*sizeof(double)); if ( gridptr->xvals )
gridptr->yvals = (double *) realloc(gridptr->yvals, gridsize*sizeof(double)); gridptr->xvals = (double *) realloc(gridptr->xvals, gridsize*sizeof(double));
gridptr->area = (double *) realloc(gridptr->area, gridsize*sizeof(double));
gridptr->xbounds = (double *) realloc(gridptr->xbounds, nv*gridsize*sizeof(double)); if ( gridptr->yvals )
gridptr->ybounds = (double *) realloc(gridptr->ybounds, nv*gridsize*sizeof(double)); gridptr->yvals = (double *) realloc(gridptr->yvals, gridsize*sizeof(double));
if ( gridptr->area )
gridptr->area = (double *) realloc(gridptr->area, gridsize*sizeof(double));
if ( gridptr->xbounds )
gridptr->xbounds = (double *) realloc(gridptr->xbounds, nv*gridsize*sizeof(double));
if ( gridptr->ybounds )
gridptr->ybounds = (double *) realloc(gridptr->ybounds, nv*gridsize*sizeof(double));
free(gridptr->mask); free(gridptr->mask);
gridptr->mask = NULL; gridptr->mask = NULL;
...@@ -2828,19 +2837,35 @@ void gridPrint(int gridID) ...@@ -2828,19 +2837,35 @@ void gridPrint(int gridID)
if ( xvals ) if ( xvals )
{ {
nbyte0 = fprintf(fp, "xvals : "); double xfirst = 0.0, xinc = 0.0;
nbyte = nbyte0;
for ( index = 0; index < xdim; index++ ) if ( type == GRID_LONLAT || type == GRID_GAUSSIAN )
{ {
if ( nbyte > 80 ) xfirst = gridInqXval(gridID, 0);
xinc = gridInqXinc(gridID);
}
if ( !DBL_IS_EQUAL(xinc, 0) )
{
fprintf(fp, "xfirst : %g\n", xfirst);
fprintf(fp, "xinc : %g\n", xinc);
}
else
{
nbyte0 = fprintf(fp, "xvals : ");
nbyte = nbyte0;
for ( index = 0; index < xdim; index++ )
{ {
fprintf(fp, "\n"); if ( nbyte > 80 )
fprintf(fp, "%*s", nbyte0, ""); {
nbyte = nbyte0; fprintf(fp, "\n");
fprintf(fp, "%*s", nbyte0, "");
nbyte = nbyte0;
}
nbyte += fprintf(fp, "%.9g ", xvals[index]);
} }
nbyte += fprintf(fp, "%.9g ", xvals[index]); fprintf(fp, "\n");
} }
fprintf(fp, "\n");
} }
if ( xbounds ) if ( xbounds )
...@@ -2858,19 +2883,35 @@ void gridPrint(int gridID) ...@@ -2858,19 +2883,35 @@ void gridPrint(int gridID)
if ( yvals ) if ( yvals )
{ {
nbyte0 = fprintf(fp, "yvals : "); double yfirst = 0.0, yinc = 0.0;
nbyte = nbyte0;
for ( index = 0; index < ydim; index++ ) if ( type == GRID_LONLAT )
{ {
if ( nbyte > 80 ) yfirst = gridInqYval(gridID, 0);
yinc = gridInqYinc(gridID);
}
if ( !DBL_IS_EQUAL(yinc, 0) )
{
fprintf(fp, "yfirst : %g\n", yfirst);
fprintf(fp, "yinc : %g\n", yinc);
}
else
{
nbyte0 = fprintf(fp, "yvals : ");
nbyte = nbyte0;
for ( index = 0; index < ydim; index++ )
{ {
fprintf(fp, "\n"); if ( nbyte > 80 )
fprintf(fp, "%*s", nbyte0, ""); {
nbyte = nbyte0; fprintf(fp, "\n");
fprintf(fp, "%*s", nbyte0, "");
nbyte = nbyte0;
}
nbyte += fprintf(fp, "%.9g ", yvals[index]);
} }
nbyte += fprintf(fp, "%.9g ", yvals[index]); fprintf(fp, "\n");
} }
fprintf(fp, "\n");
} }
if ( ybounds ) if ( ybounds )
......
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