File level functions assist with reading and writing the global attributes recommended by the CF conventions. More...
Defines | |
| #define | NCCF_MAX_TIMESTAMP_LEN 35 |
| Maximum length of a timestamp string in a history attribute. | |
Functions | |
| int | nccf_inq_libvers (char *version_string) |
| Get the version string for the CF Library (max length: NC_MAX_NAME + 1). | |
| int | nccf_def_convention (int ncid) |
| Annotate a file to indicate that it conforms to CF conventions. | |
| int | nccf_inq_convention (int ncid, int *cf_convention) |
| Determine if a file claims to conform to cf conventions. | |
| int | nccf_def_file (int ncid, const char *title, const char *history) |
| Add CF recommended global attributes to the file. | |
| int | nccf_add_history (int ncid, const char *history) |
| This function appends a time-stamped history string to the history attribute, creating the attribute if it doesn't already exist. | |
| int | nccf_inq_file (int ncid, size_t *title_lenp, char *title, size_t *history_lenp, char *history) |
| Read the CF annotations. | |
| int | nccf_def_notes (int ncid, int varid, const char *institution, const char *source, const char *comment, const char *references) |
| This functions writes up to four text attributes for either a variable, or an entire file: ``institution,'' ``source,'' ``comment,'' and ``references. | |
| int | nccf_inq_notes (int ncid, int varid, size_t *institution_lenp, char *institution, size_t *source_lenp, char *source, size_t *comment_lenp, char *comment, size_t *references_lenp, char *references) |
| Read any existing CF recommended text attributes from a variable. | |
File level functions assist with reading and writing the global attributes recommended by the CF conventions.
| #define NCCF_MAX_TIMESTAMP_LEN 35 |
| int nccf_add_history | ( | int | ncid, |
| const char * | history | ||
| ) |
This function appends a time-stamped history string to the history attribute, creating the attribute if it doesn't already exist.
| ncid | The ncid of the file. |
| history | The string to append to the history attribute. |
| int nccf_def_convention | ( | int | ncid | ) |
Annotate a file to indicate that it conforms to CF conventions.
From the CF 1.0 conventions: We recommend that the NUG defined attribute Conventions be given the string value 'CF-1.0' to identify datasets that conform to these conventions.
This function will mark a file with the CF-1.0 string in a Conventions attribute. This functions is called automatically by nccf_def_file, so need not be called by the user if nccf_def_file is being called.
| ncid | the ncid of the file to be annotated |
| int nccf_def_file | ( | int | ncid, |
| const char * | title, | ||
| const char * | history | ||
| ) |
Add CF recommended global attributes to the file.
From the CF 1.0 conventions:
'The general description of a file's contents should be contained in the following attributes: title, history, institution, source, comment and references (2.6.2). For backwards compatibility with COARDS none of these attributes is required, but their use is recommended to provide human readable documentation of the file contents.'
This function will add some or all of the CF recommended text attributes to a file. Any parameters which are set to NULL will be ignored.
| ncid | the ncid of the file to be annotated |
| title | the title string |
| history | the history string |
| int nccf_def_notes | ( | int | ncid, |
| int | varid, | ||
| const char * | institution, | ||
| const char * | source, | ||
| const char * | comment, | ||
| const char * | references | ||
| ) |
This functions writes up to four text attributes for either a variable, or an entire file: ``institution,'' ``source,'' ``comment,'' and ``references.
''
| ncid | The ncid of the file. |
| varid | The varid of the netCDF variable being described. Use NC_GLOBAL if you wish these attributes to apply to the entire file. |
| institution | If non-NULL, this text string will be written as the CF-recommended ``institution'' attribute. |
| source | If non-NULL, this text string will be written as the CF-recommended ``source'' attribute. |
| comment | If non-NULL, this text string will be written as the CF-recommended ``comment'' attribute. |
| references | If non-NULL, this text string will be written as the CF-recommended ``references'' attribute. |
| int nccf_inq_convention | ( | int | ncid, |
| int * | cf_convention | ||
| ) |
Determine if a file claims to conform to cf conventions.
This function will determine if the file claims to follow CF-1.0 conventions. This function only checks the global ``Conventions'' attribute. It does not look at file metadata to ensure that this is a well-formed CF file. It only tells whether the file claims to be a CF file.
| ncid | the ncid of the file |
| cf_convention | a 1 is written here if this file claims to follow CF 1.0 conventions, a 0 otherwise. |
| int nccf_inq_file | ( | int | ncid, |
| size_t * | title_lenp, | ||
| char * | title, | ||
| size_t * | history_lenp, | ||
| char * | history | ||
| ) |
Read the CF annotations.
Recall that in C, strlens do not include the null terminator. To get the lengths before the strings (in order to allocatate) pass NULL for any or all strngs and the lengths will be returned. Then call the funtion again after allocating memory.
The CF version is guaranteed to be less than NC_MAX_NAME.
Any of the pointer args may be NULL, in which case it will be ignored.
| ncid | The ncid of the file. |
| title_lenp | Pointer to size_t which, if not NULL, will get the length of the title attribute. |
| title | Pointer to char array which, if not NULL, will get the title string. Memory must be allocated before this function is called. Call this function with a NULL for this parameter to get the size first. |
| history_lenp | Pointer to size_t which, if not NULL, will get the length of the history attribute. |
| history | Pointer to char array which, if not NULL, will get the history string. Memory must be allocated before this function is called. Call this function with a NULL for this parameter to get the size first. |
| int nccf_inq_libvers | ( | char * | version_string | ) |
| int nccf_inq_notes | ( | int | ncid, |
| int | varid, | ||
| size_t * | institution_lenp, | ||
| char * | institution, | ||
| size_t * | source_lenp, | ||
| char * | source, | ||
| size_t * | comment_lenp, | ||
| char * | comment, | ||
| size_t * | references_lenp, | ||
| char * | references | ||
| ) |
Read any existing CF recommended text attributes from a variable.
| ncid | The ncid of the file. |
| varid | The varid of the netCDF variable. |
| institution_lenp | Pointer to size_t which, if not NULL, will get the length of the institution attribute. |
| institution | Pointer to char array which, if not NULL, will get the institution string. Memory must be allocated before this function is called. Call this function with a NULL for this parameter to get the size first. |
| source_lenp | Pointer to size_t which, if not NULL, will get the length of the source attribute. |
| source | Pointer to char array which, if not NULL, will get the source string. Memory must be allocated before this function is called. Call this function with a NULL for this parameter to get the size first. |
| comment_lenp | Pointer to size_t which, if not NULL, will get the length of the comment attribute. |
| comment | Pointer to char array which, if not NULL, will get the comment string. Memory must be allocated before this function is called. Call this function with a NULL for this parameter to get the size first. |
| references_lenp | Pointer to size_t which, if not NULL, will get the length of the references attribute. |
| references | Pointer to char array which, if not NULL, will get the references string. Memory must be allocated before this function is called. Call this function with a NULL for this parameter to get the size first. |