Functions | Modes |
---|---|
ier = cg_open(char *filename, int mode, int *fn); | r w m |
ier = cg_version(int fn, float *version); | r w m |
ier = cg_close(int fn); | r w m |
ier = cg_is_cgns(const char *filename, int *file_type); | r w m |
ier = cg_save_as(int fn, const char *filename, int file_type, int follow_links); | r w m |
ier = cg_set_file_type(int file_type); | r w m |
ier = cg_get_file_type(int fn, int *file_type); | r w m |
call cg_open_f(filename, mode, fn, ier) | r w m |
call cg_version_f(fn, version, ier) | r w m |
call cg_close_f(fn, ier) | r w m |
call cg_is_cgns_f(filename, file_type, ier) | r w m |
call cg_save_as_f(fn, filename, file_type, follow_links, ier); | r w m |
call cg_set_file_type_f(file_type, ier); | r w m |
call cg_get_file_type_f(fn, file_type, ier); | r w m |
filename | Name of the CGNS file, including path name if necessary. There is no limit on the length of this character variable. | ||
mode | Mode used for opening the file. The modes currently supported are CG_MODE_READ, CG_MODE_WRITE, and CG_MODE_MODIFY. | ||
fn | CGNS file index number. | ||
version | CGNS version number. | ||
file_type | Type of CGNS file. This will typically be either CG_FILE_ADF or CG_FILE_HDF5 depending on the underlying file format. However, note that when built in 32-bit, there is also an option to create a Version 2.5 CGNS file by setting the file type to CG_FILE_ADF2. | ||
follow_links | This flag determines whether links are left intact when saving a CGNS file. If non-zero, then the links will be removed and the data associated with the linked files copied to the new file. | ||
ier | Error status. |
The function cg_open must always be the first one called. It opens a CGNS file for reading and/or writing and returns an index number fn. The index number serves to identify the CGNS file in subsequent function calls. Several CGNS files can be opened simultaneously. The current limit on the number of files opened at once depends on the platform. On an SGI workstation, this limit is set at 100 (parameter FOPEN_MAX in stdio.h).
The file can be opened in one of the following modes:
CG_MODE_READ | Read only mode. | ||
CG_MODE_WRITE | Write only mode. | ||
CG_MODE_MODIFY | Reading and/or writing is allowed. |
When the file is opened, if no CGNSLibraryVersion_t node is found, a default value of 1.05 is assumed for the CGNS version number. Note that this corresponds to an old version of the CGNS standard, that doesn't include many data structures supported by the current standard.
The function cg_close must always be the last one called. It closes the CGNS file designated by the index number fn and frees the memory where the CGNS data was kept. When a file is opened for writing, cg_close writes all the CGNS data in memory onto disk prior to closing the file. Consequently, if is omitted, the CGNS file is not written properly.
In order to reduce memory usage and improve execution speed, large arrays such as grid coordinates or flow solutions are not actually stored in memory. Instead, only basic information about the node is kept, while reads and writes of the data is directly to and from the application's memory. An attempt is also made to do the same with unstructured mesh element data.
The function cg_is_cgns may be used to determine if a file is a CGNS file or not, and the type of file (CG_FILE_ADF or CG_FILE_HDF5). If the file is a CGNS file, cg_is_cgns returns CG_OK, otherwise CG_ERROR is returned and file_type is set to CG_FILE_NONE.
The CGNS file identified by fn may be saved to a different filename and type using cg_save_as. In order to save as an HDF5 file, the library must have been built with HDF5 support. ADF support is always built. The function cg_set_file_type sets the default file type for newly created CGNS files. The function cg_get_file_type returns the file type for the CGNS file identified by fn. If the CGNS library is built as 32-bit, the additional file type, CG_FILE_ADF2, is available. This allows creation of a 2.5 compatible CGNS file.
Functions | Modes |
---|---|
ier = cg_configure(int option, void *value); | r w m |
ier = cg_error_handler(void (*)(int, char *)); | r w m |
ier = cg_set_compress(int compress); | r w m |
ier = cg_get_compress(int *compress); | r w m |
ier = cg_set_path(const char *path); | r w m |
ier = cg_add_path(const char *path); | r w m |
call cg_set_compress_f(compress, ier); | r w m |
call cg_get_compress_f(compress, ier); | r w m |
call cg_set_path_f(path, ier); | r w m |
call cg_add_path_f(path, ier); | r w m |
option | The option to configure, currently one of CG_CONFIG_ERROR, CG_CONFIG_COMPRESS, CG_CONFIG_SET_PATH, CG_CONFIG_ADD_PATH, or CG_CONFIG_HDF5_COMPRESS as defined in cgnslib.h. | ||
value | The value to set, type cast as void *. | ||
compress | CGNS compress (rewrite) setting. | ||
path | Pathname to search for linked to files when opening a file with external links. | ||
ier | Error status. |
The function cg_configure allows certain CGNS library internal
options to be configured.
The currently supported options and expected values are:
CG_CONFIG_ERROR | This allows an error call-back function to be defined by the user. The value should be a pointer to a function to receive the error. The function is defined as void err_callback(int is_error, char *errmsg), and will be called for errors and warnings. The first argument, is_error, will be 0 for warning messages, 1 for error messages, and −1 if the program is going to terminate (i.e., a call to cg_error_exit()). The second argument is the error or warning message. If this is defined, warning and error messages will go to the function, rather than the terminal. A value of NULL will remove the call-back function. | ||
CG_CONFIG_COMPRESS | When a CGNS file is closed after being opened in modify mode, the normal operation of the CGNS library is to rewrite the file if there is unused space. This happens when nodes have been rewritten or deleted. Setting value to 0 will prevent the library from rewriting the file, and setting it to 1 will force the rewrite. The default value is −1. | ||
CG_CONFIG_SET_PATH | Sets the search path for locating linked-to files. The argument value should be a character string containing one or more directories, formatted the same as for the PATH environment variable. This will replace any current settings. Setting value to NULL will remove all paths. | ||
CG_CONFIG_ADD_PATH | Adds a directory, or list of directories, to the linked-to file search path. This is the same as CG_CONFIG_SET_PATH, but adds to the path instead of replacing it. | ||
CG_CONFIG_HDF5_COMPRESS | Sets the compression level for data written from HDF5. The default is no compression. Setting value to -1, will use the default compression level of 6. The acceptable values are 0 to 9, corresponding to gzip compression levels. |
The routines cg_error_handler, cg_set_compress, cg_set_path, and cg_add_path are convenience functions built on top of cg_configure.
There is no Fortran counterpart to function cg_configure or cg_error_handler.
Note: The HDF5 implementation does not support search paths for linked files. The links need to be either absolute or relative pathnames. As a result, it is recommended that the search path options not be used as they may be removed in future versions.
Functions | Modes |
---|---|
ier = cg_get_cgio(int fn, int *cgio_num); | r w m |
ier = cg_root_id(int fn, double *rootid); | r w m |
call cg_get_cgio_f(fn, cgio_num, ier) | r w m |
call cg_root_id_f(fn, rootid, ier) | r w m |
fn | CGNS file index number. | ||
cgio_num | CGIO indentifier for the CGNS file. | ||
rootid | Root node identifier for the CGNS file. | ||
ier | Error status. |
These allow for the use of the low-level CGIO functions in conjunction with the Mid Level Library. The function cg_get_cgio returns the CGIO database identifier for the specified CGNS file, which is used in the CGIO routines. The root node identifier for the CGNS file is returned by cg_root_id.