Commit 521a5772 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Merge declaration and definition.

parent d76ef43f
......@@ -51,16 +51,16 @@ void printFiletype(int streamID, int vlistID)
printf("GRIB2");
break;
case FILETYPE_NC:
printf("netCDF");
printf("NetCDF");
break;
case FILETYPE_NC2:
printf("netCDF2");
printf("NetCDF2");
break;
case FILETYPE_NC4:
printf("netCDF4");
printf("NetCDF4");
break;
case FILETYPE_NC4C:
printf("netCDF4 classic");
printf("NetCDF4 classic");
break;
case FILETYPE_SRV:
printf("SERVICE");
......@@ -134,21 +134,19 @@ void printFiletype(int streamID, int vlistID)
static
void printGridInfo(int vlistID)
{
int ngrids, index;
int gridID, gridtype, trunc, gridsize, xsize, ysize, xysize;
char xname[CDI_MAX_NAME], yname[CDI_MAX_NAME], xunits[CDI_MAX_NAME], yunits[CDI_MAX_NAME];
unsigned char uuidOfHGrid[CDI_UUID_SIZE];
ngrids = vlistNgrids(vlistID);
for ( index = 0; index < ngrids; index++ )
int ngrids = vlistNgrids(vlistID);
for ( int index = 0; index < ngrids; index++ )
{
gridID = vlistGrid(vlistID, index);
gridtype = gridInqType(gridID);
trunc = gridInqTrunc(gridID);
gridsize = gridInqSize(gridID);
xsize = gridInqXsize(gridID);
ysize = gridInqYsize(gridID);
xysize = xsize*ysize;
int gridID = vlistGrid(vlistID, index);
int gridtype = gridInqType(gridID);
int trunc = gridInqTrunc(gridID);
int gridsize = gridInqSize(gridID);
int xsize = gridInqXsize(gridID);
int ysize = gridInqYsize(gridID);
int xysize = xsize*ysize;
gridInqXname(gridID, xname);
gridInqYname(gridID, yname);
gridInqXunits(gridID, xunits);
......@@ -164,14 +162,9 @@ void printGridInfo(int vlistID)
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;
yfirst = gridInqYval(gridID, 0);
ylast = gridInqYval(gridID, ysize-1);
yinc = gridInqYinc(gridID);
double yfirst = gridInqYval(gridID, 0);
double ylast = gridInqYval(gridID, ysize-1);
double yinc = gridInqYinc(gridID);
fprintf(stdout, " : points=%d", gridsize);
if ( gridtype == GRID_GAUSSIAN_REDUCED )
......@@ -184,14 +177,15 @@ void printGridInfo(int vlistID)
fprintf(stdout, "\n");
if ( gridInqXvals(gridID, NULL) == 0 ) lxcoord = 0;
if ( gridInqYvals(gridID, NULL) == 0 ) lycoord = 0;
bool lxcoord = true, lycoord = true;
if ( gridInqXvals(gridID, NULL) == 0 ) lxcoord = false;
if ( gridInqYvals(gridID, NULL) == 0 ) lycoord = false;
if ( xsize > 0 && lxcoord )
{
xfirst = gridInqXval(gridID, 0);
xlast = gridInqXval(gridID, xsize-1);
xinc = gridInqXinc(gridID);
double xfirst = gridInqXval(gridID, 0);
double xlast = gridInqXval(gridID, xsize-1);
double xinc = gridInqXinc(gridID);
fprintf(stdout, "%33s : %g", xname, xfirst);
if ( xsize > 1 )
{
......@@ -219,10 +213,9 @@ void printGridInfo(int vlistID)
if ( gridIsRotated(gridID) )
{
double lonpole, latpole, angle;
lonpole = gridInqXpole(gridID);
latpole = gridInqYpole(gridID);
angle = gridInqAngle(gridID);
double lonpole = gridInqXpole(gridID);
double latpole = gridInqYpole(gridID);
double angle = gridInqAngle(gridID);
fprintf(stdout, "%33s : lon=%g lat=%g", "northpole", lonpole, latpole);
if ( IS_NOT_EQUAL(angle, 0) ) fprintf(stdout, " angle=%g", angle);
fprintf(stdout, "\n");
......@@ -264,9 +257,8 @@ void printGridInfo(int vlistID)
}
else if ( gridtype == GRID_GME )
{
int ni, nd;
ni = gridInqGMEni(gridID);
nd = gridInqGMEnd(gridID);
int ni = gridInqGMEni(gridID);
int nd = gridInqGMEnd(gridID);
fprintf(stdout, " : points=%d nd=%d ni=%d\n", gridsize, nd, ni);
}
else if ( gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED )
......@@ -301,20 +293,17 @@ void printGridInfo(int vlistID)
if ( gridInqXvals(gridID, NULL) && gridInqYvals(gridID, NULL) )
{
int i;
double *xvals, *yvals;
double xfirst, xlast, yfirst, ylast;
xvals = (double*) malloc((size_t)gridsize*sizeof(double));
yvals = (double*) malloc((size_t)gridsize*sizeof(double));
double *xvals = (double*) malloc((size_t)gridsize*sizeof(double));
double *yvals = (double*) malloc((size_t)gridsize*sizeof(double));
gridInqXvals(gridID, xvals);
gridInqYvals(gridID, yvals);
xfirst = xvals[0];
xlast = xvals[0];
yfirst = yvals[0];
ylast = yvals[0];
for ( i = 1; i < gridsize; i++ )
double xfirst = xvals[0];
double xlast = xvals[0];
double yfirst = yvals[0];
double ylast = yvals[0];
for ( int i = 1; i < gridsize; i++ )
{
if ( xvals[i] < xfirst ) xfirst = xvals[i];
if ( xvals[i] > xlast ) xlast = xvals[i];
......@@ -385,19 +374,16 @@ void printGridInfo(int vlistID)
static
void printZaxisInfo(int vlistID)
{
int zaxisID, zaxistype, levelsize, levelID;
int ltype;
double *levels = NULL;
char zaxisname[CDI_MAX_NAME], zname[CDI_MAX_NAME], zunits[CDI_MAX_NAME];
int nzaxis = vlistNzaxis(vlistID);
for ( int index = 0; index < nzaxis; index++)
for ( int index = 0; index < nzaxis; index++ )
{
double zfirst = 0, zlast = 0, zinc = 0;
zaxisID = vlistZaxis(vlistID, index);
zaxistype = zaxisInqType(zaxisID);
ltype = zaxisInqLtype(zaxisID);
levelsize = zaxisInqSize(zaxisID);
double zinc = 0;
int zaxisID = vlistZaxis(vlistID, index);
int zaxistype = zaxisInqType(zaxisID);
int ltype = zaxisInqLtype(zaxisID);
int levelsize = zaxisInqSize(zaxisID);
zaxisName(zaxistype, zaxisname);
zaxisInqName(zaxisID, zname);
zaxisInqUnits(zaxisID, zunits);
......@@ -411,15 +397,16 @@ void printZaxisInfo(int vlistID)
fprintf(stdout, " levels=%d", levelsize);
fprintf(stdout, "\n");
levels = (double*) malloc((size_t)levelsize*sizeof(double));
double *levels = (double*) malloc((size_t)levelsize*sizeof(double));
zaxisInqLevels(zaxisID, levels);
if ( !(zaxistype == ZAXIS_SURFACE && levelsize == 1 && !(fabs(levels[0]) > 0)) )
{
zfirst = levels[0];
zlast = levels[levelsize-1];
double zfirst = levels[0];
double zlast = levels[levelsize-1];
if ( levelsize > 2 )
{
int levelID;
zinc = (levels[levelsize-1] - levels[0]) / (levelsize-1);
for ( levelID = 2; levelID < levelsize; ++levelID )
if ( fabs(fabs(levels[levelID] - levels[levelID-1]) - zinc) > 0.001*zinc ) break;
......@@ -447,12 +434,12 @@ void printZaxisInfo(int vlistID)
level1 = zaxisInqLbound(zaxisID, 0);
level2 = zaxisInqUbound(zaxisID, 0);
fprintf(stdout, "%.9g-%.9g", level1, level2);
fprintf(stdout, "%g-%g", level1, level2);
if ( levelsize > 1 )
{
level1 = zaxisInqLbound(zaxisID, levelsize-1);
level2 = zaxisInqUbound(zaxisID, levelsize-1);
fprintf(stdout, " to %.9g-%.9g", level1, level2);
fprintf(stdout, " to %g-%g", level1, level2);
if ( IS_NOT_EQUAL(zinc, 0) )
fprintf(stdout, " by %g", zinc);
}
......
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