NEP 4.0.0
NetCDF Expansion Pack
Loading...
Searching...
No Matches
Data Structures | Functions | Variables
nxt4meta.c File Reference

NEXTCDF-4 Sprint 3 metadata model: dimensions, variables, attributes, type mapping, and on-disk discovery. More...

#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <hdf5_hl.h>
#include "nclist.h"
#include "nxt4internal.h"

Data Structures

struct  dim_list_t
 
struct  var_list_t
 
struct  resolve_scale_t
 
struct  att_iter_data_t
 
struct  load_children_data_t
 

Functions

static int is_reserved_att (const char *name)
 
static void free_name_list (char **names, size_t n)
 
int NEXTCDF4_check_write_define (NEXTCDF4_FILE_INFO_T *file)
 
int NEXTCDF4_map_hdf_type (nc_type xtype, hid_t *typep)
 
int NEXTCDF4_type_size (nc_type xtype, size_t *sizep)
 
const char * NEXTCDF4_type_name (nc_type xtype)
 
int NEXTCDF4_check_atomic_type (NEXTCDF4_FILE_INFO_T *file, nc_type xtype)
 
static hid_t native_hdf_type (nc_type xtype)
 
static int set_var_type (NC_VAR_INFO_T *var, nc_type xtype)
 
static int write_string_att (hid_t loc, const char *name, const char *value)
 
static int write_int_att (hid_t loc, const char *name, int value)
 
static int write_int_array_att (hid_t loc, const char *name, const int *values, size_t len)
 
static int map_nc_type (hid_t htype, nc_type *xtypep)
 
static int get_att_context (NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, NCindex **listp, hid_t *locp)
 
static NC_ATT_INFO_T * find_att (NCindex *list, const char *name)
 
static int add_att (NCindex *list, NC_OBJ *container, const char *name, nc_type xtype, size_t len, const void *data, NC_ATT_INFO_T **attp)
 
static int read_hdf5_att (hid_t loc, const char *name, NCindex *list, NC_OBJ *container)
 
int NEXTCDF4_def_dim (int ncid, const char *name, size_t len, int *idp)
 
int NEXTCDF4_inq_dim (int ncid, int dimid, char *name, size_t *lenp)
 
int NEXTCDF4_def_var (int ncid, const char *name, nc_type xtype, int ndims, const int *dimidsp, int *varidp)
 
static int create_var_dataset (NC_VAR_INFO_T *var, NC_FILE_INFO_T *h5, NEXTCDF4_FILE_INFO_T *file, NC_GRP_INFO_T *grp)
 
static int find_var_for_write (int ncid, int varid, NC_FILE_INFO_T **h5, NEXTCDF4_FILE_INFO_T **file, NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var)
 
int NEXTCDF4_def_var_chunking (int ncid, int varid, int storage, const size_t *chunksizesp)
 
int NEXTCDF4_def_var_deflate (int ncid, int varid, int shuffle, int deflate, int deflate_level)
 
int NEXTCDF4_def_var_fletcher32 (int ncid, int varid, int fletcher32)
 
int NEXTCDF4_def_var_fill (int ncid, int varid, int no_fill, const void *fill_value)
 
int NEXTCDF4_def_var_endian (int ncid, int varid, int endianness)
 
int NEXTCDF4_def_var_quantize (int ncid, int varid, int quantize_mode, int nsd)
 
int NEXTCDF4_def_var_filter (int ncid, int varid, unsigned int id, size_t nparams, const unsigned int *params)
 
int NEXTCDF4_inq_var_all (int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp, int *shufflep, int *deflatep, int *deflate_levelp, int *fletcher32p, int *contiguousp, size_t *chunksizesp, int *no_fillp, void *fill_valuep, int *endiannessp, unsigned int *idp, size_t *nparamsp, unsigned int *params)
 
int NEXTCDF4_inq_var (int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp)
 
int NEXTCDF4_inq_var_filter_ids (int ncid, int varid, size_t *nfiltersp, unsigned int *ids)
 
int NEXTCDF4_inq_var_filter_info (int ncid, int varid, unsigned int id, size_t *nparamsp, unsigned int *params)
 
int NEXTCDF4_put_att (int ncid, int varid, const char *name, nc_type datatype, size_t len, const void *value, nc_type memtype)
 
int NEXTCDF4_get_att (int ncid, int varid, const char *name, void *value, nc_type memtype)
 
int NEXTCDF4_rename_att (int ncid, int varid, const char *name, const char *newname)
 
