Defines | Functions

File-Level Functions

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.

Detailed Description

File level functions assist with reading and writing the global attributes recommended by the CF conventions.


Define Documentation

#define NCCF_MAX_TIMESTAMP_LEN   35

Maximum length of a timestamp string in a history attribute.

Definition at line 377 of file cffiles.c.


Function Documentation

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.

Parameters:
ncidThe ncid of the file.
historyThe string to append to the history attribute.
Returns:
0 for success, error code otherwise

Definition at line 391 of file cffiles.c.

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.

Parameters:
ncidthe ncid of the file to be annotated
Returns:
0 for success, error code otherwise

Definition at line 254 of file cffiles.c.

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.

Parameters:
ncidthe ncid of the file to be annotated
titlethe title string
historythe history string
Returns:
0 on success, error code otherwise

Definition at line 353 of file cffiles.c.

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.

''

Parameters:
ncidThe ncid of the file.
varidThe varid of the netCDF variable being described. Use NC_GLOBAL if you wish these attributes to apply to the entire file.
institutionIf non-NULL, this text string will be written as the CF-recommended ``institution'' attribute.
sourceIf non-NULL, this text string will be written as the CF-recommended ``source'' attribute.
commentIf non-NULL, this text string will be written as the CF-recommended ``comment'' attribute.
referencesIf non-NULL, this text string will be written as the CF-recommended ``references'' attribute.
Returns:
0 for success, error code otherwise
Examples:
tst_vars.c.

Definition at line 520 of file cffiles.c.

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.

Parameters:
ncidthe ncid of the file
cf_conventiona 1 is written here if this file claims to follow CF 1.0 conventions, a 0 otherwise.
Returns:
0 for success, error code otherwise

Definition at line 276 of file cffiles.c.

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.

Parameters:
ncidThe ncid of the file.
title_lenpPointer to size_t which, if not NULL, will get the length of the title attribute.
titlePointer 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_lenpPointer to size_t which, if not NULL, will get the length of the history attribute.
historyPointer 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.
Returns:
0 for success, error code otherwise

Definition at line 460 of file cffiles.c.

int nccf_inq_libvers ( char *  version_string)

Get the version string for the CF Library (max length: NC_MAX_NAME + 1).

Parameters:
version_stringif non-NULL, the library version char array will be written here. It will be NULL-terminated and less that NC_MAX_NAME chars.
Returns:
0 for success.
Author:
Ed Hartnett, Unidata

Definition at line 166 of file cffiles.c.

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.

Parameters:
ncidThe ncid of the file.
varidThe varid of the netCDF variable.
institution_lenpPointer to size_t which, if not NULL, will get the length of the institution attribute.
institutionPointer 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_lenpPointer to size_t which, if not NULL, will get the length of the source attribute.
sourcePointer 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_lenpPointer to size_t which, if not NULL, will get the length of the comment attribute.
commentPointer 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_lenpPointer to size_t which, if not NULL, will get the length of the references attribute.
referencesPointer 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.
Returns:
0 for success, error code otherwise
Examples:
tst_vars.c.

Definition at line 595 of file cffiles.c.

 All Classes Files Functions Defines

Generated on Tue Mar 1 2011 06:36:59 for libCF. LibCF is a Unidata library.