![]() |
NetCDF 4.9.3
|
#include "config.h"
#include "netcdf.h"
#include "netcdf_filter.h"
#include "netcdf_meta.h"
#include "nc4internal.h"
#include "nc.h"
#include "ncdispatch.h"
#include "ncutf8.h"
#include <stdarg.h>
#include <stddef.h>
#include "ncrc.h"
Go to the source code of this file.
Macros | |
#define | NRESERVED (sizeof(NC_reserved) / sizeof(NC_reservedatt)) /*|NC_reservedatt*/ |
Functions | |
static int | bincmp (const void *arg1, const void *arg2) |
static int | dim_free (NC_DIM_INFO_T *dim) |
static void | field_free (NC_FIELD_INFO_T *field) |
int | nc4_att_free (NC_ATT_INFO_T *att) |
int | nc4_att_list_add (NCindex *list, const char *name, NC_ATT_INFO_T **att) |
int | nc4_att_list_del (NCindex *list, NC_ATT_INFO_T *att) |
int | nc4_check_dup_name (NC_GRP_INFO_T *grp, char *name) |
int | nc4_check_name (const char *name, char *norm_name) |
int | nc4_dim_list_add (NC_GRP_INFO_T *grp, const char *name, size_t len, int assignedid, NC_DIM_INFO_T **dim) |
int | nc4_dim_list_del (NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim) |
int | nc4_enum_member_add (NC_TYPE_INFO_T *parent, size_t size, const char *name, const void *value) |
int | nc4_field_list_add (NC_TYPE_INFO_T *parent, const char *name, size_t offset, nc_type xtype, int ndims, const int *dim_sizesp) |
int | nc4_file_change_ncid (int ncid, unsigned short new_ncid_index) |
int | nc4_file_list_add (int ncid, const char *path, int mode, void **dispatchdata) |
int | nc4_file_list_del (int ncid) |
int | nc4_file_list_get (int ncid, char **path, int *mode, void **dispatchdata) |
int | nc4_find_dim (NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T **dim, NC_GRP_INFO_T **dim_grp) |
int | nc4_find_grp_att (NC_GRP_INFO_T *grp, int varid, const char *name, int attnum, NC_ATT_INFO_T **att) |
int | nc4_find_grp_h5 (int ncid, NC_GRP_INFO_T **grp, NC_FILE_INFO_T **h5) |
int | nc4_find_grp_h5_var (int ncid, int varid, NC_FILE_INFO_T **h5, NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var) |
int | nc4_find_nc4_grp (int ncid, NC_GRP_INFO_T **grp) |
int | nc4_find_nc_att (int ncid, int varid, const char *name, int attnum, NC_ATT_INFO_T **att) |
int | nc4_find_nc_grp_h5 (int ncid, NC **nc, NC_GRP_INFO_T **grp, NC_FILE_INFO_T **h5) |
int | nc4_find_type (const NC_FILE_INFO_T *h5, nc_type typeid, NC_TYPE_INFO_T **type) |
int | nc4_find_var (NC_GRP_INFO_T *grp, const char *name, NC_VAR_INFO_T **var) |
int | nc4_grp_list_add (NC_FILE_INFO_T *h5, NC_GRP_INFO_T *parent, char *name, NC_GRP_INFO_T **grp) |
static int | NC4_move_in_NCList (NC *nc, int new_id) |
int | nc4_nc4f_list_add (NC *nc, const char *path, int mode) |
int | nc4_nc4f_list_del (NC_FILE_INFO_T *h5) |
int | nc4_normalize_name (const char *name, char *norm_name) |
NC_TYPE_INFO_T * | nc4_rec_find_named_type (NC_GRP_INFO_T *start_grp, char *name) |
int | nc4_rec_grp_del (NC_GRP_INFO_T *grp) |
int | nc4_rec_grp_del_att_data (NC_GRP_INFO_T *grp) |
int | NC4_show_metadata (int ncid) |
int | nc4_type_free (NC_TYPE_INFO_T *type) |
int | nc4_type_list_add (NC_GRP_INFO_T *grp, size_t size, const char *name, NC_TYPE_INFO_T **type) |
int | nc4_type_new (size_t size, const char *name, int assignedid, NC_TYPE_INFO_T **type) |
int | nc4_var_list_add (NC_GRP_INFO_T *grp, const char *name, int ndims, NC_VAR_INFO_T **var) |
int | nc4_var_list_add2 (NC_GRP_INFO_T *grp, const char *name, NC_VAR_INFO_T **var) |
int | nc4_var_list_del (NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) |
int | nc4_var_set_ndims (NC_VAR_INFO_T *var, int ndims) |
const NC_reservedatt * | NC_findreserved (const char *name) |
void | NC_initialize_reserved (void) |
static void | obj_track (NC_FILE_INFO_T *file, NC_OBJ *obj) |
static int | sortcmp (const void *arg1, const void *arg2) |
static int | var_free (NC_VAR_INFO_T *var) |
Variables | |
static NC_reservedatt | NC_reserved [] |
Internal netcdf-4 functions.
This file contains functions internal to the netcdf4 library. None of the functions in this file are exposed in the exetnal API. These functions all relate to the manipulation of netcdf-4's in-memory buffer of metadata information, i.e. the linked list of NC structs.
Definition in file nc4internal.c.
#define NRESERVED (sizeof(NC_reserved) / sizeof(NC_reservedatt)) /*|NC_reservedatt*/ |
Definition at line 62 of file nc4internal.c.
|
static |
Definition at line 2075 of file nc4internal.c.
|
static |
Free a dim
dim | Pointer to dim info struct of type to delete. |
Definition at line 1451 of file nc4internal.c.
|
static |
Free up a field
field | Pointer to field info of field to delete. |
Definition at line 1238 of file nc4internal.c.
int nc4_att_free | ( | NC_ATT_INFO_T * | att | ) |
Free memory of an attribute object
att | Pointer to attribute info struct. |
Definition at line 1329 of file nc4internal.c.
int nc4_att_list_add | ( | NCindex * | list, |
const char * | name, | ||
NC_ATT_INFO_T ** | att ) |
Add to an attribute list.
list | NCindex of att info structs. |
name | name of the new attribute |
att | Pointer to pointer that gets the new att info struct. Ignored if NULL. |
Definition at line 910 of file nc4internal.c.
int nc4_att_list_del | ( | NCindex * | list, |
NC_ATT_INFO_T * | att ) |
Remove a NC_ATT_INFO_T from an index. This will nc_free the memory too.
list | Pointer to pointer of list. |
att | Pointer to attribute info struct. |
Definition at line 1606 of file nc4internal.c.
int nc4_check_dup_name | ( | NC_GRP_INFO_T * | grp, |
char * | name ) |
Names for groups, variables, and types must not be the same. This function checks that a proposed name is not already in use. Normalzation of UTF8 strings should happen before this function is called.
grp | Pointer to group info struct. |
name | Name to check. |
Definition at line 1015 of file nc4internal.c.
int nc4_check_name | ( | const char * | name, |
char * | norm_name ) |
Check and normalize and name.
name | Name to normalize. |
norm_name | The normalized name. |
Definition at line 154 of file nc4internal.c.
int nc4_dim_list_add | ( | NC_GRP_INFO_T * | grp, |
const char * | name, | ||
size_t | len, | ||
int | assignedid, | ||
NC_DIM_INFO_T ** | dim ) |
Add a dimension to the dimension list for a group.
grp | container for the dim |
name | for the dim |
len | for the dim |
assignedid | override dimid if >= 0 |
dim | Pointer to pointer that gets the new dim info struct. |
Definition at line 851 of file nc4internal.c.
int nc4_dim_list_del | ( | NC_GRP_INFO_T * | grp, |
NC_DIM_INFO_T * | dim ) |
Free a dim and unlist it
grp | Pointer to dim's containing group |
dim | Pointer to dim info struct of type to delete. |
Definition at line 1474 of file nc4internal.c.
int nc4_enum_member_add | ( | NC_TYPE_INFO_T * | parent, |
size_t | size, | ||
const char * | name, | ||
const void * | value ) |
Add a member to an enum type.
parent | Containing NC_TYPE_INFO_T object |
size | Size in bytes of new member. |
name | Name of the member. |
value | Value to associate with member. |
Definition at line 1199 of file nc4internal.c.
int nc4_field_list_add | ( | NC_TYPE_INFO_T * | parent, |
const char * | name, | ||
size_t | offset, | ||
nc_type | xtype, | ||
int | ndims, | ||
const int * | dim_sizesp ) |
Add to the compound field list.
parent | parent type |
name | Name of the field. |
offset | Offset in bytes. |
xtype | The netCDF type of the field. |
ndims | The number of dimensions of the field. |
dim_sizesp | An array of dim sizes for the field. |
Definition at line 1142 of file nc4internal.c.
int nc4_file_change_ncid | ( | int | ncid, |
unsigned short | new_ncid_index ) |
Change the ncid of an open file. This is needed for PIO integration.
ncid | The ncid of the file (aka ext_ncid). |
new_ncid_index | The new ncid index to use (i.e. the first two bytes of the ncid). |
Definition at line 247 of file nc4internal.c.
int nc4_file_list_add | ( | int | ncid, |
const char * | path, | ||
int | mode, | ||
void ** | dispatchdata ) |
Add a file to the list of libsrc4 open files. This is used by dispatch layers that wish to use the libsrc4 metadata model, but don't know about struct NC. This is the same as nc4_nc4f_list_add(), except it takes an ncid instead of an NC *, and also passes back the dispatchdata pointer.
ncid | The (already-assigned) ncid of the file (aka ext_ncid). |
path | The file name of the new file. |
mode | The mode flag. |
dispatchdata | Void * that gets pointer to dispatch data, which is the NC_FILE_INFO_T struct allocated for this file and its metadata. Ignored if NULL. (This is passed as a void to allow external user-defined formats to use this function.) |
Definition at line 211 of file nc4internal.c.
int nc4_file_list_del | ( | int | ncid | ) |
Free all resources and memory associated with a NC_FILE_INFO_T. This is the same as nc4_nc4f_list_del(), except it takes ncid. This function allows external dispatch layers, like PIO, to manipulate the file list without needing to know about internal netcdf structures.
ncid | The ncid of the file to release. |
Definition at line 1627 of file nc4internal.c.
int nc4_file_list_get | ( | int | ncid, |
char ** | path, | ||
int * | mode, | ||
void ** | dispatchdata ) |
Get info about a file on the list of libsrc4 open files. This is used by dispatch layers that wish to use the libsrc4 metadata model, but don't know about struct NC.
ncid | The ncid of the file (aka ext_ncid). |
path | A pointer that gets file name (< NC_MAX_NAME). Ignored if NULL. |
mode | A pointer that gets the mode flag. Ignored if NULL. |
dispatchdata | Void * that gets pointer to dispatch data, which is the NC_FILE_INFO_T struct allocated for this file and its metadata. Ignored if NULL. (This is passed as a void to allow external user-defined formats to use this function.) |
Definition at line 290 of file nc4internal.c.
int nc4_find_dim | ( | NC_GRP_INFO_T * | grp, |
int | dimid, | ||
NC_DIM_INFO_T ** | dim, | ||
NC_GRP_INFO_T ** | dim_grp ) |
Find a dim in the file.
grp | Pointer to group info struct. |
dimid | Dimension ID to find. |
dim | Pointer that gets pointer to dim info if found. |
dim_grp | Pointer that gets pointer to group info of group that contains dimension. Ignored if NULL. |
Definition at line 511 of file nc4internal.c.
int nc4_find_grp_att | ( | NC_GRP_INFO_T * | grp, |
int | varid, | ||
const char * | name, | ||
int | attnum, | ||
NC_ATT_INFO_T ** | att ) |
Given a group, find an att. If name is provided, use that, otherwise use the attnum.
grp | Pointer to group info struct. |
varid | Variable ID. |
name | Name to of attribute. |
attnum | Number of attribute. |
att | Pointer to pointer that gets attribute info struct. |
Definition at line 629 of file nc4internal.c.
int nc4_find_grp_h5 | ( | int | ncid, |
NC_GRP_INFO_T ** | grp, | ||
NC_FILE_INFO_T ** | h5 ) |
Given an ncid, find the relevant group and return a pointer to it, also set a pointer to the nc4_info struct of the related file.
ncid | File and group ID. |
grp | Pointer that gets pointer to group info struct. Ignored if NULL. |
h5 | Pointer that gets pointer to file info struct. Ignored if NULL. |
Definition at line 402 of file nc4internal.c.
int nc4_find_grp_h5_var | ( | int | ncid, |
int | varid, | ||
NC_FILE_INFO_T ** | h5, | ||
NC_GRP_INFO_T ** | grp, | ||
NC_VAR_INFO_T ** | var ) |
Given an ncid and varid, get pointers to the group and var metadata.
ncid | File ID. |
varid | Variable ID. |
h5 | Pointer that gets pointer to the NC_FILE_INFO_T struct for this file. Ignored if NULL. |
grp | Pointer that gets pointer to group info. Ignored if NULL. |
var | Pointer that gets pointer to var info. Ignored if NULL. |
Definition at line 468 of file nc4internal.c.
int nc4_find_nc4_grp | ( | int | ncid, |
NC_GRP_INFO_T ** | grp ) |
Given an ncid, find the relevant group and return a pointer to it.
ncid | File and group ID. |
grp | Pointer that gets pointer to group info struct. Ignored if NULL. |
Definition at line 381 of file nc4internal.c.
int nc4_find_nc_att | ( | int | ncid, |
int | varid, | ||
const char * | name, | ||
int | attnum, | ||
NC_ATT_INFO_T ** | att ) |
Given an ncid, varid, and name or attnum, find and return pointer to NC_ATT_INFO_T metadata.
ncid | File and group ID. |
varid | Variable ID. |
name | Name to of attribute. |
attnum | Number of attribute. |
att | Pointer to pointer that gets attribute info struct. |
Definition at line 686 of file nc4internal.c.
int nc4_find_nc_grp_h5 | ( | int | ncid, |
NC ** | nc, | ||
NC_GRP_INFO_T ** | grp, | ||
NC_FILE_INFO_T ** | h5 ) |
Find info for this file and group, and set pointers.
ncid | File and group ID. |
nc | Pointer that gets a pointer to the file's NC struct. Ignored if NULL. |
grp | Pointer that gets a pointer to the group struct. Ignored if NULL. |
h5 | Pointer that gets HDF5 file struct. Ignored if NULL. |
Definition at line 422 of file nc4internal.c.
int nc4_find_type | ( | const NC_FILE_INFO_T * | h5, |
nc_type | typeid, | ||
NC_TYPE_INFO_T ** | type ) |
Use a netCDF typeid to find a type in a type_list.
h5 | Pointer to HDF5 file info struct. |
typeid | The netCDF type ID. |
type | Pointer to pointer to the list of type info structs. |
Definition at line 593 of file nc4internal.c.
int nc4_find_var | ( | NC_GRP_INFO_T * | grp, |
const char * | name, | ||
NC_VAR_INFO_T ** | var ) |
Find a var (by name) in a grp.
grp | Pointer to group info. |
name | Name of var to find. |
var | Pointer that gets pointer to var info struct, if found. |
Definition at line 539 of file nc4internal.c.
int nc4_grp_list_add | ( | NC_FILE_INFO_T * | h5, |
NC_GRP_INFO_T * | parent, | ||
char * | name, | ||
NC_GRP_INFO_T ** | grp ) |
Add a group to a group list.
h5 | Pointer to the file info. |
parent | Pointer to the parent group. Will be NULL when adding the root group. |
name | Name of the group. |
grp | Pointer to pointer that gets new group info struct. Ignored if NULL. |
Definition at line 953 of file nc4internal.c.
|
static |
Definition at line 2055 of file nc4internal.c.
int nc4_nc4f_list_add | ( | NC * | nc, |
const char * | path, | ||
int | mode ) |
Given an NC pointer, add the necessary stuff for a netcdf-4 file. This allocates the NC_FILE_INFO_T struct for the file, which is used by libhdf5 and libhdf4 (and perhaps other future dispatch layers) to hold the metadata for the file.
nc | Pointer to file's NC struct. |
path | The file name of the new file. |
mode | The mode flag. |
Definition at line 329 of file nc4internal.c.
int nc4_nc4f_list_del | ( | NC_FILE_INFO_T * | h5 | ) |
Free all resources and memory associated with a NC_FILE_INFO_T.
h5 | Pointer to NC_FILE_INFO_T to be freed. |
Definition at line 1654 of file nc4internal.c.
int nc4_normalize_name | ( | const char * | name, |
char * | norm_name ) |
Normalize a UTF8 name. Put the result in norm_name, which can be NC_MAX_NAME + 1 in size. This function makes sure the free() gets called on the return from utf8proc_NFC, and also ensures that the name is not too long.
name | Name to normalize. |
norm_name | The normalized name. |
Definition at line 1700 of file nc4internal.c.
NC_TYPE_INFO_T * nc4_rec_find_named_type | ( | NC_GRP_INFO_T * | start_grp, |
char * | name ) |
Locate netCDF type by name.
start_grp | Pointer to starting group info. |
name | Name of type to find. |
Definition at line 558 of file nc4internal.c.
int nc4_rec_grp_del | ( | NC_GRP_INFO_T * | grp | ) |
Recursively delete the data for a group (and everything it contains) in our internal metadata store.
grp | Pointer to group info struct. |
Definition at line 1496 of file nc4internal.c.
int nc4_rec_grp_del_att_data | ( | NC_GRP_INFO_T * | grp | ) |
Recursively delete the data for a group (and everything it contains) in our internal metadata store.
grp | Pointer to group info struct. |
Definition at line 1556 of file nc4internal.c.
int NC4_show_metadata | ( | int | ncid | ) |
Show the in-memory metadata for a netcdf file. This function does nothing unless netCDF was built with the configure option –enable-logging.
ncid | File and group ID. |
Definition at line 2002 of file nc4internal.c.
int nc4_type_free | ( | NC_TYPE_INFO_T * | type | ) |
Free allocated space for type information.
type | Pointer to type info struct. |
Definition at line 1260 of file nc4internal.c.
int nc4_type_list_add | ( | NC_GRP_INFO_T * | grp, |
size_t | size, | ||
const char * | name, | ||
NC_TYPE_INFO_T ** | type ) |
Add to the type list.
grp | Pointer to group info struct. |
size | Size of type in bytes. |
name | Name of type. |
type | Pointer that gets pointer to new type info struct. |
Definition at line 1096 of file nc4internal.c.
int nc4_type_new | ( | size_t | size, |
const char * | name, | ||
int | assignedid, | ||
NC_TYPE_INFO_T ** | type ) |
Create a type, but do not add to various lists nor increment its ref count
size | Size of type in bytes. |
name | Name of type. |
assignedid | if >= 0 then override the default type id. |
type | Pointer that gets pointer to new type info struct. |
Definition at line 1053 of file nc4internal.c.
int nc4_var_list_add | ( | NC_GRP_INFO_T * | grp, |
const char * | name, | ||
int | ndims, | ||
NC_VAR_INFO_T ** | var ) |
Create a new variable and insert int relevant list.
grp | the containing group |
name | the name for the new variable |
ndims | the rank of the new variable |
var | Pointer in which to return a pointer to the new var. |
Definition at line 824 of file nc4internal.c.
int nc4_var_list_add2 | ( | NC_GRP_INFO_T * | grp, |
const char * | name, | ||
NC_VAR_INFO_T ** | var ) |
Create a new variable and insert into relevant lists. Dimensionality info need not be known.
grp | the containing group |
name | the name for the new variable |
var | Pointer in which to return a pointer to the new var. |
Definition at line 740 of file nc4internal.c.
int nc4_var_list_del | ( | NC_GRP_INFO_T * | grp, |
NC_VAR_INFO_T * | var ) |
Delete a var, and free the memory.
grp | Pointer to the strct for the containing group. |
var | Pointer to the var info struct of var to delete. |
Definition at line 1428 of file nc4internal.c.
int nc4_var_set_ndims | ( | NC_VAR_INFO_T * | var, |
int | ndims ) |
Set the number of dims in an NC_VAR_INFO_T struct.
var | Pointer to the var. |
ndims | Number of dimensions for this var. |
Definition at line 788 of file nc4internal.c.
const NC_reservedatt * NC_findreserved | ( | const char * | name | ) |
Define a binary searcher for reserved attributes
name | for which to search |
Definition at line 2029 of file nc4internal.c.
void NC_initialize_reserved | ( | void | ) |
Definition at line 2083 of file nc4internal.c.
|
static |
Add NC_OBJ to allXXX lists in a file
file | Pointer to the containing file |
obj | Pointer to object to add. |
Definition at line 712 of file nc4internal.c.
|
static |
Definition at line 2067 of file nc4internal.c.
|
static |
Delete a var, and free the memory. All HDF5 objects for the var must be closed before this is called.
var | Pointer to the var info struct of var to delete. |
Definition at line 1370 of file nc4internal.c.
|
static |
Number of reserved attributes. These attributes are hidden from the netcdf user, but exist in the implementation datasets to help netcdf read the dataset. Moved here from hdf5file.c. These tables need to capture all reserved attributes across all possible dispatchers
List of reserved attributes. WARNING: This list will be sorted in (strcmp) sorted order for binary search. So order here does not matter; the table will be modified by sorting.
Definition at line 42 of file nc4internal.c.