Commit fc1e1ba6 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

selname: select also ps for variables on hybrid sigma pressure levels

parent 2ae55802
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
* using CDI library version 1.7.1 * using CDI library version 1.7.1
* Version 1.7.1 released * Version 1.7.1 released
2015-11-25 Uwe Schulzweida
* selname: select also ps for variables on hybrid sigma pressure levels
2015-11-18 Modali Kameswarrao 2015-11-18 Modali Kameswarrao
* Magplot: added support for projections and regions * Magplot: added support for projections and regions
......
...@@ -480,7 +480,7 @@ int vlist_get_psvarid(int vlistID, int zaxisID) ...@@ -480,7 +480,7 @@ int vlist_get_psvarid(int vlistID, int zaxisID)
if ( cdoVerbose && psvarid == -1 ) if ( cdoVerbose && psvarid == -1 )
cdoWarning("Surface pressure variable not found - %s", psname); cdoWarning("Surface pressure variable not found - %s", psname);
} }
return psvarid; return psvarid;
} }
...@@ -666,7 +666,6 @@ void *Select(void *argument) ...@@ -666,7 +666,6 @@ void *Select(void *argument)
nlevs = zaxisInqSize(zaxisID); nlevs = zaxisInqSize(zaxisID);
ltype = zaxis2ltype(zaxisID); ltype = zaxis2ltype(zaxisID);
vars[varID] = FALSE; vars[varID] = FALSE;
if ( npar_ltype ) if ( npar_ltype )
...@@ -711,7 +710,7 @@ void *Select(void *argument) ...@@ -711,7 +710,7 @@ void *Select(void *argument)
{ {
if ( vars[varID] ) if ( vars[varID] )
{ {
zaxisID = vlistInqVarZaxis(vlistID1, varID); int zaxisID = vlistInqVarZaxis(vlistID1, varID);
if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID ) if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID )
{ {
int psvarid = vlist_get_psvarid(vlistID1, zaxisID); int psvarid = vlist_get_psvarid(vlistID1, zaxisID);
......
...@@ -144,6 +144,7 @@ void *Selvar(void *argument) ...@@ -144,6 +144,7 @@ void *Selvar(void *argument)
int vlistID1 = streamInqVlist(streamID1); int vlistID1 = streamInqVlist(streamID1);
int nvars = vlistNvars(vlistID1); int nvars = vlistNvars(vlistID1);
int *vars = (int*) Malloc(nvars*sizeof(int));
if ( operatorID == SELGRID && !args_are_numeric && nsel == 1 && strncmp(argnames[0], "var=", 4) == 0 ) if ( operatorID == SELGRID && !args_are_numeric && nsel == 1 && strncmp(argnames[0], "var=", 4) == 0 )
{ {
...@@ -170,6 +171,8 @@ void *Selvar(void *argument) ...@@ -170,6 +171,8 @@ void *Selvar(void *argument)
vlistClearFlag(vlistID1); vlistClearFlag(vlistID1);
for ( varID = 0; varID < nvars; varID++ ) for ( varID = 0; varID < nvars; varID++ )
{ {
vars[varID] = FALSE;
vlistInqVarName(vlistID1, varID, varname); vlistInqVarName(vlistID1, varID, varname);
vlistInqVarStdname(vlistID1, varID, stdname); vlistInqVarStdname(vlistID1, varID, stdname);
param = vlistInqVarParam(vlistID1, varID); param = vlistInqVarParam(vlistID1, varID);
...@@ -210,7 +213,7 @@ void *Selvar(void *argument) ...@@ -210,7 +213,7 @@ void *Selvar(void *argument)
} }
else if ( operatorID == SELSTDNAME ) else if ( operatorID == SELSTDNAME )
{ {
found = strcmp(argnames[isel], stdname) == 0; found = wildcardmatch(argnames[isel], stdname) == 0;
} }
else if ( operatorID == SELLEVEL ) else if ( operatorID == SELLEVEL )
{ {
...@@ -265,22 +268,30 @@ void *Selvar(void *argument) ...@@ -265,22 +268,30 @@ void *Selvar(void *argument)
{ {
vlistDefFlag(vlistID1, varID, levID, !INVERTS_SELECTION(operatorID)); vlistDefFlag(vlistID1, varID, levID, !INVERTS_SELECTION(operatorID));
selfound[isel] = TRUE; selfound[isel] = TRUE;
vars[varID] = TRUE;
} }
} }
} }
} }
int npar = 0; int npar = 0;
for ( varID = 0; varID < nvars; varID++ ) if ( vars[varID] ) npar++;
for ( varID = 0; varID < nvars; varID++ ) for ( varID = 0; varID < nvars; varID++ )
{ {
zaxisID = vlistInqVarZaxis(vlistID1, varID); if ( vars[varID] )
nlevs = zaxisInqSize(zaxisID); {
int zaxisID = vlistInqVarZaxis(vlistID1, varID);
for ( levID = 0; levID < nlevs; levID++ ) if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID )
if ( vlistInqFlag(vlistID1, varID, levID) == TRUE ) break; {
int psvarid = vlist_get_psvarid(vlistID1, zaxisID);
if ( levID < nlevs ) npar++; if ( psvarid != -1 && !vars[psvarid] )
{
vars[psvarid] = TRUE;
vlistDefFlag(vlistID1, psvarid, 0, !INVERTS_SELECTION(operatorID));
}
}
}
} }
for ( isel = 0; isel < nsel; isel++ ) for ( isel = 0; isel < nsel; isel++ )
...@@ -408,6 +419,8 @@ void *Selvar(void *argument) ...@@ -408,6 +419,8 @@ void *Selvar(void *argument)
if ( ! lcopy ) if ( ! lcopy )
if ( array ) Free(array); if ( array ) Free(array);
if ( vars ) Free(vars);
if ( selfound ) Free(selfound); if ( selfound ) Free(selfound);
listDelete(ilist); listDelete(ilist);
......
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