NEP 4.3.0
NetCDF Expansion Pack
Loading...
Searching...
No Matches
nxcdf_create.c File Reference

Empty-file creation for the nxCDF backend. More...

#include "nxcdf/nxcdf.h"
#include "config.h"
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "nxcdf_internal.h"

Functions

static int valid_create_mode (int mode)
 Reject create-mode flag combinations nxCDF cannot honor.
int NXCDF_create (const char *path, int cmode, size_t initialsz, int basepe, size_t *chunksizehintp, void *parameters, const NC_Dispatch *dispatch, int ncid)
 Create an empty nxCDF file.

Detailed Description

Empty-file creation for the nxCDF backend.

Author
Edward Hartnett
Date
2026-08-28

Function Documentation

◆ NXCDF_create()

int NXCDF_create ( const char * path,
int cmode,
size_t initialsz,
int basepe,
size_t * chunksizehintp,
void * parameters,
const NC_Dispatch * dispatch,
int ncid )

Create an empty nxCDF file.

Dispatch-table entry behind nc_create() with NC_NXCDF: creates the HDF5 file and writes the backend marker attributes.

This is the dispatch-table entry netcdf-c calls when a user calls nc_create() with NC_NXCDF in the mode flags. It validates the mode, requires HDF5 2.1.1 or newer at run time (the build enforces the same minimum), registers the file's in-memory state, and creates the HDF5 file with a superblock bound matching the requested model: H5F_LIBVER_LATEST (superblock v3) for native and classic-model files, H5F_LIBVER_V110 for NC_NETCDF4_MODEL files so upstream netcdf-c linked against HDF5 1.10 can read them.

Only the hidden marker attributes are written here — dimensions, variables and attributes are materialized later by _enddef (see NXCDF__enddef() and nxCDF Architecture).

Parameters
pathFile-system path to create.
cmodeNetCDF create-mode flags.
initialszRequested initial file size; currently ignored.
basepeBase processing element; currently ignored.
chunksizehintpChunk-size hint; currently ignored.
parametersNon-NULL when the user called nc_create_par(): points at an NXCDF_MPI_INFO carrying the MPI communicator and info handle. nc_create_par() also requires NC_NETCDF4 in the mode flags (upstream rejects other creates without PnetCDF), so parallel creates pass NC_NXCDF|NC_NETCDF4.
dispatchDispatch table selected by netcdf-c.
ncidNetCDF file identifier allocated by netcdf-c.
Returns
NC_NOERR on success, NC_EINVAL for bad mode flags, NC_ENOTBUILT when HDF5 is too old, NC_EEXIST for a NC_NOCLOBBER collision, NC_ENOPAR for a parallel request when nxCDF was built without parallel support, NC_EPARINIT when the MPI-IO driver cannot be set, or another NetCDF error code.

◆ valid_create_mode()

int valid_create_mode ( int mode)
static

Reject create-mode flag combinations nxCDF cannot honor.

nxCDF always writes HDF5 files, so the NetCDF-3 format-variant flags NC_64BIT_OFFSET and NC_64BIT_DATA have no meaning here. NC_CLASSIC_MODEL and NC_NETCDF4_MODEL select different data models and different HDF5 superblock bounds, so they are mutually exclusive. See nxCDF Architecture for the mode table.

Parameters
modeNetCDF mode flags.
Returns
NC_NOERR on success, or NC_EINVAL.