static NC_VAR_INFO_T * find_coord_var (NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim)
 
static NC_DIM_INFO_T * coord_var_dim (NC_VAR_INFO_T *var)
 
int NEXTCDF4_rename_dim (int ncid, int dimid, const char *name)
 
int NEXTCDF4_rename_var (int ncid, int varid, const char *name)
 
int NEXTCDF4_del_att (int ncid, int varid, const char *name)
 
static herr_t find_dim_cb (hid_t loc, const char *name, const H5L_info_t *info, void *op_data)
 
static int load_one_dim (NEXTCDF4_FILE_INFO_T *file, NC_GRP_INFO_T *grp, const char *name, int dimid)
 
static int load_dimensions (NEXTCDF4_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp)
 
static herr_t find_var_cb (hid_t loc, const char *name, const H5L_info_t *info, void *op_data)
 
static NC_DIM_INFO_T * find_dim_by_name (NC_GRP_INFO_T *grp, const char *name)
 
static int scale_resolve_visitor (hid_t did, unsigned int dim, hid_t dsid, void *op_data)
 
static int resolve_var_dimids (NC_GRP_INFO_T *grp, hid_t dset, int ndims, int *dimids)
 
static int load_one_var (NEXTCDF4_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp, const char *name, int varid)
 
static herr_t load_att_cb (hid_t loc, const char *attr_name, const H5A_info_t *ainfo, void *op_data)
 
static int load_variables (NEXTCDF4_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp)
 
static int load_group_attributes (NEXTCDF4_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp)
 
static int load_children (NEXTCDF4_FILE_INFO_T *file, NC_FILE_INFO_T *h5, hid_t parent_hdf, NC_GRP_INFO_T *parent)
 
static int load_one_type (NC_GRP_INFO_T *grp, hid_t htype, const char *name)
 
static int load_group_metadata (NEXTCDF4_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp, hid_t hdf_grp)
 
static int load_one_group (NEXTCDF4_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *parent, hid_t parent_hdf, const char *name)
 
static herr_t load_children_cb (hid_t loc, const char *name, const H5L_info_t *info, void *op_data)
 
int NEXTCDF4_load_metadata (NEXTCDF4_FILE_INFO_T *file, NC_FILE_INFO_T *h5)
 

Variables

static const char * reserved_atts []
 

Detailed Description

NEXTCDF-4 Sprint 3 metadata model: dimensions, variables, attributes, type mapping, and on-disk discovery.

Author
Edward Hartnett
Date
2026-08-28

Function Documentation

◆ add_att()

static int add_att ( NCindex *  list,
NC_OBJ *  container,
const char *  name,
nc_type  xtype,
size_t  len,
const void *  data,
NC_ATT_INFO_T **  attp 
)
static

◆ coord_var_dim()

static NC_DIM_INFO_T * coord_var_dim ( NC_VAR_INFO_T *  var)
static

◆ create_var_dataset()

static int create_var_dataset ( NC_VAR_INFO_T *  var,
NC_FILE_INFO_T *  h5,
NEXTCDF4_FILE_INFO_T file,
NC_GRP_INFO_T *  grp 
)
static

◆ find_att()

static NC_ATT_INFO_T * find_att ( NCindex *  list,
const char *  name 
)
static

◆ find_coord_var()

static NC_VAR_INFO_T * find_coord_var ( NC_GRP_INFO_T *  grp,
NC_DIM_INFO_T *  dim 
)
static

◆ find_dim_by_name()

static NC_DIM_INFO_T * find_dim_by_name ( NC_GRP_INFO_T *  grp,
const char *  name 
)
static

◆ find_dim_cb()

static herr_t find_dim_cb ( hid_t  loc,
const char *  name,
const H5L_info_t *  info,
void *  op_data 
)
static

◆ find_var_cb()

static herr_t find_var_cb ( hid_t  loc,
const char *  name,
const H5L_info_t *  info,
void *  op_data 
)
static

◆ find_var_for_write()

static int find_var_for_write ( int  ncid,
int  varid,
NC_FILE_INFO_T **  h5,
NEXTCDF4_FILE_INFO_T **  file,
NC_GRP_INFO_T **  grp,
NC_VAR_INFO_T **  var 
)
static

◆ free_name_list()

static void free_name_list ( char **  names,
size_t  n 
)
static

◆ get_att_context()

static int get_att_context ( NC_GRP_INFO_T *  grp,
NC_VAR_INFO_T *  var,
NCindex **  listp,
hid_t *  locp 
)
static

◆ is_reserved_att()

static int is_reserved_att ( const char *  name)
static

◆ load_att_cb()

static herr_t load_att_cb ( hid_t  loc,
const char *  attr_name,
const H5A_info_t *  ainfo,
void *  op_data 
)
static

◆ load_children()

static int load_children ( NEXTCDF4_FILE_INFO_T file,
NC_FILE_INFO_T *  h5,
hid_t  parent_hdf,
NC_GRP_INFO_T *  parent 
)
static

◆ load_children_cb()

static herr_t load_children_cb ( hid_t  loc,
const char *  name,
const H5L_info_t *  info,
void *  op_data 
)
static

◆ load_dimensions()

static int load_dimensions ( NEXTCDF4_FILE_INFO_T file,
NC_FILE_INFO_T *  h5,
NC_GRP_INFO_T *  grp 
)
static

◆ load_group_attributes()

static int load_group_attributes ( NEXTCDF4_FILE_INFO_T file,
NC_FILE_INFO_T *  h5,
NC_GRP_INFO_T *  grp 
)
static

◆ load_group_metadata()

static int load_group_metadata ( NEXTCDF4_FILE_INFO_T file,
NC_FILE_INFO_T *  h5,
NC_GRP_INFO_T *  grp,
hid_t  hdf_grp 
)
static

◆ load_one_dim()

static int load_one_dim ( NEXTCDF4_FILE_INFO_T file,
NC_GRP_INFO_T *  grp,
const char *  name,
int  dimid 
)
static

◆ load_one_group()

static int load_one_group ( NEXTCDF4_FILE_INFO_T file,
NC_FILE_INFO_T *  h5,
NC_GRP_INFO_T *  parent,
hid_t  parent_hdf,
const char *  name 
)
static

◆ load_one_type()

static int load_one_type ( NC_GRP_INFO_T *  grp,
hid_t  htype,
const char *  name 
)
static

◆ load_one_var()

static int load_one_var ( NEXTCDF4_FILE_INFO_T file,
NC_FILE_INFO_T *  h5,
NC_GRP_INFO_T *  grp,
const char *  name,
int  varid 
)
static

◆ load_variables()

static int load_variables ( NEXTCDF4_FILE_INFO_T file,
NC_FILE_INFO_T *  h5,
NC_GRP_INFO_T *  grp 
)
static

◆ map_nc_type()

static int map_nc_type ( hid_t  htype,
nc_type *  xtypep 
)
static

◆ native_hdf_type()

static hid_t native_hdf_type ( nc_type  xtype)
static

◆ NEXTCDF4_check_atomic_type()

int NEXTCDF4_check_atomic_type ( NEXTCDF4_FILE_INFO_T file,
nc_type  xtype 
)

Validate a fixed-size atomic type for the active model.

Parameters
fileNEXTCDF-4 file state.
xtypeCandidate NetCDF type.
Returns
NC_NOERR or NC_EBADTYPE/NC_ENOTNC4.

◆ NEXTCDF4_check_write_define()

int NEXTCDF4_check_write_define ( NEXTCDF4_FILE_INFO_T file)

Verify the file is in define mode and not read-only.

Parameters
fileNEXTCDF-4 file state.
Returns
NC_NOERR or an appropriate NetCDF error code.

◆ NEXTCDF4_def_dim()

int NEXTCDF4_def_dim ( int  ncid,
const char *  name,
size_t  len,
int *  idp 
)

Define a dimension in the root group.

Parameters
ncidNetCDF file identifier.
nameDimension name.
lenDimension length, or 0 for unlimited.
idpDestination for the assigned dimension id.
Returns
NC_NOERR on success, or a NetCDF error code.

◆ NEXTCDF4_def_var()

int NEXTCDF4_def_var ( int  ncid,
const char *  name,
nc_type  xtype,
int  ndims,
const int *  dimidsp,
int *  varidp 
)

Define a fixed-size atomic variable in the root group.

Parameters
ncidNetCDF file identifier.
nameVariable name.
xtypeNetCDF atomic type.
ndimsNumber of dimensions.
dimidspArray of dimension ids.
varidpDestination for the assigned variable id.
Returns
NC_NOERR on success, or a NetCDF error code.

◆ NEXTCDF4_def_var_chunking()

int NEXTCDF4_def_var_chunking ( int  ncid,
int  varid,
int  storage,
const size_t *  chunksizesp 
)

Variable storage-property dispatch callbacks.

◆ NEXTCDF4_def_var_deflate()

int NEXTCDF4_def_var_deflate ( int  ncid,
int  varid,
int  shuffle,
int  deflate,
int  deflate_level 
)

◆ NEXTCDF4_def_var_endian()

int NEXTCDF4_def_var_endian ( int  ncid,
int  varid,
int  endianness 
)

◆ NEXTCDF4_def_var_fill()

int NEXTCDF4_def_var_fill ( int  ncid,
int  varid,
int  no_fill,
const void *  fill_value 
)

◆ NEXTCDF4_def_var_filter()

int NEXTCDF4_def_var_filter ( int  ncid,
int  varid,
unsigned int  id,
size_t  nparams,
const unsigned int *  params 
)

◆ NEXTCDF4_def_var_fletcher32()

int NEXTCDF4_def_var_fletcher32 ( int  ncid,
int  varid,
int  fletcher32 
)

◆ NEXTCDF4_def_var_quantize()

int NEXTCDF4_def_var_quantize ( int  ncid,
int  varid,
int  quantize_mode,
int  nsd 
)

◆ NEXTCDF4_del_att()

int NEXTCDF4_del_att ( int  ncid,
int  varid,
const char *  name 
)

Delete an attribute.

Parameters
ncidNetCDF file identifier.
varidVariable id or NC_GLOBAL.
nameAttribute name.
Returns
NC_NOERR on success, or a NetCDF error code.

◆ NEXTCDF4_get_att()

int NEXTCDF4_get_att ( int  ncid,
int  varid,
const char *  name,
void *  value,
nc_type  memtype 
)

Get an attribute from the root group or a variable.

Parameters
ncidNetCDF file identifier.
varidVariable id or NC_GLOBAL.
nameAttribute name.
valueDestination buffer.
memtypeRequested in-memory type.
Returns
NC_NOERR on success, or a NetCDF error code.

◆ NEXTCDF4_inq_dim()

int NEXTCDF4_inq_dim ( int  ncid,
int  dimid,
char *  name,
size_t *  lenp 
)

Inquire a dimension by id.

Parameters
ncidNetCDF file identifier.
dimidDimension id.
nameDestination for the dimension name.
lenpDestination for the dimension length.
Returns
NC_NOERR on success, or a NetCDF error code.

◆ NEXTCDF4_inq_var()

int NEXTCDF4_inq_var ( int  ncid,
int  varid,
char *  name,
nc_type *  xtypep,
int *  ndimsp,
int *  dimidsp,
int *  nattsp 
)

Inquire a variable by id.

Parameters
ncidNetCDF file identifier.
varidVariable id.
nameDestination for the variable name.
xtypepDestination for the variable type.
ndimspDestination for the rank.
dimidspDestination for the dimension ids.
nattspDestination for the number of attributes.
Returns
NC_NOERR on success, or a NetCDF error code.

◆ NEXTCDF4_inq_var_all()

int NEXTCDF4_inq_var_all ( int  ncid,
int  varid,
char *  name,
nc_type *  xtypep,
int *  ndimsp,
int *  dimidsp,
int *  nattsp,
int *  shufflep,
int *  deflatep,
int *  deflate_levelp,
int *  fletcher32p,
int *  contiguousp,
size_t *  chunksizesp,
int *  no_fillp,
void *  fill_valuep,
int *  endiannessp,
unsigned int *  idp,
size_t *  nparamsp,
unsigned int *  params 
)

◆ NEXTCDF4_inq_var_filter_ids()

int NEXTCDF4_inq_var_filter_ids ( int  ncid,
int  varid,
size_t *  nfiltersp,
unsigned int *  ids 
)

◆ NEXTCDF4_inq_var_filter_info()

int NEXTCDF4_inq_var_filter_info ( int  ncid,
int  varid,
unsigned int  id,
size_t *  nparamsp,
unsigned int *  params 
)

◆ NEXTCDF4_load_metadata()

int NEXTCDF4_load_metadata ( NEXTCDF4_FILE_INFO_T file,
NC_FILE_INFO_T *  h5 
)

Load all root-group metadata from an open HDF5 file.

Parameters
fileOpen NEXTCDF-4 state.
h5Common NetCDF-4 file metadata.
Returns
NC_NOERR on success, or a NetCDF error code.

◆ NEXTCDF4_map_hdf_type()

int NEXTCDF4_map_hdf_type ( nc_type  xtype,
hid_t *  typep 
)

Map a fixed-size NetCDF atomic type to its HDF5 datatype.

Parameters
xtypeNetCDF atomic type.
typepDestination for an HDF5 datatype identifier.
Returns
NC_NOERR or NC_EBADTYPE.

◆ NEXTCDF4_put_att()

int NEXTCDF4_put_att ( int  ncid,
int  varid,
const char *  name,
nc_type  xtype,
size_t  len,
const void *  value,
nc_type  memtype 
)

Put an attribute on the root group or a variable.

Parameters
ncidNetCDF file identifier.
varidVariable id or NC_GLOBAL.
nameAttribute name.
xtypeNetCDF atomic type.
lenNumber of elements.
valueAttribute data.
memtypeIn-memory type for the attribute value.
Returns
NC_NOERR on success, or a NetCDF error code.

◆ NEXTCDF4_rename_att()

int NEXTCDF4_rename_att ( int  ncid,
int  varid,
const char *  name,
const char *  newname 
)

Rename an attribute.

Parameters
ncidNetCDF file identifier.
varidVariable id or NC_GLOBAL.
nameCurrent attribute name.
newnameNew attribute name.
Returns
NC_NOERR on success, or a NetCDF error code.

◆ NEXTCDF4_rename_dim()

int NEXTCDF4_rename_dim ( int  ncid,
int  dimid,
const char *  name 
)

Rename a dimension.

Parameters
ncidNetCDF file identifier.
dimidDimension id.
nameNew dimension name.
Returns
NC_NOERR on success, or a NetCDF error code.

◆ NEXTCDF4_rename_var()

int NEXTCDF4_rename_var ( int  ncid,
int  varid,
const char *  name 
)

Rename a variable.

Parameters
ncidNetCDF file identifier.
varidVariable id.
nameNew variable name.
Returns
NC_NOERR on success, or a NetCDF error code.

◆ NEXTCDF4_type_name()

const char * NEXTCDF4_type_name ( nc_type  xtype)

Return a display name for a fixed-size NetCDF atomic type.

Parameters
xtypeNetCDF atomic type.
Returns
A pointer to a constant string.

◆ NEXTCDF4_type_size()

int NEXTCDF4_type_size ( nc_type  xtype,
size_t *  sizep 
)

Return the in-memory size of a fixed-size NetCDF atomic type.

Parameters
xtypeNetCDF atomic type.
sizepDestination for the size in bytes.
Returns
NC_NOERR or NC_EBADTYPE.

◆ read_hdf5_att()

static int read_hdf5_att ( hid_t  loc,
const char *  name,
NCindex *  list,
NC_OBJ *  container 
)
static

◆ resolve_var_dimids()

static int resolve_var_dimids ( NC_GRP_INFO_T *  grp,
hid_t  dset,
int  ndims,
int *  dimids 
)
static

◆ scale_resolve_visitor()

static int scale_resolve_visitor ( hid_t  did,
unsigned int  dim,
hid_t  dsid,
void *  op_data 
)
static

◆ set_var_type()

static int set_var_type ( NC_VAR_INFO_T *  var,
nc_type  xtype 
)
static

◆ write_int_array_att()

static int write_int_array_att ( hid_t  loc,
const char *  name,
const int *  values,
size_t  len 
)
static

◆ write_int_att()

static int write_int_att ( hid_t  loc,
const char *  name,
int  value 
)
static

◆ write_string_att()

static int write_string_att ( hid_t  loc,
const char *  name,
const char *  value 
)
static

Variable Documentation

◆ reserved_atts

const char* reserved_atts[]
static
Initial value:
= {
"CLASS",
"NAME",
"REFERENCE_LIST",
"DIMENSION_LIST",
"_Netcdf4Coordinates",
"_FillValue",
"_Format",
"_nc3_strict",
"_NCProperties",
"_SuperblockVersion",
"_IsNetcdf4",
"_ARRAY_DIMENSIONS",
"_Codecs",
NULL
}
#define NEXTCDF4_DIMID_ATT
Definition nxt4internal.h:25
#define NEXTCDF4_VARID_ATT
Definition nxt4internal.h:27
#define NEXTCDF4_MODEL_ATT
Definition nxt4internal.h:20
#define NEXTCDF4_BACKEND_ATT
Definition nxt4internal.h:18
#define NEXTCDF4_VARDIMIDS_ATT
Definition nxt4internal.h:29