Table Of Contents


The CGNS/MLL and CGNS/ADF wrapper. Provides the user with a Python-like interface to the CGNS/MLL and CGNS/ADF functions. There are two classes acting as proxies to the MLL and the ADF calls. The interface to the calls are most of the time unchanged, that is the order and the types of the arguments are more or less the same as for the C/Fortran APIs.

The file id is always the first argument in the C/Fortran API, it is replaced by the class itself which holds the required connection information.


The so-called ADF calls of the v3 version of CGNS libraries can read/write ADF as well as HDF5 files.

MLL Examples

If you really want to use CGNS/MLL, for example if you have a large toolbox with old pyCGNS scripts you have to change your imports from CGNS.WRA to CGNS.WRA.wrapper for functions. There is a long example with fake data, the purpose here is to show the syntax:

import CGNS.WRA.wrapper
import CGNS.PAT.cgnskeywords as CGK
import numpy as NPY

db.zonewrite(1,'Zone 01',[3,5,7,2,4,6,0,0,0],CGK.Structured)
db.zonewrite(1,'Zone 02',[3,5,7,2,4,6,0,0,0],CGK.Structured)

# beware: the keywords for strings have the _s postfix like below
#         but enumerates are used without postfix
db.one2onewrite(1,1,"01-02","Zone 02",(3,1,1,3,5,7),(1,1,1,1,5,7),(1,2,3))
db.bcwrite(1,1,"I low",CGK.BCTunnelInflow,CGK.PointRange,[(1,1,1),(3,2,4)])
db.bcdatasetwrite(1,1,1,"I low DATA SET",CGK.BCTunnelInflow)

# we have now nodes that can be set as children of different node types,
# then we have to set the parent node using the goto. The current parent
# is a variable for the current CGNS file.



When a function call fails, it sets the error code and error message. You have to check it at each call if you want to make sure there is no problem:

import CGNS.WRA.wrapper
import CGNS.PAT.cgnskeywords as CGK

if (db.error[0] != 0):
  print "# Error code:%d message:[%s]"%(db.error[0],db.error[1])

The actual data is passed to the MLL using the numpy arrays. When you write you have to create the numpy array, once it is passed to the function you can delete it:


When you read, the MLL returns a new numpy array to you, this array now belongs to you and you can close the CGNS file and/or delete the array, there is no more relationship between the array and MLL:

print r.shape

Migration concerns

  • The module import keeps the CGNS.WRA.wrapper module name.

  • All constants have to be changed to fit CGNS.PAT.cgnskeywords variables RealDouble CGK.RealDouble RealSingle CGK.RealSingle

    CoordinateX CGK.CoordinateX_s


The official CGNS web site, by extension any document on this web site has an official taste...
The specific purpose of the CFD General Notation System (CGNS) project is to provide a standard for recording and recovering computer data associated with the numerical solution of the equations of fluid dynamics. See also the How to?.
The Standard Interface Data Structure is the specification of the data model. This public document describes the syntax and the semantics of all tree-structured data required or proposed for a CFD simulation.
The Mid-Level Library is an example implementation of CGNS/SIDS on top of CGNS/ADF and CGNS/HDF5 mappings. This library has a C and a Fortran API.
The Advanced Data Format *CGNS/SIDS* implementation. A binary storage format and its companion library, developped by Boeing.
The Hierarchical Data Format *CGNS/SIDS* implementation. A binary storage format and its companion library (see below).
The Python programming language *CGNS/SIDS* implementation.
A CGNS/HDF5 compliant implementation. The CHLone library is available on SourceForge.
A powerful storage system for large data. The HDF5 library should be seen as a middleware system with a lot of powerful features related to efficient, portable and trustable storage mean.
An object oriented interpreted programming language.
A compiler tool that translate Python/Numpy into C code for performance purpose.
The numerical library for Python. Numpy is used to store the data in Python arrays which have a direct memory mapping to actual C or Fortran memory.
A visualization toolkit used to display 3D objects ni CGNS.NAV.
The Python interface for the Qt toolkit. PySide
A powerful graphical toolkit available under GPL v3, LGPL v2 and a commercial license. The current use of Qt is under LGPL v2 in pyCGNS.

API Index