API Reference#
Complex datatype defines
Datatype for complex numbers, for use with pfnc_def_var
Note
These only work when defining a variable with pfnc_def_var
. To check the type of an existing variable use pfnc_var_is_complex
, and to check if it is specifically using a compound datatype or a dimension use pfnc_var_is_complex_type
or pfnc_var_has_complex_dimension
respectively. @endnote
-
PFNC_FLOAT_COMPLEX#
Uses complex compound datatype with netCDF4 format, and complex dimension otherwise.
-
PFNC_FLOAT_COMPLEX_DIM#
Always use a complex dimension, regardless of file format.
-
PFNC_DOUBLE_COMPLEX#
Uses complex compound datatype with netCDF4 format, and complex dimension otherwise.
-
PFNC_DOUBLE_COMPLEX_DIM#
Always use a complex dimension, regardless of file format.
Wrappers
Wrappers for the equivalent nc_*
functions that correctly handle the start/count/stride arrays for complex dimensions.
When the variable is stored using a complex dimension, the file representation has one more dimension than the user-visible in-memory representation. For example, a 1D array:
double_complex data[5];
would be represented in the file with two dimensions (when not using a compound datatype!), and so if we use the standard netCDF API we would need to use {5, 2}
for the countp
arguments, for example, while using nc-complex, we only need {5}
.
NOTE: The pfnc_put/get*
functions do not currently handle conversion between float/double
base types
-
int pfnc_def_var(int ncid, const char *name, nc_type xtype, int ndims, const int *dimidsp, int *varidp)#
Extension to
nc_def_var
that also acceptsPFNC_FLOAT_COMPLEX
,PFNC_FLOAT_COMPLEX_DIM
,PFNC_DOUBLE_COMPLEX
, andPFNC_DOUBLE_COMPLEX_DIM
-
int pfnc_get_var_double_complex(int ncid, int varid, double_complex *ip)#
-
int pfnc_put_var_double_complex(int ncid, int varid, const double_complex *op)#
-
int pfnc_get_var_float_complex(int ncid, int varid, float_complex *ip)#
-
int pfnc_put_var_float_complex(int ncid, int varid, const float_complex *op)#
-
int pfnc_put_vara_double_complex(int ncid, int varid, const size_t *startp, const size_t *countp, const double_complex *op)#
-
int pfnc_get_vara_double_complex(int ncid, int varid, const size_t *startp, const size_t *countp, double_complex *ip)#
-
int pfnc_put_vars_double_complex(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const double_complex *op)#
-
int pfnc_get_vars_double_complex(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, double_complex *ip)#
-
int pfnc_put_var1_double_complex(int ncid, int varid, const size_t *indexp, const double_complex *data)#
-
int pfnc_get_var1_double_complex(int ncid, int varid, const size_t *indexp, double_complex *data)#
-
int pfnc_put_vara_float_complex(int ncid, int varid, const size_t *startp, const size_t *countp, const float_complex *op)#
-
int pfnc_get_vara_float_complex(int ncid, int varid, const size_t *startp, const size_t *countp, float_complex *ip)#
-
int pfnc_put_vars_float_complex(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const float_complex *op)#
-
int pfnc_get_vars_float_complex(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, float_complex *ip)#
-
int pfnc_put_var1_float_complex(int ncid, int varid, const size_t *indexp, const float_complex *data)#
-
int pfnc_get_var1_float_complex(int ncid, int varid, const size_t *indexp, float_complex *data)#
-
int pfnc_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp)#
-
inline int pfnc_inq_varndims(int ncid, int varid, int *ndimsp)#
-
inline int pfnc_inq_vardimid(int ncid, int varid, int *dimidsp)#
-
int pfnc_def_var_chunking(int ncid, int varid, int storage, const size_t *chunksizesp)#
-
int pfnc_inq_var_chunking(int ncid, int varid, int *storagep, size_t *chunksizesp)#
-
int pfnc_get_vara(int ncid, int varid, const size_t *startp, const size_t *countp, void *ip)#
-
int pfnc_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, void *ip)#
-
int pfnc_put_vara(int ncid, int varid, const size_t *startp, const size_t *countp, const void *op)#
-
int pfnc_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const void *op)#
Typedefs
-
typedef double _Complex double_complex#
nc-complex: A lightweight, drop-in extension for complex number support in netCDF
Copyright (C) 2023 Peter Hill
SPDX-License-Identifier: MIT Portable typedefs for complex numbers
These become aliases for
std::complex
with C++.
-
typedef float _Complex float_complex#
Functions
-
bool pfnc_var_is_complex(int ncid, int varid)#
Return true if variable is complex.
-
bool pfnc_var_is_complex_type(int ncid, int varid)#
Return true if variable is complex and uses a compound datatype.
-
bool pfnc_var_has_complex_dimension(int ncid, int varid)#
Return true if variable is complex and has a complex dimension (assumed to be the last dimension)
-
bool pfnc_is_complex_dim(int ncid, int dim_id)#
Return true if dimension is complex.
-
int pfnc_get_double_complex_typeid(int ncid, nc_type *nc_typeid)#
Get the ID for the complex datatype with
double
elements, creating it if it doesn’t already exist.
-
int pfnc_get_float_complex_typeid(int ncid, nc_type *nc_typeid)#
Get the ID for the complex datatype with
float
elements, creating it if it doesn’t already exist.
-
int pfnc_get_complex_dim(int ncid, int *nc_dim)#
Get complex dimension, creating one if it doesn’t already exist.
-
int pfnc_complex_base_type(int ncid, nc_type nc_typeid, nc_type *base_type_id)#
Get the base numerical type of a complex type
Returns the type of the components for a compound type, or the type of an element for a dimension type.
-
int pfnc_inq_var_complex_base_type(int ncid, int varid, nc_type *nc_typeid)#
Get the base numerical type of a complex variable.
-
const char *pfnc_inq_libvers(void)#
Return some information about the
nc-complex
library.