Commit fcfd92e9 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Virtualize grid value comparisons.

parent 51c865b4
...@@ -2224,9 +2224,7 @@ int gridCompare(int gridID, const grid_t *grid) ...@@ -2224,9 +2224,7 @@ int gridCompare(int gridID, const grid_t *grid)
} }
} }
else if ( grid->xvals && grid->yvals ) else if ( grid->xvals && grid->yvals )
{ differ = gridRef->vtable->compareXYFull(gridRef, (grid_t *)grid);
differ = compareXYvals(gridRef, (grid_t *)grid);
}
} }
else else
differ = 1; differ = 1;
...@@ -2237,7 +2235,7 @@ int gridCompare(int gridID, const grid_t *grid) ...@@ -2237,7 +2235,7 @@ int gridCompare(int gridID, const grid_t *grid)
{ {
if ( grid->xdef == 1 && grid->ydef == 1 if ( grid->xdef == 1 && grid->ydef == 1
&& grid->xvals && grid->yvals ) && grid->xvals && grid->yvals )
differ = compareXYvals(gridRef, (grid_t *)grid); differ = gridRef->vtable->compareXYFull(gridRef, (grid_t *)grid);
} }
else if ( (grid->ysize == 0 || grid->ysize == 1) && else if ( (grid->ysize == 0 || grid->ysize == 1) &&
grid->xsize == gridInqXsize(gridID)*gridInqYsize(gridID) ) grid->xsize == gridInqXsize(gridID)*gridInqYsize(gridID) )
...@@ -2262,9 +2260,7 @@ int gridCompare(int gridID, const grid_t *grid) ...@@ -2262,9 +2260,7 @@ int gridCompare(int gridID, const grid_t *grid)
} }
} }
else if ( grid->xvals && grid->yvals ) else if ( grid->xvals && grid->yvals )
{ differ = gridRef->vtable->compareXYFull(gridRef, (grid_t *)grid);
differ = compareXYvals(gridRef, (grid_t *)grid);
}
} }
else else
differ = 1; differ = 1;
...@@ -2287,7 +2283,7 @@ int gridCompare(int gridID, const grid_t *grid) ...@@ -2287,7 +2283,7 @@ int gridCompare(int gridID, const grid_t *grid)
printf("grid nv %d\n", gridInqNvertex(gridID)); printf("grid nv %d\n", gridInqNvertex(gridID));
*/ */
if ( grid->xsize == gridInqXsize(gridID) && grid->ysize == gridInqYsize(gridID) ) if ( grid->xsize == gridInqXsize(gridID) && grid->ysize == gridInqYsize(gridID) )
differ = compareXYvals2(gridRef, (grid_t *)grid); differ = gridRef->vtable->compareXYAO(gridRef, (grid_t *)grid);
} }
else if ( grid->type == GRID_UNSTRUCTURED ) else if ( grid->type == GRID_UNSTRUCTURED )
{ {
...@@ -2318,7 +2314,7 @@ int gridCompare(int gridID, const grid_t *grid) ...@@ -2318,7 +2314,7 @@ int gridCompare(int gridID, const grid_t *grid)
differ = grid->nvertex != gridInqNvertex(gridID) differ = grid->nvertex != gridInqNvertex(gridID)
|| grid->number != gridInqNumber(gridID) || grid->number != gridInqNumber(gridID)
|| (grid->number > 0 && grid->position != gridInqPosition(gridID)) || (grid->number > 0 && grid->position != gridInqPosition(gridID))
|| compareXYvals2(gridRef, (grid_t *)grid); || gridRef->vtable->compareXYAO(gridRef, (grid_t *)grid);
} }
} }
} }
...@@ -4800,6 +4796,8 @@ const struct gridVirtTable cdiGridVtable ...@@ -4800,6 +4796,8 @@ const struct gridVirtTable cdiGridVtable
.inqYVals = gridInqYValsSerial, .inqYVals = gridInqYValsSerial,
.inqXValsPtr = gridInqXValsPtrSerial, .inqXValsPtr = gridInqXValsPtrSerial,
.inqYValsPtr = gridInqYValsPtrSerial, .inqYValsPtr = gridInqYValsPtrSerial,
.compareXYFull = compareXYvals,
.compareXYAO = compareXYvals2,
.inqArea = gridInqAreaSerial, .inqArea = gridInqAreaSerial,
.inqAreaPtr = gridInqAreaPtrBase, .inqAreaPtr = gridInqAreaPtrBase,
.hasArea = gridHasAreaBase, .hasArea = gridHasAreaBase,
......
...@@ -24,6 +24,11 @@ struct gridVirtTable ...@@ -24,6 +24,11 @@ struct gridVirtTable
int (*inqYVals)(grid_t *gridptr, double *yvals); int (*inqYVals)(grid_t *gridptr, double *yvals);
const double *(*inqXValsPtr)(grid_t *gridptr); const double *(*inqXValsPtr)(grid_t *gridptr);
const double *(*inqYValsPtr)(grid_t *gridptr); const double *(*inqYValsPtr)(grid_t *gridptr);
/* return if for both grids, all xval and all yval are equal */
int (*compareXYFull)(grid_t *gridRef, grid_t *gridTest);
/* return if for both grids, x[0], y[0], x[size-1] and y[size-1] are
* respectively equal */
int (*compareXYAO)(grid_t *gridRef, grid_t *gridTest);
void (*inqArea)(grid_t *gridptr, double *area); void (*inqArea)(grid_t *gridptr, double *area);
const double *(*inqAreaPtr)(grid_t *gridptr); const double *(*inqAreaPtr)(grid_t *gridptr);
int (*hasArea)(grid_t *gridptr); int (*hasArea)(grid_t *gridptr);
......
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