Commit 2eac1ac2 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Changed interface to zaxisInqLevels().

parent fd44d8f7
......@@ -225,7 +225,7 @@ void *Adisit(void *argument)
int nlevel = nlevel1;
double *pressure = (double*) Malloc(nlevel*sizeof(double));
zaxisInqLevels(zaxisID, pressure);
cdoZaxisInqLevels(zaxisID, pressure);
if ( pin >= 0 )
for ( i = 0; i < nlevel; ++i ) pressure[i] = pin;
......
......@@ -413,7 +413,7 @@ static void register_z_axis(int zaxisID, char *name, int *axis_ids)
if ( zaxisInqType(zaxisID) != ZAXIS_SURFACE )
{
coord_vals = Malloc(levels * sizeof(double));
zaxisInqLevels(zaxisID, coord_vals);
cdoZaxisInqLevels(zaxisID, coord_vals);
zaxisInqUnits(zaxisID, units);
cmor_axis(new_axis_id(axis_ids), name, units, levels, (void *)coord_vals,
'd', NULL, 0, NULL);
......
......@@ -196,33 +196,36 @@ void *Change(void *argument)
for ( index = 0; index < nzaxis; index++ )
{
zaxisID1 = vlistZaxis(vlistID2, index);
nlevs = zaxisInqSize(zaxisID1);
levels = (double*) Malloc(nlevs*sizeof(double));
newlevels = (double*) Malloc(nlevs*sizeof(double));
zaxisInqLevels(zaxisID1, levels);
for ( k = 0; k < nlevs; k++ ) newlevels[k] = levels[k];
nfound = 0;
for ( i = 0; i < nch; i += 2 )
for ( k = 0; k < nlevs; k++ )
if ( fabs(levels[k] - chlevels[i]) < 0.0001 ) nfound++;
if ( nfound )
{
zaxisID2 = zaxisDuplicate(zaxisID1);
for ( i = 0; i < nch; i += 2 )
for ( k = 0; k < nlevs; k++ )
if ( fabs(levels[k] - chlevels[i]) < 0.001 )
newlevels[k] = chlevels[i+1];
zaxisDefLevels(zaxisID2, newlevels);
vlistChangeZaxis(vlistID2, zaxisID1, zaxisID2);
}
Free(levels);
Free(newlevels);
}
if ( zaxisInqLevels(zaxisID1, NULL) )
{
nlevs = zaxisInqSize(zaxisID1);
levels = (double*) Malloc(nlevs*sizeof(double));
newlevels = (double*) Malloc(nlevs*sizeof(double));
zaxisInqLevels(zaxisID1, levels);
for ( k = 0; k < nlevs; k++ ) newlevels[k] = levels[k];
nfound = 0;
for ( i = 0; i < nch; i += 2 )
for ( k = 0; k < nlevs; k++ )
if ( fabs(levels[k] - chlevels[i]) < 0.0001 ) nfound++;
if ( nfound )
{
zaxisID2 = zaxisDuplicate(zaxisID1);
for ( i = 0; i < nch; i += 2 )
for ( k = 0; k < nlevs; k++ )
if ( fabs(levels[k] - chlevels[i]) < 0.001 )
newlevels[k] = chlevels[i+1];
zaxisDefLevels(zaxisID2, newlevels);
vlistChangeZaxis(vlistID2, zaxisID1, zaxisID2);
}
Free(levels);
Free(newlevels);
}
}
}
else if ( operatorID == CHLEVELC || operatorID == CHLEVELV )
{
......@@ -247,27 +250,30 @@ void *Change(void *argument)
}
zaxisID1 = vlistInqVarZaxis(vlistID2, varID);
nlevs = zaxisInqSize(zaxisID1);
levels = (double*) Malloc(nlevs*sizeof(double));
zaxisInqLevels(zaxisID1, levels);
nfound = 0;
for ( k = 0; k < nlevs; k++ )
if ( fabs(levels[k] - chlevels[0]) < 0.0001 ) nfound++;
if ( nfound )
{
zaxisID2 = zaxisDuplicate(zaxisID1);
for ( k = 0; k < nlevs; k++ )
if ( fabs(levels[k] - chlevels[0]) < 0.001 )
levels[k] = chlevels[1];
zaxisDefLevels(zaxisID2, levels);
vlistChangeVarZaxis(vlistID2, varID, zaxisID2);
}
else
cdoAbort("Level %g not found!", chlevels[0]);
Free(levels);
if ( zaxisInqLevels(zaxisID1, NULL) )
{
nlevs = zaxisInqSize(zaxisID1);
levels = (double*) Malloc(nlevs*sizeof(double));
zaxisInqLevels(zaxisID1, levels);
nfound = 0;
for ( k = 0; k < nlevs; k++ )
if ( fabs(levels[k] - chlevels[0]) < 0.0001 ) nfound++;
if ( nfound )
{
zaxisID2 = zaxisDuplicate(zaxisID1);
for ( k = 0; k < nlevs; k++ )
if ( fabs(levels[k] - chlevels[0]) < 0.001 )
levels[k] = chlevels[1];
zaxisDefLevels(zaxisID2, levels);
vlistChangeVarZaxis(vlistID2, varID, zaxisID2);
}
else
cdoAbort("Level %g not found!", chlevels[0]);
Free(levels);
}
}
else if ( operatorID == CHLTYPE )
{
......
......@@ -125,7 +125,7 @@ void *Cloudlayer(void *argument)
int gridID, zaxisID;
int nlevel, nlevs, nrecs, code;
int varID, levelID;
int zrev = FALSE;
bool zrev = false;
int i;
int offset;
int nmiss;
......@@ -210,7 +210,7 @@ void *Cloudlayer(void *argument)
if ( plevs[0] > plevs[nlevel-1] )
{
double ptmp;
zrev = TRUE;
zrev = true;
for ( levelID = 0; levelID < nlevel/2; ++levelID )
{
ptmp = plevs[levelID];
......
......@@ -181,7 +181,8 @@ void *Diff(void *argument)
fprintf(stdout, "%s %s ", vdatestr, vtimestr);
reset_text_color(stdout);
set_text_color(stdout, RESET, GREEN);
fprintf(stdout, "%7g ", zaxisInqLevel(zaxisID, levelID));
double level = zaxisInqLevels(zaxisID, NULL) ? zaxisInqLevel(zaxisID, levelID) : levelID+1;
fprintf(stdout, "%7g ", level);
fprintf(stdout, "%8d %7d ", gridsize, MAX(nmiss1, nmiss2));
fprintf(stdout, "%7d ", ndiff);
reset_text_color(stdout);
......
......@@ -427,7 +427,7 @@ void *Expr(void *argument)
size_t nlev = parse_arg.coords[i].size;
double *data = (double*) Malloc(nlev*sizeof(double));
parse_arg.coords[i].data = data;
zaxisInqLevels(zaxisID, data);
cdoZaxisInqLevels(zaxisID, data);
}
else
cdoAbort("Computation of coordinate %c not implemented!", coord);
......
......@@ -51,7 +51,8 @@ void print_location_LL(int operfunc, int vlistID, int varID, int levelID, int gr
if ( gridInqType(gridID) == GRID_GAUSSIAN ||
gridInqType(gridID) == GRID_LONLAT )
{
double level = zaxisInqLevel(vlistInqVarZaxis(vlistID, varID), levelID);
int zaxisID = vlistInqVarZaxis(vlistID, varID);
double level = zaxisInqLevels(zaxisID, NULL) ? zaxisInqLevel(zaxisID, levelID) : levelID+1;
int nlon = gridInqXsize(gridID);
int nlat = gridInqYsize(gridID);
for ( int j = 0; j < nlat; ++j )
......@@ -73,8 +74,7 @@ void print_location_LL(int operfunc, int vlistID, int varID, int levelID, int gr
}
fprintf(stdout, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d %3d %7g %9.7g %9.7g %12.5g\n",
year, month, day, hour, minute, second,
code, level, xval, yval, sglval);
year, month, day, hour, minute, second, code, level, xval, yval, sglval);
}
}
}
......
......@@ -571,15 +571,14 @@ static
void ctl_zdef(FILE *gdp, int vlistID, bool *zrev)
{
int i, j, index;
int zaxisIDmax = -1, nlevmax;
int nzaxis, zaxisID, nlev;
int lplev = FALSE;
double *levels, level0, levinc = 0;
int zaxisIDmax = -1;
int zaxisID, nlev;
double levinc = 0;
*zrev = false;
nzaxis = vlistNzaxis(vlistID);
int nzaxis = vlistNzaxis(vlistID);
nlevmax = 0;
int nlevmax = 0;
for ( index = 0; index < nzaxis; index++ )
{
zaxisID = vlistZaxis(vlistID, index);
......@@ -591,10 +590,10 @@ void ctl_zdef(FILE *gdp, int vlistID, bool *zrev)
}
}
levels = (double*) Malloc(nlevmax*sizeof(double));
zaxisInqLevels(zaxisIDmax, levels);
if ( zaxisInqType(zaxisIDmax) == ZAXIS_PRESSURE ) lplev = TRUE;
level0 = levels[0];
double *levels = (double*) Malloc(nlevmax*sizeof(double));
cdoZaxisInqLevels(zaxisIDmax, levels);
bool lplev = (zaxisInqType(zaxisIDmax) == ZAXIS_PRESSURE);
double level0 = levels[0];
if ( nlevmax > 1 )
{
if ( levels[0] < levels[1] && zaxisInqType(zaxisIDmax) != ZAXIS_HYBRID )
......
......@@ -343,7 +343,7 @@ void *Info(void *argument)
set_text_color(stdout, RESET, MAGENTA);
fprintf(stdout, "%s %s ", vdatestr, vtimestr);
reset_text_color(stdout);
level = zaxisInqLevel(zaxisID, levelID);
level = zaxisInqLevels(zaxisID, NULL) ? zaxisInqLevel(zaxisID, levelID) : levelID+1;
set_text_color(stdout, RESET, GREEN);
fprintf(stdout, "%7g ", level);
fprintf(stdout, "%8d %7d ", gridsize, nmiss);
......
......@@ -213,7 +213,7 @@ void *Intlevel(void *argument)
int nlev1 = nlevel;
double *lev1 = (double*) Malloc((nlev1+2)*sizeof(double));
zaxisInqLevels(zaxisID1, lev1+1);
cdoZaxisInqLevels(zaxisID1, lev1+1);
bool lup = false;
bool ldown = false;
......
......@@ -41,7 +41,7 @@ void invertLevDes(int vlistID)
int nlev = zaxisInqSize(zaxisID1);
if ( nlev <= 1 ) continue;
/* if ( zaxisInqLevels(zaxisID1, NULL) ) */
if ( zaxisInqLevels(zaxisID1, NULL) )
{
double yv1[nlev], yv2[nlev];
zaxisInqLevels(zaxisID1, yv1);
......
......@@ -123,7 +123,7 @@ void *Isosurface(void *argument)
int nlev1 = nlevel;
double *lev1 = (double*) Malloc(nlev1*sizeof(double));
zaxisInqLevels(zaxisID1, lev1);
cdoZaxisInqLevels(zaxisID1, lev1);
int zaxisIDsfc = zaxisCreate(ZAXIS_SURFACE, 1);
for ( i = 0; i < nzaxis; i++ )
......
......@@ -45,7 +45,7 @@ void mastrfu(int gridID, int zaxisID, double *array1, double *array2, int nmiss,
double **field1 = (double**) Malloc(nlev*sizeof(double*));
double **field2 = (double**) Malloc(nlev*sizeof(double*));
zaxisInqLevels(zaxisID, plevel);
cdoZaxisInqLevels(zaxisID, plevel);
// gaussaw(phi, dummy, nlat);
......
......@@ -55,7 +55,7 @@ void checkDupEntry(int vlistID1, int vlistID2, const char *filename)
mlev1 = nlev1;
lev1 = (double*) Realloc(lev1, mlev1*sizeof(double));
}
zaxisInqLevels(zaxisID1, lev1);
cdoZaxisInqLevels(zaxisID1, lev1);
for ( int varID2 = 0; varID2 < nvars2; ++varID2 )
{
......@@ -74,7 +74,7 @@ void checkDupEntry(int vlistID1, int vlistID2, const char *filename)
mlev2 = nlev2;
lev2 = (double*) Realloc(lev2, mlev2*sizeof(double));
}
zaxisInqLevels(zaxisID2, lev2);
cdoZaxisInqLevels(zaxisID2, lev2);
for ( k = 0; k < nlev2; ++k )
if ( !IS_EQUAL(lev1[k], lev2[k]) ) break;
......
......@@ -205,8 +205,8 @@ void *Output(void *argument)
int gridsize = gridInqSize(gridID);
int nlon = gridInqXsize(gridID);
int nlat = gridInqYsize(gridID);
double level = zaxisInqLevel(zaxisID, levelID);
double missval = vlistInqVarMissval(vlistID, varID);
double level = zaxisInqLevels(zaxisID, NULL) ? zaxisInqLevel(zaxisID, levelID) : levelID+1;
double missval = vlistInqVarMissval(vlistID, varID);
cdiParamToString(param, paramstr, sizeof(paramstr));
......
......@@ -361,7 +361,7 @@ void *Outputgmt(void *argument)
double *zaxis_lower_lev = (double*) Malloc(nlev*sizeof(double));
double *zaxis_upper_lev = (double*) Malloc(nlev*sizeof(double));
zaxisInqLevels(zaxisID, zaxis_center_lev);
cdoZaxisInqLevels(zaxisID, zaxis_center_lev);
if ( luse_grid_corner )
{
......
......@@ -100,8 +100,8 @@ void *Pinfo(void *argument)
int code = vlistInqVarCode(vlistID1, varID);
int gridID = vlistInqVarGrid(vlistID1, varID);
int zaxisID = vlistInqVarZaxis(vlistID1, varID);
double missval = vlistInqVarMissval(vlistID1, varID);
int gridsize = gridInqSize(gridID);
double missval = vlistInqVarMissval(vlistID1, varID);
if ( operatorID == PINFOV ) vlistInqVarName(vlistID1, varID, varname);
......@@ -110,7 +110,7 @@ void *Pinfo(void *argument)
else
fprintf(stdout, "%6d :%s %s %3d", indg, vdatestr, vtimestr, code);
level = zaxisInqLevel(zaxisID, levelID);
level = zaxisInqLevels(zaxisID, NULL) ? zaxisInqLevel(zaxisID, levelID) : levelID+1;
fprintf(stdout, " %7g ", level);
fprintf(stdout, "%7d %7d :", gridsize, nmiss);
......
......@@ -122,8 +122,8 @@ void *Replace(void *argument)
{
double *level1 = (double*) Malloc(nlevel1*sizeof(double));
double *level2 = (double*) Malloc(nlevel2*sizeof(double));
zaxisInqLevels(vlistInqVarZaxis(vlistID1, varID1), level1);
zaxisInqLevels(vlistInqVarZaxis(vlistID2, varID2), level2);
cdoZaxisInqLevels(vlistInqVarZaxis(vlistID1, varID1), level1);
cdoZaxisInqLevels(vlistInqVarZaxis(vlistID2, varID2), level2);
for ( levelID = 0; levelID < nlevel1; levelID++ )
varlevel[idx][levelID] = -1;
......
......@@ -219,7 +219,7 @@ void *Rhopot(void *argument)
int nlevel = nlevel1;
double *pressure = (double*) Malloc(nlevel*sizeof(double));
zaxisInqLevels(zaxisID, pressure);
cdoZaxisInqLevels(zaxisID, pressure);
if ( pin >= 0 )
for ( int i = 0; i < nlevel; ++i ) pressure[i] = pin;
......
......@@ -252,7 +252,7 @@ void *Select(void *argument)
for ( int levID = 0; levID < nlevs; ++levID )
{
levidx = levID + 1;
level = zaxisInqLevel(zaxisID, levID);
level = zaxisInqLevels(zaxisID, NULL) ? zaxisInqLevel(zaxisID, levID) : levidx;
if ( !vars[varID] && PML_NOCC(pml, levidx) && PML_CHECK_INT(pml, levidx) ) vars[varID] = true;
if ( !vars[varID] && PML_NOCC(pml, level) && PML_CHECK_FLT(pml, level) ) vars[varID] = true;
}
......@@ -282,7 +282,7 @@ void *Select(void *argument)
for ( int levID = 0; levID < nlevs; ++levID )
{
levidx = levID + 1;
level = zaxisInqLevel(zaxisID, levID);
level = zaxisInqLevels(zaxisID, NULL) ? zaxisInqLevel(zaxisID, levID) : levidx;
if ( nlevs == 1 && IS_EQUAL(level, 0) )
{
......
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