Skip navigation links
(CGNS Documentation Home Page) (Steering Committee Charter) (Overview and Entry-Level Document) (A User's Guide to CGNS) (Standard Interface Data Structures) (SIDS-to-ADF File Mapping Manual) (SIDS-to-HDF File Mapping Manual) (Mid-Level Library) (ADF User's Guide) (CGNS Tools and Utilities)

(General Remarks) (Opening and Closing a CGNS File) (Navigating a CGNS File) (Error Handling) (Structural Nodes) (Descriptors) (Physical Data) (Location and Position) (Auxiliary Data) (Grid Specification) (Solution Data) (Grid Connectivity) (Boundary Conditions) (Equation Specification) (Families) (Time-Dependent Data) (Links)

Navigating a CGNS File

Accessing a Node


Functions Modes
ier = cg_goto(int fn, int B, ..., "end"); r w m
call cg_goto_f(fn, B, ier, ..., 'end') r w m

Input/Output

    fn   CGNS file index number.

B Base index number, where 1 ≤ Bnbases.

... Variable argument list used to specify the path to a node. It is composed of an unlimited list of pair-arguments. Each pair-argument takes the form CGNS_NodeLabel, NodeIndex. An example is Zone_t, ZoneIndex.

There is one exception to this rule. When accessing a BCData_t node, the index must be set to either Dirichlet or Neumann since only these two types are allowed. (Note that Dirichlet and Neumann are defined in the include files cgnslib.h and cgnslib_f.h). See the example below.

end The character string "end" (or 'end' for the Fortran function) must be the last argument. It is used to indicate the end of the argument list.

ier Error status. The possible values, with the corresponding C names (or Fortran parameters) defined in cgnslib.h (or cgnslib_f.h) are listed below.

    Value   Name/Parameter
0 CG_OK
1 CG_ERROR
2 CG_NODE_NOT_FOUND
3 CG_INCORRECT_PATH

For non-zero values, an error message may be printed using cg_error_print().

This function allows access to any parent-type nodes in a CGNS file. A parent-type node is one that can have children. Nodes that cannot have children, like Descriptor_t, are not supported by this function.

Shown below are examples of the use of cg_goto for both C and Fortran.

   ier = cg_goto(fn, B, "Zone_t", Z, "FlowSolution_t", F, "end");

   call cg_goto_f(fn, B, ier, 'Zone_t', Z, 'GasModel_t', 1, 'DataArray_t',
                  A, 'end')

   call cg_goto_f(fn, B, 'Zone_t', Z, 'ZoneBC_t', 1, 'BC_t', BC,
                  'BCDataSet_t', S, 'BCData_t', Dirichlet)

Deleting a Node


Functions Modes
ier = cg_delete_node(char *NodeName); - - m
call cg_delete_node_f(NodeName, ier) - - m

Input/Output

    NodeName   Name of the child to be deleted.
ier Error status.

The function cg_delete_node is used is conjunction with cg_goto. Once positioned at a parent node with cg_goto, a child of this node can be deleted with cg_delete_node. This function requires a single argument, NodeName, which is the name of the child to be deleted.

Since the highest level that can be pointed to with cg_goto is a base node for a CGNS database (CGNSBase_t), the highest-level nodes that can be deleted are the children of a CGNSBase_t node. In other words, nodes located directly under the ADF (or HDF) root node (CGNSBase_t and CGNSLibraryVersion_t) can not be deleted with cg_delete.

A few other nodes are not allowed to be deleted from the database because these are required nodes as defined by the SIDS, and deleting them would make the file non-CGNS compliant. These are:

When a child node is deleted, both the database and the file on disk are updated to remove the node. One must be careful not to delete a node from within a loop of that node type. For example, if the number of zones below a CGNSBase_t node is nzones, a zone should never be deleted from within a zone loop! By deleting a zone, the total number of zones (nzones) changes, as well as the zone indexing. Suppose for example that nzones is 5, and that the third zone is deleted. After calling cg_delete_node, nzones is changed to 4, and the zones originally indexed 4 and 5 are now indexed 3 and 4.