S
Sheldon
Hi,
Can someone please explain how one can pass a 2D array to a function
but only using a single pointer?
This example surely does this and it is confusing the heck out me:
int nc_put_vars_float (int ncid, int varid, const size_t start[],
const size_t count[], const ptrdiff_t stride[],
const float *fp);
#include <netcdf.h>
...
#define NDIM 2 /* rank of netCDF variable */
int ncid; /* netCDF ID */
int status; /* error status */
int rhid; /* variable ID */
static size_t start[NDIM] /* netCDF variable start point: */
= {0, 0}; /* first element */
static size_t count[NDIM] /* size of internal array: entire
*/
= {2, 3}; /* (subsampled) netCDF variable */
static ptrdiff_t stride[NDIM] /* variable subsampling intervals:
*/
= {2, 2}; /* access every other netCDF
element */
float rh[2][3]; /* note subsampled sizes for */
/* netCDF variable dimensions */
...
status = nc_open("foo.nc", NC_WRITE, &ncid);
if (status != NC_NOERR) handle_error(status);
...
status = nc_inq_varid(ncid, "rh", &rhid);
if (status != NC_NOERR) handle_error(status);
...
status = nc_put_vars_float(ncid, rhid, start, count, stride, rh);
if (status != NC_NOERR) handle_error(status);
Complete example:
http://www.unidata.ucar.edu/softwar..._005f-type.html#nc_005fput_005fvars_005f-type
I want to use the nc_put_vars_float function but my arrays are within
a structure and when I call the function giving it ptr->array where
array is a 2D array, I get an error of incompatible pointer type.
Can someone please explain what's going on and how I can modify my
struct array so that this function accepts it?
Sincerely,
Marston
Can someone please explain how one can pass a 2D array to a function
but only using a single pointer?
This example surely does this and it is confusing the heck out me:
int nc_put_vars_float (int ncid, int varid, const size_t start[],
const size_t count[], const ptrdiff_t stride[],
const float *fp);
#include <netcdf.h>
...
#define NDIM 2 /* rank of netCDF variable */
int ncid; /* netCDF ID */
int status; /* error status */
int rhid; /* variable ID */
static size_t start[NDIM] /* netCDF variable start point: */
= {0, 0}; /* first element */
static size_t count[NDIM] /* size of internal array: entire
*/
= {2, 3}; /* (subsampled) netCDF variable */
static ptrdiff_t stride[NDIM] /* variable subsampling intervals:
*/
= {2, 2}; /* access every other netCDF
element */
float rh[2][3]; /* note subsampled sizes for */
/* netCDF variable dimensions */
...
status = nc_open("foo.nc", NC_WRITE, &ncid);
if (status != NC_NOERR) handle_error(status);
...
status = nc_inq_varid(ncid, "rh", &rhid);
if (status != NC_NOERR) handle_error(status);
...
status = nc_put_vars_float(ncid, rhid, start, count, stride, rh);
if (status != NC_NOERR) handle_error(status);
Complete example:
http://www.unidata.ucar.edu/softwar..._005f-type.html#nc_005fput_005fvars_005f-type
I want to use the nc_put_vars_float function but my arrays are within
a structure and when I call the function giving it ptr->array where
array is a 2D array, I get an error of incompatible pointer type.
Can someone please explain what's going on and how I can modify my
struct array so that this function accepts it?
Sincerely,
Marston