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

vertintml: use psname if available

parent 2453fb4c
......@@ -464,7 +464,7 @@ void par_check_word_flag(int npar, char **parlist, int *flaglist, const char *tx
}
int vlist_get_psvarid(int nvars, int vlistID, int zaxisID)
int vlist_get_psvarid(int vlistID, int zaxisID)
{
int psvarid = -1;
char name[CDI_MAX_NAME];
......@@ -474,6 +474,7 @@ int vlist_get_psvarid(int nvars, int vlistID, int zaxisID)
if ( psname[0] )
{
int nvars = vlistNvars(vlistID);
for ( int varID = 0; varID < nvars; ++varID )
{
vlistInqVarName(vlistID, varID, name);
......@@ -483,6 +484,8 @@ int vlist_get_psvarid(int nvars, int vlistID, int zaxisID)
break;
}
}
if ( cdoVerbose && psvarid == -1 )
cdoWarning("Surface pressure variable not found - %s", psname);
}
return psvarid;
......@@ -718,7 +721,7 @@ void *Select(void *argument)
zaxisID = vlistInqVarZaxis(vlistID1, varID);
if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID )
{
int psvarid = vlist_get_psvarid(nvars, vlistID1, zaxisID);
int psvarid = vlist_get_psvarid(vlistID1, zaxisID);
if ( psvarid != -1 && !vars[psvarid] ) vars[psvarid] = TRUE;
}
}
......
......@@ -70,8 +70,6 @@ void *Vertintml(void *argument)
int useTable;
gribcode_t gribcodes = {0};
LIST *flist = listNew(FLT_LIST);
char psname[CDI_MAX_NAME];
psname[0] = 0;
cdoInitialize(argument);
......@@ -266,10 +264,11 @@ void *Vertintml(void *argument)
}
}
int psvarID = -1;
int linvertvct = FALSE;
if ( lhavevct && nvct && nvct%2 == 0 )
{
zaxisInqPsName(zaxisID, psname);
psvarID = vlist_get_psvarid(vlistID1, zaxisIDh);
for ( i = nvct/2+1; i < nvct; i++ )
if ( vct[i] > vct[i-1] ) break;
......@@ -278,7 +277,6 @@ void *Vertintml(void *argument)
}
if ( cdoVerbose ) cdoPrint("linvertvct = %d", linvertvct);
if ( cdoVerbose ) cdoPrint("psname = %s", psname);
if ( linvertvct )
{
......@@ -501,7 +499,9 @@ void *Vertintml(void *argument)
cdoAbort("Temperature not found, needed for vertical interpolation of geopotheight!");
presID = lnpsID;
if ( zaxisIDh != -1 && lnpsID == -1 )
if ( psvarID != -1 ) presID = psvarID;
if ( zaxisIDh != -1 && presID == -1 )
{
if ( psID == -1 )
cdoAbort("%s not found!", var_stdname(surface_air_pressure));
......@@ -511,10 +511,11 @@ void *Vertintml(void *argument)
if ( cdoVerbose )
{
vlistInqVarName(vlistID1, presID, varname);
if ( presID == lnpsID )
cdoPrint("using LOG(%s)", var_stdname(surface_air_pressure));
cdoPrint("using LOG(%s) from %s", var_stdname(surface_air_pressure), varname);
else
cdoPrint("using %s", var_stdname(surface_air_pressure));
cdoPrint("using %s from %s", var_stdname(surface_air_pressure), varname);
}
// check VCT
......@@ -585,10 +586,10 @@ void *Vertintml(void *argument)
}
}
if ( lnpsID != -1 )
if ( presID == lnpsID )
for ( i = 0; i < gridsize; i++ ) ps_prog[i] = exp(vardata1[lnpsID][i]);
else if ( psID != -1 )
memcpy(ps_prog, vardata1[psID], gridsize*sizeof(double));
else if ( presID != -1 )
memcpy(ps_prog, vardata1[presID], gridsize*sizeof(double));
/* check range of ps_prog */
minmaxval(gridsize, ps_prog, NULL, &minval, &maxval);
......
......@@ -150,5 +150,4 @@ double parameter2double(const char *string);
int parameter2int(const char *string);
int parameter2intlist(const char *string);
#endif /* _CDO_INT_H */
......@@ -187,7 +187,7 @@ int cdoDefineZaxis(const char *zaxisfile);
int vlistInqNWPV(int vlistID, int varID);
int vlistIsSzipped(int vlistID);
int vlist_check_gridsize(int vlistID);
int vlist_get_psvarid(int vlistID, int zaxisID);
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