Commit 74318e9d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added function vlist_inq_gridsize()

parent 89d852d4
......@@ -15,7 +15,8 @@ The pressure, temperature, and surface geopotential are identified by their GRIB
or netCDF CF standard name.
Supported parameter tables are: WMO standard table number 2 and ECMWF local table number 128.
Use the alias @bold{ml2plx}/@bold{ml2hlx} or the environment variable @env{EXTRAPOLATE}
to extrapolate missing values. All input fields have to be on the same horizontal grid.
to extrapolate missing values. This operator requires all variables on the same horizontal grid.
@EndDescription
@EndModule
......
......@@ -35,18 +35,19 @@
#define C_EARTH_GRAV (9.80665)
void *Vertintml(void *argument)
{
int mode;
enum {ECHAM_MODE, WMO_MODE};
enum {func_pl, func_hl};
enum {type_lin, type_log};
int gridsize, ngp = 0;
int gridsize, ngp;
int recID, nrecs;
int i, k, offset;
int tsID, varID, levelID;
int zaxisIDp, zaxisIDh = -1, nzaxis;
int ngrids, gridID, zaxisID;
int gridID, zaxisID;
int nplev, nhlev = 0, nhlevf = 0, nhlevh = 0, nlevel;
int *vert_index = NULL;
int nvct;
......@@ -122,27 +123,7 @@ void *Vertintml(void *argument)
int taxisID2 = taxisDuplicate(taxisID1);
vlistDefTaxis(vlistID2, taxisID2);
ngrids = vlistNgrids(vlistID1);
for ( i = 0; i < ngrids; i++ )
{
gridID = vlistGrid(vlistID1, i);
if ( gridInqType(gridID) != GRID_SPECTRAL )
{
ngp = gridInqSize(gridID);
break;
}
}
/* check gridsize */
for ( i = 0; i < ngrids; i++ )
{
gridID = vlistGrid(vlistID1, i);
if ( gridInqType(gridID) != GRID_SPECTRAL )
{
if ( ngp != gridInqSize(gridID) )
cdoAbort("Grids have different size!");
}
}
ngp = vlist_inq_gridsize(vlistID1);
if ( operfunc == func_hl )
zaxisIDp = zaxisCreate(ZAXIS_HEIGHT, nplev);
......
......@@ -317,3 +317,37 @@ int vlistInqNWPV(int vlistID, int varID)
return (nwpv);
}
int vlist_inq_gridsize(int vlistID)
{
int lerror = FALSE;
int ngrids = vlistNgrids(vlistID);
int gridID = vlistGrid(vlistID, 0);
int ngp = gridInqSize(gridID);
/* check gridsize */
for ( int index = 0; index < ngrids; ++index )
{
gridID = vlistGrid(vlistID, index);
if ( ngp != gridInqSize(gridID) )
{
lerror = TRUE;
break;
}
}
if ( lerror )
{
cdoPrint("This operator requires all variables on the same horizontal grid.");
cdoPrint("Horizontal grids found:");
for ( int index = 0; index < ngrids; ++index )
{
gridID = vlistGrid(vlistID, index);
cdoPrint(" grid=%d type=%s points=%d", index+1, gridNamePtr(gridInqType(gridID)), gridInqSize(gridID));
}
cdoAbort("The input stream contains variables on different horizontal grids!");
}
return ngp;
}
......@@ -183,6 +183,8 @@ int cdoDefineZaxis(const char *zaxisfile);
int vlistInqNWPV(int vlistID, int varID);
int vlistIsSzipped(int vlistID);
int vlist_inq_gridsize(int vlistID);
void cdoGenFileSuffix(char *filesuffix, size_t maxlen, int filetype, int vlistID, const char *refname);
......
Supports Markdown
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