Commit 6da77d75 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added gridInqXvalsPart() and gridInqYvalsPart().

parent 545ed5e9
......@@ -3,6 +3,10 @@
* using EXSE library version 1.4.1
* Version 1.9.6 released
2018-09-26 Uwe Schulzweida
* Added gridInqXvalsPart() and gridInqYvalsPart() [patch from: Niklas Rber]
2018-09-17 Uwe Schulzweida
* Added function cdiInqGridMissval()
......
......@@ -760,6 +760,7 @@ void gridDefXvals(int gridID, const double xvals[]);
/* gridInqXvals: Get all values of a X-axis */
size_t gridInqXvals(int gridID, double xvals[]);
size_t gridInqXvalsPart(int gridID, int start, size_t size, double xvals[]);
/* gridInqXIsc: Find out whether X-coordinate is of type CHAR */
int gridInqXIsc(int gridID);
......@@ -772,6 +773,7 @@ void gridDefYvals(int gridID, const double yvals[]);
/* gridInqYvals: Get all values of a Y-axis */
size_t gridInqYvals(int gridID, double yvals[]);
size_t gridInqYvalsPart(int gridID, int start, size_t size, double yvals[]);
/* gridInqYIsc: Find out whether Y-coordinate is of type CHAR */
int gridInqYIsc(int gridID);
......
......@@ -1542,6 +1542,32 @@ size_t gridInqXValsSerial(grid_t *gridptr, double *xvals)
return size;
}
static
size_t gridInqXValsPartSerial(grid_t *gridptr, int start, size_t length, double *xvals)
{
size_t size;
if ( gridptr->type == GRID_CURVILINEAR || gridptr->type == GRID_UNSTRUCTURED )
size = gridptr->size;
else if ( gridptr->type == GRID_GAUSSIAN_REDUCED )
size = 2;
else
size = gridptr->x.size;
if ( CDI_Debug && size == 0 )
Warning("size undefined for gridID = %d", gridptr->self);
if ( gridptr->x.vals )
{
if ( size && xvals )
{
const double *gridptr_xvals = gridptr->vtable->inqXValsPtr(gridptr);
memcpy(xvals, gridptr_xvals+start, length * sizeof (double));
}
}
else
size = 0;
}
static
size_t gridInqXCvalsSerial(grid_t *gridptr, char **xcvals)
{
......@@ -1600,6 +1626,13 @@ size_t gridInqXvals(int gridID, double *xvals)
}
size_t gridInqXvalsPart(int gridID, int start, size_t length, double *xvals)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->vtable->inqXValsPart(gridptr, start, length, xvals);
}
size_t gridInqXCvals(int gridID, char **xcvals)
{
grid_t *gridptr = grid_to_pointer(gridID);
......@@ -1712,6 +1745,30 @@ size_t gridInqYValsSerial(grid_t *gridptr, double *yvals)
return size;
}
static
size_t gridInqYValsPartSerial(grid_t *gridptr, int start, size_t length, double *yvals)
{
int gridtype = gridptr->type;
size_t size = (gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED)
? gridptr->size : gridptr->y.size;
if ( CDI_Debug && size == 0 )
Warning("size undefined for gridID = %d!", gridptr->self);
if ( gridptr->y.vals )
{
if ( size && yvals )
{
const double *gridptr_yvals = gridptr->vtable->inqYValsPtr(gridptr);
memcpy(yvals, gridptr_yvals+start, length * sizeof (double));
}
}
else
size = 0;
return size;
}
/*
@Function gridInqYvals
@Title Get all values of a Y-axis
......@@ -1739,6 +1796,13 @@ size_t gridInqYvals(int gridID, double *yvals)
}
size_t gridInqYvalsPart(int gridID, int start, size_t size, double *yvals)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->vtable->inqYValsPart(gridptr, start, size, yvals);
}
size_t gridInqYCvals(int gridID, char **ycvals)
{
grid_t *gridptr = grid_to_pointer(gridID);
......@@ -5057,9 +5121,11 @@ const struct gridVirtTable cdiGridVtable
.inqXVal = gridInqXValSerial,
.inqYVal = gridInqYValSerial,
.inqXVals = gridInqXValsSerial,
.inqXValsPart = gridInqXValsPartSerial,
.inqXCvals = gridInqXCvalsSerial,
.inqXIsc = gridInqXIscSerial,
.inqYVals = gridInqYValsSerial,
.inqYValsPart = gridInqYValsPartSerial,
.inqYCvals = gridInqYCvalsSerial,
.inqYIsc = gridInqYIscSerial,
.inqXValsPtr = gridInqXValsPtrSerial,
......
......@@ -31,9 +31,11 @@ struct gridVirtTable
double (*inqXVal)(grid_t *gridptr, size_t index);
double (*inqYVal)(grid_t *gridptr, size_t index);
size_t (*inqXVals)(grid_t *gridptr, double *xvals);
size_t (*inqXValsPart)(grid_t *gridptr, int start, size_t length, double *xvals);
size_t (*inqXCvals)(grid_t *gridptr, char **xcvals);
int (*inqXIsc)(grid_t *gridptr);
size_t (*inqYVals)(grid_t *gridptr, double *yvals);
size_t (*inqYValsPart)(grid_t *gridptr, int start, size_t length, double *yvals);
size_t (*inqYCvals)(grid_t *gridptr, char **ycvals);
int (*inqYIsc)(grid_t *gridptr);
const double *(*inqXValsPtr)(grid_t *gridptr);
......
Markdown is supported
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