Display MPAS Grids

MPAS_GRID_DISPLAY_OPENGL, C++ programs which read information from an MPAS Grid file, stored in NETCDF format, and display the main (mainly hexagonal) mesh or the dual triangulation, using OpenGL.


where displays a plot of the polygonal faces of the primal mesh.

where displays a plot of the faces of the dual triangulation.

where displays a plot of the lines of the dual triangulation.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


MPAS_GRID_DISPLAY_OPENGL is available in a C++ version.

Related Programs:

FERN_OPENGL, a C++ program which uses OpenGL to display the Barnsley fractal fern.

MPAS_DRAW, a C++ program which reads an MPAS NETCDF file and allows the interactive user to select grid and solution information to be displayed using OpenGL.

MPAS_GRID_DISPLAY, MATLAB programs which can read an MPAS NETCDF grid file and display the primary polygonal mesh or the dual triangular mesh.

NETCDF, a data directory which contains examples of NETCDF files, a format for the interchange of scientific data.

NETCDF_MPAS, a data directory which contains examples of MPAS grid data stored as NETCDF files.

NETCDF_MPAS, a C++ library which reads MPAS grid data stored as NETCDF files.

SCREENSHOT_OPENGL, a C++ program which shows how a program using the OpenGL graphics library can save a screenshot of the graphics being displayed.


  1. The MPAS home page, .
  2. Russ Rew, Glenn Davis, Steve Emmerson, Harvey Davies, Ed Hartne,
    The NetCDF User's Guide,
    Unidata Program Center, March 2009.
  3. Todd Ringler, John Thuburn, Joseph Klemp, William Skamarock,
    A unified approach to energy conservation and potential vorticity dynamics for arbitrarily-structured C-grids,
    Journal of Computational Physics,
    Volume 229, Number 9, 1 May 2010, pages 3065-3090.

Source Code:

GRID_CELLS retrieves the information defining the polygonal grid cells, and displays them.

TRIANGULATION_FACES retrieves the 3 cell centers around each vertex, and draws the corresponding faces of the triangulation. The display is a triangulated sphere surface.

TRIANGULATION_LINES retrieves the pairs of cell centers that are neighbors, and draws lines to connect them. This actually creates the lines of the triangulation. The display is a triangulated sphere, but there are no areas filled in on the surface, so you can see through to the other side.

Examples and Tests:

You can go up one level to the MATLAB source codes.

Last revised on 02 January 2011.