|
NEP 4.3.0
NetCDF Expansion Pack
|
Public API for the nxCDF UDF backend. More...
Go to the source code of this file.
Data Structures | |
| struct | nc_std_ref_s |
Macros | |
| #define | NC_FORMATX_NXCDF NC_FORMATX_UDF9 |
| Extended format identifier reported by nc_inq_format_extended() for nxCDF files. | |
| #define | NC_NXCDF NEP_UDF_NXCDF |
| #define | NC_NETCDF4_MODEL 0x04000000 |
| #define | NC_SWMR_WRITE 0x08000000 |
| #define | NC_SWMR_READ 0x10000000 |
| #define | NC_FLOAT16 17 |
| #define | NC_BFLOAT16 18 |
| #define | NC_FLOAT8_E4M3 19 |
| #define | NC_FLOAT8_E5M2 20 |
| #define | NC_FLOAT6_E2M3 21 |
| #define | NC_FLOAT6_E3M2 22 |
| #define | NC_FLOAT4_E2M1 23 |
| #define | NC_COMPLEX 24 |
| #define | NC_DOUBLECOMPLEX 25 |
| #define | NC_BITFIELD8 26 |
| #define | NC_BITFIELD16 27 |
| #define | NC_BITFIELD32 28 |
| #define | NC_BITFIELD64 29 |
| #define | NC_STD_REF 30 |
| #define | NC_STD_REF_SIZE 64 |
| #define | NC_STD_REF_OBJECT 1 |
| #define | NC_STD_REF_REGION 2 |
| #define | NC_STD_REF_ATTR 3 |
| #define | NC_REF_OBJ_VAR 1 |
| #define | NC_REF_OBJ_GRP 2 |
| #define | NC_REF_OBJ_TYPE 3 |
| #define | NC_REF_OBJ_ATT 4 |
Typedefs | |
| typedef struct nc_std_ref_s | nc_std_ref_t |
Functions | |
| NC_Dispatch * | NC_NXCDF_initialize (void) |
| Register the nxCDF dispatch table in UDF slot 9. | |
| int | NC_NXCDF_finalize (void) |
| Finalize process-wide nxCDF dispatch state. | |
| int | nc_ref_object (int ncid, int obj_type, int objid, nc_std_ref_t *ref) |
| Create an HDF5 object reference to a variable, group, or user-defined type in a nxCDF file. | |
| int | nc_deref_object (int ncid, const nc_std_ref_t *ref, int *obj_typep, int *grpidp, int *idp) |
| Resolve an object reference token back to NetCDF ids. | |
| int | nc_ref_region (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, nc_std_ref_t *ref) |
| Create a dataset region reference to a strided hyperslab of a variable in a nxCDF file. | |
| int | nc_deref_region (int ncid, const nc_std_ref_t *ref, int *grpidp, int *varidp, int *ndimsp, size_t *startp, size_t *countp, ptrdiff_t *stridep) |
| Resolve a dataset region reference token back to its variable and selection. | |
| int | nc_ref_attr (int ncid, int obj_type, int objid, const char *att_name, nc_std_ref_t *ref) |
| Create an HDF5 attribute reference to an attribute on a variable, group, or committed datatype in a nxCDF file. | |
| int | nc_deref_attr (int ncid, const nc_std_ref_t *ref, int *obj_typep, int *grpidp, int *idp, char *att_name) |
| Resolve an attribute reference token back to its owner and attribute name. | |
| int | nc_ref_object_ext (int ncid, const char *filename, const char *path, nc_std_ref_t *ref) |
| Create an object reference pointing into another file. | |
| int | nc_ref_region_ext (int ncid, const char *filename, const char *path, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, nc_std_ref_t *ref) |
| Create a dataset region reference pointing into another file. | |
| int | nc_ref_attr_ext (int ncid, const char *filename, const char *path, const char *att_name, nc_std_ref_t *ref) |
| Create an attribute reference pointing into another file. | |
| int | nc_ref_open_target (int ncid, const nc_std_ref_t *ref, int *target_ncidp) |
| Open the external file a reference token points into. | |
| int | nc_ref_get_type (const nc_std_ref_t *ref, int *ref_typep) |
| Report the kind of a reference token. | |
| int | nc_ref_get_file_name (const nc_std_ref_t *ref, char *name, size_t size) |
| Copy the file name stored in a reference token. | |
| int | nc_ref_get_obj_name (const nc_std_ref_t *ref, char *name, size_t size) |
| Copy the object path stored in a reference token. | |
| int | nc_ref_free (nc_std_ref_t *ref) |
| Release the resources held by a reference token. | |
| int | nc_ref_open_remote (int ncid, const char *url, const char *path, int *target_ncidp, int *kindp, int *objidp, char *att_name, size_t att_name_size) |
| Open a remote reference target and resolve its object path. | |
| int | nc_ref_resolve (int ncid, const char *path, int *kindp, int *objidp, char *att_name, size_t att_name_size) |
| Resolve an object path on an already-open remote session. | |
| int | nc_start_swmr_write (int ncid) |
| Start a single-writer/multiple-reader session on a native nxCDF file. | |
| int | nc_swmr_flush (int ncid) |
| Publish all datasets and dimension scales of an active SWMR writer. | |
| int | nc_swmr_refresh (int ncid) |
| Refresh a nxCDF SWMR reader session so newly published data becomes visible. | |
Public API for the nxCDF UDF backend.
nxCDF is a netCDF User Defined Format (UDF) backend: a plug-in file format registered in UDF slot 9 (NC_NXCDF). This installed header declares everything applications need — the mode flags, the extended format identifier, the initialize/finalize pair, the nxCDF atomic types, and the reference, remote-reference, and SWMR APIs. nc_create()/nc_open() with the NC_NXCDF mode flag routes to the backend through netcdf-c; see nxCDF Architecture.
This header may be included by downstream projects: it depends only on installed netcdf-c headers and nep.h.
| #define NC_BFLOAT16 18 |
nxCDF 16-bit bfloat16 floating point type (HDF5 2.1.1+). Untyped I/O uses raw uint16_t; typed float/double I/O uses NEP round-to-nearest-even, with single rounding from double.
| #define NC_BITFIELD16 27 |
nxCDF 16-bit bitfield type.
| #define NC_BITFIELD32 28 |
nxCDF 32-bit bitfield type.
| #define NC_BITFIELD64 29 |
nxCDF 64-bit bitfield type.
| #define NC_BITFIELD8 26 |
nxCDF 8-bit bitfield type.
| #define NC_COMPLEX 24 |
nxCDF single-precision complex number type.
| #define NC_DOUBLECOMPLEX 25 |
nxCDF double-precision complex number type.
| #define NC_FLOAT16 17 |
nxCDF 16-bit IEEE 754 half-precision floating point type. Untyped I/O uses raw uint16_t; typed float/double I/O uses NEP round-to-nearest-even, with single rounding from double.
| #define NC_FLOAT4_E2M1 23 |
nxCDF 4-bit E2M1 floating point type (HDF5 2.1.1+). Untyped I/O (raw uint8_t) only.
| #define NC_FLOAT6_E2M3 21 |
nxCDF 6-bit E2M3 floating point type (HDF5 2.1.1+). Untyped I/O (raw uint8_t) only.
| #define NC_FLOAT6_E3M2 22 |
nxCDF 6-bit E3M2 floating point type (HDF5 2.1.1+). Untyped I/O (raw uint8_t) only.
| #define NC_FLOAT8_E4M3 19 |
nxCDF 8-bit E4M3 floating point type (HDF5 2.1.1+). Untyped I/O (raw uint8_t) only.
| #define NC_FLOAT8_E5M2 20 |
nxCDF 8-bit E5M2 floating point type (HDF5 2.1.1+). Untyped I/O (raw uint8_t) only.
| #define NC_FORMATX_NXCDF NC_FORMATX_UDF9 |
Extended format identifier reported by nc_inq_format_extended() for nxCDF files.
| #define NC_NETCDF4_MODEL 0x04000000 |
Request NetCDF-4-model compatibility from the nxCDF backend
| #define NC_NXCDF NEP_UDF_NXCDF |
Explicit create/open mode for the nxCDF backend
| #define NC_REF_OBJ_ATT 4 |
Resolved object kind reported by nc_ref_resolve() and nc_ref_open_remote() when the stored path carried a #attname suffix: an attribute on the resolved owner. (Distinct from NC_STD_REF_ATTR, which shares its numeric value with NC_REF_OBJ_TYPE.)
| #define NC_REF_OBJ_GRP 2 |
Reference target kind: a NetCDF group (HDF5 group).
| #define NC_REF_OBJ_TYPE 3 |
Reference target kind: a NetCDF user-defined type (HDF5 committed datatype).
| #define NC_REF_OBJ_VAR 1 |
Reference target kind for nc_ref_object(), nc_ref_attr() and the nc_deref_*() functions: a NetCDF variable (HDF5 dataset).
| #define NC_STD_REF 30 |
nxCDF HDF5 standard reference type (H5T_STD_REF). Elements are opaque 64-byte nc_std_ref_t tokens covering object, dataset region, and attribute references; see nc_ref_object() and friends. Native mode only.
| #define NC_STD_REF_ATTR 3 |
Attribute reference token kind, reported by nc_ref_get_type().
| #define NC_STD_REF_OBJECT 1 |
Object reference token kind, reported by nc_ref_get_type().
| #define NC_STD_REF_REGION 2 |
Dataset region reference token kind, reported by nc_ref_get_type().
| #define NC_STD_REF_SIZE 64 |
Bytes in one opaque nxCDF reference token. Matches HDF5 H5R_REF_BUF_SIZE (the size of H5R_ref_t).
| #define NC_SWMR_READ 0x10000000 |
Request a native serial nxCDF SWMR reader session at open.
Read-only flag combined with NC_NXCDF in the mode of nc_open(). The file is opened with HDF5 SWMR read access so it can coexist with a live writer and observe records the writer publishes. Any file the HDF5 layer accepts for SWMR reading may be opened: a live writer's file, a quiescent file after the writer closed, or a file never written in SWMR mode — provided its superblock is v3, which includes NC_NETCDF4_MODEL files. After opening, the reader polls nc_swmr_refresh() and reads with the ordinary inquiry/data calls; multiple independent readers are supported. Rejected at nc_create, and at open when combined with NC_WRITE, NC_SWMR_WRITE, NC_CLASSIC_MODEL or MPI parameters. This is a NEP-only flag, not an upstream NetCDF mode. See nc_swmr_refresh().
| #define NC_SWMR_WRITE 0x08000000 |
Request a native serial nxCDF SWMR writer session at create/open.
SWMR (Single Writer / Multiple Reader) lets one process write a file while other processes read it concurrently. Passing this flag in the cmode of nc_create() or the mode of nc_open(NC_WRITE) asks the backend to start HDF5 SWMR writing automatically: creates defer activation until enddef commits the schema, writable opens activate after metadata load. Equivalent to calling nc_start_swmr_write() after an ordinary open. Requires a native nxCDF file on a superblock-v3, SWMR-capable driver; rejected on MPI sessions and compatibility modes. Once active, the schema and attributes are frozen and the writer publishes data with nc_swmr_flush() or nc_sync(). This is a NEP-only flag, not an upstream NetCDF mode.
| typedef struct nc_std_ref_s nc_std_ref_t |
One opaque nxCDF reference token; layout-compatible with HDF5 H5R_ref_t so tokens move to and from the HDF5 reference API without conversion. Never interpret the bytes.
| int nc_deref_attr | ( | int | ncid, |
| const nc_std_ref_t * | ref, | ||
| int * | obj_typep, | ||
| int * | grpidp, | ||
| int * | idp, | ||
| char * | att_name ) |
Resolve an attribute reference token back to its owner and attribute name.
Resolve an attribute reference token back to its owner and attribute name.
Reports the owner kind and ids as nc_deref_object() does, plus the attribute name. For an external token, ncid is the target session returned by nc_ref_open_target().
| ncid | NetCDF file ID (nxCDF); for an external token, the session returned by nc_ref_open_target(). |
| ref | Reference token. |
| obj_typep | Receives NC_REF_OBJ_VAR, NC_REF_OBJ_GRP, or NC_REF_OBJ_TYPE for the attribute-bearing object; may be NULL. |
| grpidp | Containing group's ncid (or the group itself for NC_REF_OBJ_GRP); may be NULL. |
| idp | The varid, group ncid, or typeid of the owner; may be NULL. For NC_REF_OBJ_TYPE owners the attribute value is read through the HDF5 API (H5Aopen/H5Aread), not the NetCDF API. |
| att_name | Receives the attribute name; must be a caller buffer of at least NC_MAX_NAME + 1 bytes, or NULL. |
| int nc_deref_object | ( | int | ncid, |
| const nc_std_ref_t * | ref, | ||
| int * | obj_typep, | ||
| int * | grpidp, | ||
| int * | idp ) |
Resolve an object reference token back to NetCDF ids.
Reports the target kind (NC_REF_OBJ_VAR, NC_REF_OBJ_GRP, or NC_REF_OBJ_TYPE), the containing group ncid, and the object id. For an external token, ncid is the target session returned by nc_ref_open_target() and the returned IDs belong to it.
| ncid | NetCDF file ID (nxCDF); for an external token, the session returned by nc_ref_open_target(). |
| ref | Reference token. |
| obj_typep | Receives NC_REF_OBJ_VAR, NC_REF_OBJ_GRP, or NC_REF_OBJ_TYPE; may be NULL. |
| grpidp | For a variable or type, the containing group's ncid; for a group, the group ncid itself. May be NULL. |
| idp | For a variable the varid, a group the group ncid, or a type the typeid. May be NULL. |
| int nc_deref_region | ( | int | ncid, |
| const nc_std_ref_t * | ref, | ||
| int * | grpidp, | ||
| int * | varidp, | ||
| int * | ndimsp, | ||
| size_t * | startp, | ||
| size_t * | countp, | ||
| ptrdiff_t * | stridep ) |
Resolve a dataset region reference token back to its variable and selection.
Recovers the target variable and the stored start/count/stride arrays. For an external token, ncid is the target session returned by nc_ref_open_target().
| ncid | NetCDF file ID (nxCDF); for an external token, the session returned by nc_ref_open_target(). |
| ref | Reference token. |
| grpidp | Containing group's ncid; may be NULL. |
| varidp | Variable ID; may be NULL. |
| ndimsp | Variable rank; may be NULL. |
| startp | Receives the selection start (rank elements); may be NULL. |
| countp | Receives the selection count (rank elements); may be NULL. |
| stridep | Receives the selection stride (rank elements); may be NULL. |
|
extern |
Finalize process-wide nxCDF dispatch state.
nxCDF currently keeps no state that needs teardown, so this is a placeholder for symmetry with NC_NXCDF_initialize() and the other NEP backends.
|
extern |
Register the nxCDF dispatch table in UDF slot 9.
Applications call this once before using NC_NXCDF (unless the backend is autoloaded via .ncrc). Also reads NEP_LOG_LEVEL.
Register the nxCDF dispatch table in UDF slot 9.
Installs NXCDF_dispatcher into UDF slot 9 by calling netcdf-c's nc_def_user_format(). Applications must call this once before using NC_NXCDF (unless the backend is autoloaded via .ncrc). Also reads the NEP_LOG_LEVEL environment variable to set the initial log level when logging is compiled in.
| int nc_ref_attr | ( | int | ncid, |
| int | obj_type, | ||
| int | objid, | ||
| const char * | att_name, | ||
| nc_std_ref_t * | ref ) |
Create an HDF5 attribute reference to an attribute on a variable, group, or committed datatype in a nxCDF file.
obj_type/objid are dispatched exactly as in nc_ref_object(), so every attribute-bearing object kind is covered.
| ncid | NetCDF file ID (nxCDF, native mode). |
| obj_type | NC_REF_OBJ_VAR, NC_REF_OBJ_GRP, or NC_REF_OBJ_TYPE, dispatched exactly as in nc_ref_object(). NC_REF_OBJ_GRP covers the attributes the NetCDF API attaches to NC_GLOBAL. |
| objid | Object identifier, interpreted per obj_type. |
| att_name | Name of an existing attribute on the object. |
| ref | Receives the opaque reference token. |
obj_type, target, or missing attribute; NC_EHDFERR on HDF5 failure.| int nc_ref_attr_ext | ( | int | ncid, |
| const char * | filename, | ||
| const char * | path, | ||
| const char * | att_name, | ||
| nc_std_ref_t * | ref ) |
Create an attribute reference pointing into another file.
Like nc_ref_attr(), but the target is the attribute att_name on the object named by path in filename. path may name any attribute-bearing object kind. filename must be an absolute filesystem path and the target file must be writable by the application, as for nc_ref_object_ext().
The attribute is named on the object at path in filename.
| ncid | NetCDF file ID (nxCDF, native mode). |
| filename | Absolute filesystem path of the HDF5 file holding the target object; the target must be writable by the application. |
| path | HDF5 path of the target object in filename; may name any attribute-bearing object kind. |
| att_name | Name of an attribute on the target object. |
| ref | Receives the opaque reference token. |
filename; NC_EHDFERR on HDF5 failure.| int nc_ref_free | ( | nc_std_ref_t * | ref | ) |
Release the resources held by a reference token.
An HDF5 reference token holds a reference to the file it was created in; until it is released the file cannot fully close. Call this on every token obtained from nc_ref_object(), nc_ref_region(), nc_ref_attr(), or the nc_ref_*_ext() variants when the token is no longer needed. Tokens read from a dataset or attribute may also be passed here. Releasing an uninitialized or already-released token is safe.
Wraps H5Rdestroy(); safe on uninitialized tokens. A token holds a reference to the file it was created in — until it is released the file cannot fully close. Call this on every token obtained from nc_ref_object(), nc_ref_region(), nc_ref_attr(), or the nc_ref_*_ext() variants, and on tokens read back from a dataset or attribute, when it is no longer needed.
| ref | Reference token. |
| int nc_ref_get_file_name | ( | const nc_std_ref_t * | ref, |
| char * | name, | ||
| size_t | size ) |
Copy the file name stored in a reference token.
Returns the name of the file the token points into, which differs from the containing file only for external references.
Differs from the containing file only for external references.
| ref | Reference token. |
| name | Destination buffer of size bytes. |
| size | Buffer size in bytes, including room for the null terminator. |
size is too small; NC_EHDFERR on HDF5 failure.| int nc_ref_get_obj_name | ( | const nc_std_ref_t * | ref, |
| char * | name, | ||
| size_t | size ) |
Copy the object path stored in a reference token.
For an attribute reference this is the path of the object that carries the attribute; use nc_deref_attr() for the attribute name itself.
For an attribute reference this is the path of the object that carries the attribute; use nc_deref_attr() for the attribute name itself.
| ref | Reference token. |
| name | Destination buffer of size bytes. |
| size | Buffer size in bytes, including room for the null terminator. |
size is too small; NC_EHDFERR on HDF5 failure.| int nc_ref_get_type | ( | const nc_std_ref_t * | ref, |
| int * | ref_typep ) |
Report the kind of a reference token.
Returns NC_STD_REF_OBJECT, NC_STD_REF_REGION, or NC_STD_REF_ATTR.
| ref | Reference token. |
| ref_typep | Receives NC_STD_REF_OBJECT, NC_STD_REF_REGION, or NC_STD_REF_ATTR. |
| int nc_ref_object | ( | int | ncid, |
| int | obj_type, | ||
| int | objid, | ||
| nc_std_ref_t * | ref ) |
Create an HDF5 object reference to a variable, group, or user-defined type in a nxCDF file.
The object is identified by an NC_REF_OBJ_* kind and an id interpreted per kind; the token is written to ref.
| ncid | NetCDF file ID (nxCDF, native mode). |
| obj_type | NC_REF_OBJ_VAR: objid is a varid in group ncid. NC_REF_OBJ_GRP: objid is a group ncid (ncid is ignored). NC_REF_OBJ_TYPE: objid is a typeid in group ncid. |
| objid | Object identifier, interpreted per obj_type. |
| ref | Receives the opaque reference token. |
obj_type or target; NC_EHDFERR on HDF5 failure.| int nc_ref_object_ext | ( | int | ncid, |
| const char * | filename, | ||
| const char * | path, | ||
| nc_std_ref_t * | ref ) |
Create an object reference pointing into another file.
The token encodes filename; storing it in an NC_STD_REF variable or attribute of the file ncid produces a cross-file reference. ncid is validated like nc_ref_object() but is otherwise unused.
filename must be an absolute filesystem path: a stored relative name would be reinterpreted against whatever working directory a later reader happens to have. The target file must also be writable by the application — HDF5 may reopen persisted external references read-write, so a read-only target can be referenced but never dereferenced.
The token records filename so H5Ropen_* and the nc_ref_get_* inspectors can resolve the external target.
| ncid | NetCDF file ID (nxCDF, native mode); validated but otherwise unused. |
| filename | Absolute filesystem path of the HDF5 file holding the target object; relative names are rejected because a stored relative path would be reinterpreted against the reader's working directory. The target must be writable by the application. |
| path | HDF5 path of the target object in filename (for example "grp/dset" or "/grp/dset"). |
| ref | Receives the opaque reference token. |
filename; NC_EHDFERR on HDF5 failure.| int nc_ref_open_remote | ( | int | ncid, |
| const char * | url, | ||
| const char * | path, | ||
| int * | target_ncidp, | ||
| int * | kindp, | ||
| int * | objidp, | ||
| char * | att_name, | ||
| size_t | att_name_size ) |
Open a remote reference target and resolve its object path.
Remote references are a stored convention, not an HDF5 token: the application keeps a URL and an object path as strings (for example in parallel NC_STRING variables or attributes), and this function resolves one pair. The URL is opened with nc_open(url, NC_NOWRITE, ...) — no NC_NXCDF flag — so any remote-capable dispatch in the installed NetCDF-C may answer: DAP2, DAP4, or NCZarr file/byte-range stores. (s3:// URLs additionally require NetCDF-C built with NC_HAS_S3.) The returned session is an ordinary upstream NetCDF file ID, not a nxCDF session.
path follows the nc_ref_resolve() grammar: a leading /, /-separated group components, a final component naming a variable, group, or committed datatype, and an optional #attname suffix selecting an attribute of that object.
On success the caller owns target_ncidp and must close it with nc_close(); each call returns an independent session. The IDs reported through kindp/ to that session and die with it. If the open succeeds but objidp belongpath fails to resolve, the session is closed, target_ncidp is set to -1 and the resolution error is returned. Remote access is read-only.
Requires NEP built with NEP_ENABLE_REMOTE_REFS (see NEP_HAS_REMOTE_REFS in nep_meta.h).
| ncid | NetCDF file ID (nxCDF) of the file holding the reference; provides context only. |
| url | URL the installed NetCDF-C can open remotely. |
| path | Object path inside the remote dataset (see nc_ref_resolve()). |
| target_ncidp | Receives the remote session's NetCDF file ID; set to -1 on failure. |
| kindp | Receives NC_REF_OBJ_VAR, NC_REF_OBJ_GRP, NC_REF_OBJ_TYPE, or NC_REF_OBJ_ATT when path carried a #attname suffix. |
| objidp | Receives the resolved ID: a varid, group ncid, typeid, or — for NC_REF_OBJ_ATT — the attribute owner's varid, group ncid or typeid. |
| att_name | Buffer receiving the attribute name when path carried a #attname suffix; may be NULL otherwise. |
| att_name_size | Size of att_name in bytes. |
ncid; NC_EINVAL for bad arguments or malformed path; otherwise the nc_open/inquiry error for an unreachable URL or missing object.Implementation of the public contract declared in nep.h: the containing file is validated as nxCDF (context only), the URL is opened with plain nc_open(NC_NOWRITE) so any remote-capable upstream dispatch answers, and the path is resolved with nc_ref_resolve(). A failed resolution closes the fresh session.
| int nc_ref_open_target | ( | int | ncid, |
| const nc_std_ref_t * | ref, | ||
| int * | target_ncidp ) |
Open the external file a reference token points into.
The token records an absolute filename for its target file; this function opens that file as a new nxCDF session and returns its NetCDF file ID. Pass the returned ncid to nc_deref_object(), nc_deref_region(), or nc_deref_attr() to resolve the token; the IDs those calls return belong to the target session and remain valid until it is closed.
The caller owns the returned session: close it with nc_close(). Each call returns an independent session, even for tokens into the same file. Token lifetime is independent — release ref with nc_ref_free() when done; freeing the token does not close the target session, and closing the target session does not affect the token.
The target file must be writable by the application: HDF5 may reopen persisted external references read-write, so the session is opened with NC_WRITE even when only reads are intended. Dereferencing never intentionally modifies target contents.
Extracts the stored absolute filename and opens it through nc_open() with NC_NXCDF|NC_WRITE. The returned ncid is a normal caller-owned session: pass it to nc_deref_* to resolve the token, and close it with nc_close(). Each call returns an independent session. The IDs the nc_deref_* calls return belong to that target session and remain valid until it is closed; token lifetime (nc_ref_free) is independent of target-session lifetime. The target must be writable: HDF5 may reopen persisted external references read-write, so the session is opened with NC_WRITE even when only reads are intended.
| ncid | NetCDF file ID (nxCDF) of the file the token was created in or read from. |
| ref | Reference token pointing into another file. |
| target_ncidp | Receives the NetCDF file ID of the opened target file; set to -1 on failure. |
| int nc_ref_region | ( | int | ncid, |
| int | varid, | ||
| const size_t * | startp, | ||
| const size_t * | countp, | ||
| const ptrdiff_t * | stridep, | ||
| nc_std_ref_t * | ref ) |
Create a dataset region reference to a strided hyperslab of a variable in a nxCDF file.
Only regular strided hyperslabs (start/count/stride) are supported; irregular selections are rejected.
| ncid | NetCDF file ID (nxCDF, native mode). |
| varid | Variable ID. |
| startp | Start index in each dimension (rank elements). |
| countp | Edge count in each dimension (rank elements). |
| stridep | Stride in each dimension, or NULL for unit stride. |
| ref | Receives the opaque reference token. |
| int nc_ref_region_ext | ( | int | ncid, |
| const char * | filename, | ||
| const char * | path, | ||
| const size_t * | startp, | ||
| const size_t * | countp, | ||
| const ptrdiff_t * | stridep, | ||
| nc_std_ref_t * | ref ) |
Create a dataset region reference pointing into another file.
Like nc_ref_region(), but the target is the variable named by path in filename. filename must be an absolute filesystem path and the target file must be writable by the application, as for nc_ref_object_ext().
The selection uses start/count/stride like nc_ref_region().
| ncid | NetCDF file ID (nxCDF, native mode). |
| filename | Absolute filesystem path of the HDF5 file holding the target dataset; the target must be writable by the application. |
| path | HDF5 path of the target dataset in filename. |
| startp | Start index in each dimension. |
| countp | Edge count in each dimension. |
| stridep | Stride in each dimension, or NULL for unit stride. |
| ref | Receives the opaque reference token. |
filename; NC_EHDFERR on HDF5 failure.| int nc_ref_resolve | ( | int | ncid, |
| const char * | path, | ||
| int * | kindp, | ||
| int * | objidp, | ||
| char * | att_name, | ||
| size_t | att_name_size ) |
Resolve an object path on an already-open remote session.
Maps a stored object path to NetCDF IDs on ncid, which is typically a session returned by nc_ref_open_remote() but may be any open NetCDF file ID. Use it to resolve several stored paths against one remote session without paying a remote open per reference.
path grammar: a leading /, /-separated group components, and a final component naming a variable, group or committed datatype. An optional #attname suffix selects an attribute of the named object. / alone resolves to the root group. Resolution precedence for the final component is variable, then group, then committed type.
When path carries no # suffix, kindp receives NC_REF_OBJ_VAR, NC_REF_OBJ_GRP or NC_REF_OBJ_TYPE and objidp the varid, group ncid or typeid. With a #attname suffix, kindp receives NC_REF_OBJ_ATT, att_name the attribute name and objidp the owner's varid, group ncid or typeid. Attribute existence is verified with nc_inq_attid() for variable and group owners; attributes on committed-datatype owners are not verifiable through the NetCDF API and the name is returned unchecked.
| ncid | Open NetCDF file ID to resolve against. |
| path | Object path (see above). |
| kindp | Receives the resolved kind (see above). |
| objidp | Receives the resolved ID (see above). |
| att_name | Buffer receiving the attribute name, or NULL when path carries no # suffix. |
| att_name_size | Size of att_name in bytes. |
path; NC_ENOTVAR when the final component names no variable, group or type; NC_ENOTATT for a missing attribute; other inquiry errors propagate.Implementation of the public contract declared in nep.h: split the optional #attname suffix, walk the group components with nc_inq_grp_ncid(), and resolve the leaf as variable, group or committed type in that order.
| int nc_start_swmr_write | ( | int | ncid | ) |
Start a single-writer/multiple-reader session on a native nxCDF file.
SWMR (Single Writer / Multiple Reader) is an HDF5 concurrency mode: one process holds a file open for writing while any number of other processes hold the same file open read-only and watch the data grow, without file locks or re-opening. The writer calls nc_swmr_flush() (or nc_sync()) to publish what it has written; each reader calls nc_swmr_refresh() to make the newly published records visible. NEP exposes this through libncnxcdf on nxCDF (HDF5) files only. This function is the writer-side entry point; readers never call it — they open with NC_SWMR_READ instead.
Link libncnxcdf and enable NEP_HAS_NXCDF. A file or subgroup ncid addresses the whole file. Pending definitions are committed before HDF5 SWMR activation; calling again on an active writer is a no-op. Only serial native files with superblock v3 and a SWMR-capable driver are supported. Variables must have fixed-size atomic types (including NEP small floats, complex and bitfield types), not NC_STRING, NC_STD_REF or user types. Declared user types, even unused ones, are excluded. All schema and attributes freeze at activation; in-bounds writes and unlimited growth remain allowed. This is session state, not a persistent mode marker.
Alternatively request NC_SWMR_WRITE at create/open: creates defer start until enddef (including automatic enddef on write); writable opens start after metadata loading. Closing an inactive requested file never starts SWMR. Failed activation may leave ordinary definitions committed; it does not roll them back and leaves the session inactive and closable.
| ncid | Open file or group identifier. |
Start a single-writer/multiple-reader session on a native nxCDF file.
| int nc_swmr_flush | ( | int | ncid | ) |
Publish all datasets and dimension scales of an active SWMR writer.
This is the writer's half of the SWMR handshake. In a SWMR session data written by the writer is not automatically visible to readers: it sits in the writer's HDF5 caches until the writer publishes it. nc_swmr_flush() flushes every variable dataset and every dimension-scale dataset, then flushes the file, which is what makes the appended records readable by SWMR readers after their next nc_swmr_refresh(). nc_sync() on an active writer performs the same publication, so applications may use either call as their publish boundary.
Link libncnxcdf. Publication is reader visibility, not an atomic multi-variable timestep, rollback or power-loss durability guarantee. HDF5 may also flush opportunistically before this call. Readers must open with NC_SWMR_READ and call nc_swmr_refresh() to observe published data. Does not enter define mode or activate an inactive session.
| ncid | Open file or group identifier; the entire file is flushed. |
Publish all datasets and dimension scales of an active SWMR writer.
| int nc_swmr_refresh | ( | int | ncid | ) |
Refresh a nxCDF SWMR reader session so newly published data becomes visible.
This is the reader's half of the SWMR handshake. A SWMR reader holds the file open with HDF5 SWMR read access; its datasets and dimension extents are snapshots that do not change on their own. After the writer publishes new records with nc_swmr_flush() or nc_sync(), the reader calls nc_swmr_refresh() once and then reads the new data with the ordinary nc_inq_dimlen()/nc_get_vara() calls. A typical reader loop is: wait for the application's own publish signal, call nc_swmr_refresh(), call nc_inq_dimlen() for the current record count, then read the new records. Any number of readers may do this independently, and readers may open before or after the writer starts SWMR writing and may close in either order.
Link libncnxcdf. Requires a file opened read-only with NC_NXCDF|NC_SWMR_READ; a file or subgroup ncid addresses the whole file. Every open variable dataset and dimension-scale dataset is refreshed through H5Drefresh, then the cached length of each dimension is reloaded from its scale dataset's current extent. Calling when nothing new was published is a cheap no-op, so it is safe to call on every iteration of a polling loop.
Refresh is not a re-open: the SWMR writer contract freezes the schema and attributes at activation, so variables, dimensions, attributes or types added afterwards are never expected and are not discovered — reopen the file to see such changes. Reads mid-append are well defined at the dataset level, but whether a multi-variable logical record is complete is an application concern; a common protocol is for the writer to update a scalar marker variable last, after the record data, and for readers to check the marker after refreshing. Calling this on an ordinary read-only, writable or writer session returns NC_EINVAL.
| ncid | Open file or group identifier of a SWMR reader session. |
Refresh a nxCDF SWMR reader session so newly published data becomes visible.