Skip to content
Snippets Groups Projects
Commit 9c952061 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

sortlevel: added optional parameter -1 to reverse the sorting

parent 90b21639
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,10 @@
* using CDI library version 1.6.5
* Version 1.6.5 released
2014-10-21 Uwe Schulzweida
* sortlevel: added optional parameter -1 to reverse the sorting
2014-10-16 Uwe Schulzweida
* Ydrunstat: set the year of all output timesteps to the lowest year of the output timesteps
......
......@@ -49,8 +49,8 @@ static
int cmpvarcode(const void *s1, const void *s2)
{
int cmp = 0;
const varinfo_t *x = s1;
const varinfo_t *y = s2;
const varinfo_t *x = (const varinfo_t *) s1;
const varinfo_t *y = (const varinfo_t *) s2;
/*
printf("%d %d %d %d\n", x->code, y->code, x, y);
*/
......@@ -63,8 +63,8 @@ int cmpvarcode(const void *s1, const void *s2)
static
int cmpvarname(const void *s1, const void *s2)
{
const varinfo_t *x = s1;
const varinfo_t *y = s2;
const varinfo_t *x = (const varinfo_t *) s1;
const varinfo_t *y = (const varinfo_t *) s2;
return (strcmp(x->name, y->name));
}
......@@ -73,8 +73,8 @@ static
int cmpvarlevel(const void *s1, const void *s2)
{
int cmp = 0;
const levinfo_t *x = s1;
const levinfo_t *y = s2;
const levinfo_t *x = (const levinfo_t *) s1;
const levinfo_t *y = (const levinfo_t *) s2;
if ( x->level < y->level ) cmp = -1;
else if ( x->level > y->level ) cmp = 1;
......@@ -86,8 +86,8 @@ static
int cmpvarlevelrev(const void *s1, const void *s2)
{
int cmp = 0;
const levinfo_t *x = s1;
const levinfo_t *y = s2;
const levinfo_t *x = (const levinfo_t *) s1;
const levinfo_t *y = (const levinfo_t *) s2;
if ( x->level > y->level ) cmp = -1;
else if ( x->level < y->level ) cmp = 1;
......@@ -132,6 +132,7 @@ void *Sort(void *argument)
double **vardata = NULL;
varinfo_t *varInfo;
int taxisID1, taxisID2;
int (*cmpvarlev)(const void *, const void *) = cmpvarlevel;
cdoInitialize(argument);
......@@ -141,6 +142,14 @@ void *Sort(void *argument)
operatorID = cdoOperatorID();
if ( operatorArgc() > 1 ) cdoAbort("Too many arguments!");
if ( operatorID == SORTLEVEL && operatorArgc() == 1 )
{
int iarg = atoi(operatorArgv()[0]);
if ( iarg < 0 ) cmpvarlev = cmpvarlevelrev;
}
streamID1 = streamOpenRead(cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
......@@ -232,7 +241,7 @@ void *Sort(void *argument)
for ( vindex = 0; vindex < nvars; vindex++ )
{
nlevs = varInfo[vindex].nlevs;
qsort(varInfo[vindex].levInfo, nlevs, sizeof(levinfo_t), cmpvarlevel);
qsort(varInfo[vindex].levInfo, nlevs, sizeof(levinfo_t), cmpvarlev);
}
}
......
......@@ -342,13 +342,11 @@ void *Maggraph(void *argument);
#define InttimeOperators {"inttime"}
#define IntntimeOperators {"intntime"}
#define IntyearOperators {"intyear"}
#define InvertOperators {"invertlat", "invertlon", "invertlatdes", "invertlondes", \
"invertlatdata", "invertlondata"}
#define InvertOperators {"invertlat", "invertlon", "invertlatdes", "invertlondes", "invertlatdata", "invertlondata"}
#define InvertlevOperators {"invertlev"}
#define IsosurfaceOperators {"isosurface"}
#define KvlOperators {"read_cmor_table", "conv_cmor_table"}
#define LogOperators {"dumplogs", "daylogs", "monlogs", "dumplogo", \
"snamelogo", "scalllogo", "smemlogo", "stimelogo", "sperclogo"}
#define LogOperators {"dumplogs", "daylogs", "monlogs", "dumplogo", "snamelogo", "scalllogo", "smemlogo", "stimelogo", "sperclogo"}
#define MaskboxOperators {"masklonlatbox", "maskindexbox"}
#define MaskregionOperators {"maskregion"}
#define MastrfuOperators {"mastrfu"}
......@@ -457,8 +455,7 @@ void *Maggraph(void *argument);
#define VardupOperators {"pardup", "parmul"}
#define VargenOperators {"random", "const", "sincos", "coshill", "for", "topo", "temp", "mask", "stdatm"}
#define VarrmsOperators {"varrms"}
#define VertintOperators {"ml2pl", "ml2hl", "ml2plx", "ml2hlx", \
"ml2pl_lp", "ml2hl_lp", "ml2plx_lp", "ml2hlx_lp"}
#define VertintOperators {"ml2pl", "ml2hl", "ml2plx", "ml2hlx", "ml2pl_lp", "ml2hl_lp", "ml2plx_lp", "ml2hlx_lp"}
#define VertstatOperators {"vertmin", "vertmax", "vertsum", "vertmean", "vertavg", "vertvar", "vertstd"}
#define VertwindOperators {"vertwind"}
#define WindOperators {"uv2dv", "uv2dvl", "dv2uv", "dv2uvl", "dv2ps"}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment