|
NEP 4.3.0
NetCDF Expansion Pack
|
nxCDF group creation and inquiry. More...
#include "nxcdf/nxcdf.h"#include "config.h"#include <stdlib.h>#include <string.h>#include "nclist.h"#include "nxcdf_internal.h"Functions | |
| static int | get_grp_hdf (NC_GRP_INFO_T *grp, hid_t *gid) |
| Return the open HDF5 group handle for an in-memory group. | |
| static int | attach_grp_hdf (NC_GRP_INFO_T *grp, hid_t hdf_group) |
| Attach an HDF5 group handle to a freshly-added group. | |
| static int | find_grp_by_id (NC_GRP_INFO_T *root, int grpid, NC_GRP_INFO_T **grpp) |
| Recursively find a group in the tree by its in-file group id. | |
| static int | get_grp_from_ncid (int ncid, NC_FILE_INFO_T **h5, NC_GRP_INFO_T **grpp) |
| Resolve the NC_GRP_INFO_T an ncid refers to. | |
| int | NXCDF_def_grp (int ncid, const char *name, int *grpidp) |
| Create a subgroup — the nc_def_grp() dispatch entry. | |
| static int | find_child_grp (NC_GRP_INFO_T *parent, const char *name, NC_GRP_INFO_T **grpp) |
| Locate a direct child group by name. | |
| int | NXCDF_inq_ncid (int ncid, const char *name, int *grpidp) |
| Get the ncid of a named subgroup — the nc_inq_ncid() dispatch entry. | |
| int | NXCDF_inq_grps (int ncid, int *numgrps, int *grpidsp) |
| Get the ncids of all subgroups — the nc_inq_grps() dispatch entry. | |
| int | NXCDF_inq_grpname (int ncid, char *name) |
| Get a group's (short) name — the nc_inq_grpname() dispatch entry. | |
| int | NXCDF_inq_grpname_full (int ncid, size_t *lenp, char *name) |
| Get a group's full path name — the nc_inq_grpname_full() dispatch entry. | |
| int | NXCDF_inq_grp_parent (int ncid, int *parentidp) |
| Get a group's parent ncid — the nc_inq_grp_parent() dispatch entry. | |
| int | NXCDF_inq_grp_full_ncid (int ncid, const char *full_name, int *grpidp) |
| Get the ncid of a group given its full path — the nc_inq_grp_full_ncid() dispatch entry. | |
| int | NXCDF_rename_grp (int grpid, const char *name) |
| Rename a populated enhanced-model group without changing object IDs. Moves only the parent link, retaining open descendants and their dimension and datatype relationships. Full names are derived from the updated tree. | |
nxCDF group creation and inquiry.
|
static |
Attach an HDF5 group handle to a freshly-added group.
Companion to get_grp_hdf(): used when the NC_GRP_INFO_T already exists (created by nc4_grp_list_add) and only the private NXCDF_GRP_INFO_T record with its hid_t needs to be hung off it. A no-op if the record is already attached.
| grp | Group. |
| hdf_group | HDF5 group identifier to attach. |
|
static |
Locate a direct child group by name.
| parent | Parent group. |
| name | Name. |
| grpp | Destination for the child group. |
|
static |
Recursively find a group in the tree by its in-file group id.
In netcdf-c an ncid is two halves: the upper 16 bits identify the file, the lower 16 bits the group inside that file. This walks the in-memory group tree looking for a group whose hdr.id matches the low half — the HDF5 object ids are not used for this lookup.
| root | Group tree root. |
| grpid | In-file group id (low half of an ncid). |
| grpp | Destination for the matching group. |
|
static |
Resolve the NC_GRP_INFO_T an ncid refers to.
Splits the ncid into file id (upper 16 bits) and in-file group id (lower 16 bits), locates the file's root group via netcdf-c's nc4_find_grp_h5, then descends the in-memory group tree. Group operations dispatch on an ncid that may name any group in the file, so nearly every public function in this file starts here.
| ncid | NetCDF file identifier (file id | group id). |
| h5 | Destination for the file state, or NULL; if non-NULL and *h5 is NULL it is filled with the file's NC_FILE_INFO_T. |
| grpp | Destination for the group. |
|
static |
Return the open HDF5 group handle for an in-memory group.
Every NC_GRP_INFO_T carries a NXCDF_GRP_INFO_T holding the hid_t of the corresponding HDF5 group. If that private record was never allocated (for example for the root group right after create), this function allocates it on demand: non-root groups get a placeholder handle that is filled in when the HDF5 group is created; the root group uses the file's rootid.
| grp | Group. |
| gid | Destination for the HDF5 group identifier. |
| int NXCDF_def_grp | ( | int | ncid, |
| const char * | name, | ||
| int * | grpidp ) |
Create a subgroup — the nc_def_grp() dispatch entry.
Validates define-mode write access, creates the HDF5 group under the parent's hid_t, adds the matching NC_GRP_INFO_T to the in-memory tree, and returns the child ncid. Groups are an enhanced-model feature: native and NC_NETCDF4_MODEL files accept them, while NC_CLASSIC_MODEL files return NC_ENOTNC4.
| ncid | NetCDF file identifier of the parent group. |
| name | Subgroup name. |
| grpidp | Destination for the new subgroup ncid. |
| int NXCDF_inq_grp_full_ncid | ( | int | ncid, |
| const char * | full_name, | ||
| int * | grpidp ) |
Get the ncid of a group given its full path — the nc_inq_grp_full_ncid() dispatch entry.
NXCDF_inq_ncid() already accepts absolute paths, so this is a straight delegation.
| ncid | NetCDF file identifier. |
| full_name | Full group path. |
| grpidp | Destination for the group ncid. |
| int NXCDF_inq_grp_parent | ( | int | ncid, |
| int * | parentidp ) |
Get a group's parent ncid — the nc_inq_grp_parent() dispatch entry.
| ncid | NetCDF file identifier. |
| parentidp | Destination for the parent ncid. |
| int NXCDF_inq_grpname | ( | int | ncid, |
| char * | name ) |
Get a group's (short) name — the nc_inq_grpname() dispatch entry.
| ncid | NetCDF file identifier. |
| name | Destination for the group name. |
| int NXCDF_inq_grpname_full | ( | int | ncid, |
| size_t * | lenp, | ||
| char * | name ) |
Get a group's full path name — the nc_inq_grpname_full() dispatch entry.
Rebuilds "/g1/g2/..." by walking the parent chain up to the root; the root group itself contributes nothing but the leading slash. Nesting is capped at 32 levels.
| ncid | NetCDF file identifier. |
| lenp | Destination for the name length. |
| name | Destination for the full group name. |
| int NXCDF_inq_grps | ( | int | ncid, |
| int * | numgrps, | ||
| int * | grpidsp ) |
Get the ncids of all subgroups — the nc_inq_grps() dispatch entry.
| ncid | NetCDF file identifier. |
| numgrps | Destination for the number of subgroups. |
| grpidsp | Destination for the subgroup ncids. |
| int NXCDF_inq_ncid | ( | int | ncid, |
| const char * | name, | ||
| int * | grpidp ) |
Get the ncid of a named subgroup — the nc_inq_ncid() dispatch entry.
name may be a simple name ("g1"), a relative path ("g1/g2"), or an absolute path ("/g1/g2"); "/" alone resolves to the root group. The lookup walks the in-memory group tree component by component — no HDF5 calls are needed because the metadata was fully loaded at open.
| ncid | NetCDF file identifier. |
| name | Subgroup name or path. |
| grpidp | Destination for the subgroup ncid. |
| int NXCDF_rename_grp | ( | int | grpid, |
| const char * | name ) |
Rename a populated enhanced-model group without changing object IDs. Moves only the parent link, retaining open descendants and their dimension and datatype relationships. Full names are derived from the updated tree.
Rename a non-root enhanced-model group and flush its link.
| grpid | Non-root group identifier. |
| name | New short name, normalized according to netCDF naming rules. |