Commit 770c72f7 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

grid.c: define Yvals for GRID_GAUSSIAN_REDUCED

parent b9cc283d
2007-09-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* using GRIB library version 1.0.6
* stream_grb:grbDefGrid use ISEC2_ScanFlag [request: Alex Kann]
* replace calendar module by a new one because of date/time problems
with years < 0 [report: Veronika Gayler]
* add module timebase
......
......@@ -634,26 +634,36 @@ static void setDefaultFileType(char *filetypestr)
{
if ( filetypestr )
{
if ( strncmp(filetypestr, "grb", 3) == 0 ) DefaultFileType = FILETYPE_GRB;
else if ( strncmp(filetypestr, "nc2", 3) == 0 ) DefaultFileType = FILETYPE_NC2;
else if ( strncmp(filetypestr, "nc", 2) == 0 ) DefaultFileType = FILETYPE_NC;
else if ( strncmp(filetypestr, "srv", 3) == 0 ) DefaultFileType = FILETYPE_SRV;
else if ( strncmp(filetypestr, "ext", 3) == 0 ) DefaultFileType = FILETYPE_EXT;
else if ( strncmp(filetypestr, "ieg", 3) == 0 ) DefaultFileType = FILETYPE_IEG;
char *ftstr = filetypestr;
if ( strncmp(filetypestr, "grb", 3) == 0 ) { ftstr += 3; DefaultFileType = FILETYPE_GRB; }
else if ( strncmp(filetypestr, "nc2", 3) == 0 ) { ftstr += 3; DefaultFileType = FILETYPE_NC2; }
else if ( strncmp(filetypestr, "nc", 2) == 0 ) { ftstr += 2; DefaultFileType = FILETYPE_NC; }
else if ( strncmp(filetypestr, "srv", 3) == 0 ) { ftstr += 3; DefaultFileType = FILETYPE_SRV; }
else if ( strncmp(filetypestr, "ext", 3) == 0 ) { ftstr += 3; DefaultFileType = FILETYPE_EXT; }
else if ( strncmp(filetypestr, "ieg", 3) == 0 ) { ftstr += 3; DefaultFileType = FILETYPE_IEG; }
else
{
fprintf(stderr, "Unsupported filetype %s!\n", filetypestr);
fprintf(stderr, "Available filetypes are grb, nc, srv, ext, ieg.\n");
exit(-1);
fprintf(stderr, "Available filetypes: grb, nc, nc2, srv, ext and ieg\n");
exit(EXIT_FAILURE);
}
if ( DefaultFileType != CDI_UNDEFID )
if ( DefaultFileType != CDI_UNDEFID && *ftstr != 0 )
{
if ( (filetypestr = strchr(filetypestr, '_' )) )
if ( *ftstr == '_' )
{
filetypestr++;
ftstr++;
setDefaultDataType(filetypestr);
setDefaultDataType(ftstr);
}
else
{
fprintf(stderr, "Unexpected character >%c< in file type >%s<!\n", *ftstr, filetypestr);
fprintf(stderr, "Use format[_nbits] with:\n");
fprintf(stderr, " format = grb, nc, nc2, srv, ext or ieg\n");
fprintf(stderr, " nbits = 32/64 for nc, nc2, srv, ext, ieg; 1 - 32 for grb\n");
exit(EXIT_FAILURE);
}
}
}
......
......@@ -1598,7 +1598,7 @@ int gridInqYvals(int gridID, double *yvals)
size = gridptr->ysize;
if ( CDI_Debug && size == 0 )
Warning(func, "size undefined for gridID = %d", gridID);
Warning(func, "Size undefined for gridID = %d!", gridID);
if ( yvals && gridptr->yvals )
for ( i = 0; i < size; i++ )
......@@ -1644,12 +1644,12 @@ void gridDefYvals(int gridID, double *yvals)
size = gridptr->ysize;
if ( size == 0 )
Error(func, "size undefined for gridID = %d", gridID);
Error(func, "Size undefined for gridID = %d!", gridID);
if ( gridptr->yvals == NULL )
gridptr->yvals = (double *) malloc(size*sizeof(double));
else if ( CDI_Debug )
Warning(func, "values allready defined!");
Warning(func, "Values allready defined!");
for ( i = 0; i < size; i++ )
gridptr->yvals[i] = yvals[i];
......@@ -2348,6 +2348,23 @@ int gridGenerate(GRID grid)
{
gridDefYsize(gridID, grid.ysize);
gridDefRowlon(gridID, grid.ysize, grid.rowlon);
if ( grid.ydef == 1 )
{
gridDefYvals(gridID, grid.yvals);
if ( grid.ybounds && grid.nvertex )
gridDefYbounds(gridID, grid.ybounds);
}
else if ( grid.ydef == 2 )
{
double *yvals = (double *) malloc(grid.ysize*sizeof(double));
gridGenYvals(grid.type, grid.ysize, grid.yfirst, grid.ylast, grid.yinc, yvals);
gridDefYvals(gridID, yvals);
free(yvals);
/*
gridDefYinc(gridID, grid.yinc);
*/
}
break;
}
case GRID_SPECTRAL:
......
......@@ -1854,10 +1854,10 @@ void grbDefGrid(int *isec1, int *isec2, int gridID)
}
/* East -> West */
if ( ISEC2_LastLon < ISEC2_FirstLon ) ISEC2_ScanFlag += 1;
if ( ISEC2_LastLon < ISEC2_FirstLon ) ISEC2_ScanFlag += 128;
/* South -> North */
if ( ISEC2_LastLat > ISEC2_FirstLat ) ISEC2_ScanFlag += 2;
if ( ISEC2_LastLat > ISEC2_FirstLat ) ISEC2_ScanFlag += 64;
break;
}
......
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