Commit 5d5d2b74 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

vlistCompare cleanup

parent bfba3cdd
......@@ -123,7 +123,7 @@ void *Arith(void *argument)
}
if ( filltype == FILL_NONE )
vlistCompare(vlistID1, vlistID2, func_sft);
vlistCompare(vlistID1, vlistID2, CMP_SFT);
gridsize = vlistGridsizeMax(vlistIDx1);
......@@ -214,7 +214,7 @@ void *Arith(void *argument)
vlistID2 = streamInqVlist(streamID2);
vlistIDx2 = vlistID2;
vlistCompare(vlistID1, vlistID2, func_sft);
vlistCompare(vlistID1, vlistID2, CMP_SFT);
nrecs2 = streamInqTimestep(streamIDx2, tsID2);
if ( nrecs2 == 0 )
......
......@@ -85,7 +85,7 @@ void *Cat(void *argument)
vlistID2 = streamInqVlist(streamID2);
taxisID2 = vlistInqTaxis(vlistID2);
vlistCompare(vlistID1, vlistID2, func_sft);
vlistCompare(vlistID1, vlistID2, CMP_SFT);
tsID2 = vlistNtsteps(vlistID2);
if ( tsID2 == 0 ) tsID2 = 1; /* bug fix for constant data only */
......
......@@ -102,7 +102,7 @@ void *Comp(void *argument)
}
if ( filltype == FILL_NONE )
vlistCompare(vlistID1, vlistID2, func_sft);
vlistCompare(vlistID1, vlistID2, CMP_SFT);
nospec(vlistID1);
nospec(vlistID2);
......
......@@ -78,7 +78,7 @@ void *Cond(void *argument)
}
if ( filltype == FILL_NONE )
vlistCompare(vlistID1, vlistID2, func_sft);
vlistCompare(vlistID1, vlistID2, CMP_SFT);
nospec(vlistID1);
nospec(vlistID2);
......
......@@ -79,9 +79,9 @@ void *Cond2(void *argument)
}
if ( filltype == FILL_NONE )
vlistCompare(vlistID1, vlistID2, func_sft);
vlistCompare(vlistID1, vlistID2, CMP_SFT);
vlistCompare(vlistID2, vlistID3, func_sft);
vlistCompare(vlistID2, vlistID3, CMP_SFT);
nospec(vlistID1);
nospec(vlistID2);
......
......@@ -101,8 +101,8 @@ void *Copy(void *argument)
}
else
{
vlistCompare(vlistID1, vlistID2, func_sft);
/* vlistCompare(vlistID1, vlistID2, func_hrd); */
vlistCompare(vlistID1, vlistID2, CMP_SFT);
/* vlistCompare(vlistID1, vlistID2, CMP_HRD); */
}
tsID1 = 0;
......
......@@ -48,7 +48,7 @@ void *Diff(void *argument)
int taxisID;
int nmiss1, nmiss2;
int ndrec = 0, nd2rec = 0, ngrec = 0;
int lfunc;
int cmpflag;
char varname[128];
char paramstr[32];
char vdatestr[32], vtimestr[32];
......@@ -74,14 +74,9 @@ void *Diff(void *argument)
vlistID1 = streamInqVlist(streamID1);
vlistID2 = streamInqVlist(streamID2);
lfunc = func_sftn;
/*
if ( operatorID == DIFFV )
lfunc = func_sftn;
else
lfunc = func_sftc;
*/
vlistCompare(vlistID1, vlistID2, lfunc);
cmpflag = CMP_NAME | CMP_GRIDSIZE | CMP_NLEVEL | CMP_GRID;
vlistCompare(vlistID1, vlistID2, cmpflag);
gridsize = vlistGridsizeMax(vlistID1);
......
......@@ -46,7 +46,7 @@ void *Ensstat(void *argument)
int operfunc;
int i;
int nvars;
int cmpfunc;
int cmpflag;
int varID, recID;
int gridsize = 0;
int gridID;
......@@ -139,12 +139,12 @@ void *Ensstat(void *argument)
/* check that the contents is always the same */
nvars = vlistNvars(ef[0].vlistID);
if ( nvars == 1 )
cmpfunc = func_sftn;
cmpflag = CMP_NAME | CMP_GRIDSIZE | CMP_NLEVEL | CMP_GRID;
else
cmpfunc = func_sftn;
cmpflag = CMP_NAME | CMP_GRIDSIZE | CMP_NLEVEL | CMP_GRID;
for ( fileID = 1; fileID < nfiles; fileID++ )
vlistCompare(ef[0].vlistID, ef[fileID].vlistID, cmpfunc);
vlistCompare(ef[0].vlistID, ef[fileID].vlistID, cmpflag);
vlistID1 = ef[0].vlistID;
vlistID2 = vlistDuplicate(vlistID1);
......
......@@ -109,7 +109,7 @@ void *Fldstat2(void *argument)
vlistID2 = streamInqVlist(streamID2);
vlistID3 = vlistDuplicate(vlistID1);
vlistCompare(vlistID1, vlistID2, func_sft);
vlistCompare(vlistID1, vlistID2, CMP_SFT);
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = vlistInqTaxis(vlistID2);
......
......@@ -56,7 +56,7 @@ int cmpx(const void *s1, const void *s2)
}
static
int cmpxy(const void *s1, const void *s2)
int cmpxy_lt(const void *s1, const void *s2)
{
int cmp = 0;
xyinfo_t *xy1 = (xyinfo_t *) s1;
......@@ -68,10 +68,24 @@ int cmpxy(const void *s1, const void *s2)
return (cmp);
}
static
int cmpxy_gt(const void *s1, const void *s2)
{
int cmp = 0;
xyinfo_t *xy1 = (xyinfo_t *) s1;
xyinfo_t *xy2 = (xyinfo_t *) s2;
if ( xy1->y > xy2->y || (!(fabs(xy1->y - xy2->y) > 0) && xy1->x < xy2->x) ) cmp = -1;
else if ( xy1->y < xy2->y || (!(fabs(xy1->y - xy2->y) > 0) && xy1->x > xy2->x) ) cmp = 1;
return (cmp);
}
static
int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid)
{
static char *func = "genGrid";
int lsouthnorth = TRUE;
int fileID;
int gridID;
int gridID2 = -1;
......@@ -89,7 +103,7 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid)
for ( fileID = 0; fileID < nfiles; fileID++ )
{
gridID = vlistGrid(ef[fileID].vlistID, igrid);
gridID = vlistGrid(ef[fileID].vlistID, igrid);
gridtype = gridInqType(gridID);
if ( !(gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN ||
(gridtype == GRID_GENERIC && gridInqXsize(gridID) > 0 && gridInqYsize(gridID) > 0)) )
......@@ -110,21 +124,32 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid)
xyinfo[fileID].x = xvals[fileID][0];
xyinfo[fileID].y = yvals[fileID][0];
xyinfo[fileID].id = fileID;
if ( fileID == 0 && ysize > 1 )
{
if ( yvals[fileID][0] > yvals[fileID][ysize-1] ) lsouthnorth = FALSE;
}
}
for ( fileID = 0; fileID < nfiles; fileID++ )
printf("1 %d %g %g \n", xyinfo[fileID].id, xyinfo[fileID].x, xyinfo[fileID].y);
if ( cdoVerbose )
for ( fileID = 0; fileID < nfiles; fileID++ )
printf("1 %d %g %g \n", xyinfo[fileID].id, xyinfo[fileID].x, xyinfo[fileID].y);
qsort(xyinfo, nfiles, sizeof(xyinfo_t), cmpx);
for ( fileID = 0; fileID < nfiles; fileID++ )
printf("2 %d %g %g \n", xyinfo[fileID].id, xyinfo[fileID].x, xyinfo[fileID].y);
qsort(xyinfo, nfiles, sizeof(xyinfo_t), cmpxy);
for ( fileID = 0; fileID < nfiles; fileID++ )
printf("3 %d %g %g \n", xyinfo[fileID].id, xyinfo[fileID].x, xyinfo[fileID].y);
if ( cdoVerbose )
for ( fileID = 0; fileID < nfiles; fileID++ )
printf("2 %d %g %g \n", xyinfo[fileID].id, xyinfo[fileID].x, xyinfo[fileID].y);
if ( lsouthnorth )
qsort(xyinfo, nfiles, sizeof(xyinfo_t), cmpxy_lt);
else
qsort(xyinfo, nfiles, sizeof(xyinfo_t), cmpxy_gt);
if ( cdoVerbose )
for ( fileID = 0; fileID < nfiles; fileID++ )
printf("3 %d %g %g \n", xyinfo[fileID].id, xyinfo[fileID].x, xyinfo[fileID].y);
nx = 1;
for ( fileID = 1; fileID < nfiles; fileID++ )
{
......@@ -259,9 +284,9 @@ void *Gather(void *argument)
/* check that the contents is always the same */
nvars = vlistNvars(ef[0].vlistID);
if ( nvars == 1 )
cmpfunc = func_sftn;
cmpfunc = CMP_NAME | CMP_GRIDSIZE | CMP_NLEVEL;
else
cmpfunc = func_sftn;
cmpfunc = CMP_NAME | CMP_GRIDSIZE | CMP_NLEVEL;
for ( fileID = 1; fileID < nfiles; fileID++ )
vlistCompare(ef[0].vlistID, ef[fileID].vlistID, cmpfunc);
......
......@@ -120,8 +120,8 @@ void *Hi(void *argument)
taxisID2 = vlistInqTaxis(vlistID2);
taxisID3 = vlistInqTaxis(vlistID3);
vlistCompare(vlistID1, vlistID2, func_sft);
vlistCompare(vlistID1, vlistID3, func_sft);
vlistCompare(vlistID1, vlistID2, CMP_SFT);
vlistCompare(vlistID1, vlistID3, CMP_SFT);
gridsize = vlistGridsizeMax(vlistID1);
......
......@@ -182,7 +182,7 @@ void *Mergegrid(void *argument)
vlistID2 = streamInqVlist(streamID2);
vlistCompare(vlistID1, vlistID2, func_code);
vlistCompare(vlistID1, vlistID2, CMP_CODE | CMP_NLEVEL);
ndiffgrids = 0;
for ( index = 1; index < vlistNgrids(vlistID1); index++ )
......
......@@ -80,7 +80,7 @@ void *Mergetime(void *argument)
/* check that the contents is always the same */
for ( fileID = 1; fileID < nfiles; fileID++ )
vlistCompare(sf[0].vlistID, sf[fileID].vlistID, func_hrd);
vlistCompare(sf[0].vlistID, sf[fileID].vlistID, CMP_HRD);
/* read the first time step */
for ( fileID = 0; fileID < nfiles; fileID++ )
......
......@@ -68,7 +68,7 @@ void *Monarith(void *argument)
vlistID2 = streamInqVlist(streamID2);
vlistID3 = vlistDuplicate(vlistID1);
vlistCompare(vlistID1, vlistID2, func_sft);
vlistCompare(vlistID1, vlistID2, CMP_SFT);
gridsize = vlistGridsizeMax(vlistID1);
......
......@@ -81,8 +81,8 @@ void *Seaspctl(void *argument)
vlistID3 = streamInqVlist(streamID3);
vlistID4 = vlistDuplicate(vlistID1);
vlistCompare(vlistID1, vlistID2, func_hrd);
vlistCompare(vlistID1, vlistID3, func_hrd);
vlistCompare(vlistID1, vlistID2, CMP_HRD);
vlistCompare(vlistID1, vlistID3, CMP_HRD);
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = vlistInqTaxis(vlistID2);
......
......@@ -649,8 +649,8 @@ void *Select(void *argument)
}
else
{
vlistCompare(vlistID0, vlistID1, func_sft);
/* vlistCompare(vlistID1, vlistID2, func_hrd); */
vlistCompare(vlistID0, vlistID1, CMP_SFT);
/* vlistCompare(vlistID1, vlistID2, CMP_HRD); */
}
tsID1 = 0;
......
......@@ -97,7 +97,7 @@ void *Sorttimestamp(void *argument)
}
else
{
vlistCompare(vlistID2, vlistID1, func_hrd);
vlistCompare(vlistID2, vlistID1, CMP_HRD);
}
nvars = vlistNvars(vlistID1);
......
......@@ -60,8 +60,8 @@ void *Subtrend(void *argument)
vlistID3 = streamInqVlist(streamID3);
vlistID4 = vlistDuplicate(vlistID1);
vlistCompare(vlistID1, vlistID2, func_sft);
vlistCompare(vlistID1, vlistID3, func_sft);
vlistCompare(vlistID1, vlistID2, CMP_SFT);
vlistCompare(vlistID1, vlistID3, CMP_SFT);
taxisID1 = vlistInqTaxis(vlistID1);
taxisID4 = taxisDuplicate(taxisID1);
......
......@@ -79,8 +79,8 @@ static void timpctl(int operatorID)
vlistID3 = streamInqVlist(streamID3);
vlistID4 = vlistDuplicate(vlistID1);
vlistCompare(vlistID1, vlistID2, func_hrd);
vlistCompare(vlistID1, vlistID3, func_hrd);
vlistCompare(vlistID1, vlistID2, CMP_HRD);
vlistCompare(vlistID1, vlistID3, CMP_HRD);
if ( cdoOperatorIntval(operatorID) == 16 ) vlistDefNtsteps(vlistID4, 1);
......
......@@ -87,8 +87,8 @@ void *Timselpctl(void *argument)
vlistID3 = streamInqVlist(streamID3);
vlistID4 = vlistDuplicate(vlistID1);
vlistCompare(vlistID1, vlistID2, func_hrd);
vlistCompare(vlistID1, vlistID3, func_hrd);
vlistCompare(vlistID1, vlistID2, CMP_HRD);
vlistCompare(vlistID1, vlistID3, CMP_HRD);
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = vlistInqTaxis(vlistID2);
......
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