Convert Triangulation to GMSH File

FEM_TO_GMSH is a C program which converts FEM files representing a 1D, 2D, or 3D mesh into a GMSH mesh file.

The FEM files include a node file, which simply lists the coordinates of each node, and an element connectivity file, which lists, for each element, the indices of the nodes that define it. Either 0 or 1-based indexing can be used when referencing the nodes.


fem_to_gmsh prefix
where prefix is the common filename prefix:


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


FEM_TO_GMSH is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

DOLFIN-CONVERT, a Python program which can convert mesh file from Gmsh, MEDIT, METIS or SCOTCH format to an XML format suitable for use by DOLFIN or FENICS, by Anders Logg.

FEM_TO_MEDIT, a C program which reads a pair of FEM files defining node coordinates and elements, and creates a corresponding MEDIT mesh file.

FEM_TO_TRIANGLE, a C program which reads FEM files defining a 2D mesh of triangles, namely a file of node coordinates and a file of elements defined by node indices, and creates a corresponding pair of node and element files for use by Jonathan Shewchuk's triangle program.

FEM_TO_XML, a C program which reads FEM files defining a 1D, 2D or 3D mesh, namely a file of node coordinates and a file of elements defined by node indices, and creates a corresponding XML file for input to DOLFIN or FENICS.

GMSH, examples which illustrate the use of the Gmsh program, a 3D mesh generator for the finite element method (FEM).

GMSH_IO, a C library which can read or write some of the files created by the Gmsh program for 1D, 2D or 3D meshes used by the finite element method (FEM).

GMSH_TO_FEM, a C program which reads a mesh data file created by the GMSH program and writes a pair of node and element files that correspond to the FEM format.

MSH, a data directory of examples of MSH files, the native 3D mesh format used by Gmsh.

TET_MESH, a C library which carries out various operations on tetrahedral meshes.

TRIANGULATION, a C library which performs various operations on order 3 (linear) or order 6 (quadratic) triangulations.


  1. Christophe Geuzaine, Jean-Francois Remacle,
    Gmsh: a three-dimensional finite element mesh generator with built-in pre- and post-processing facilities,
    International Journal for Numerical Methods in Engineering,
    Volume 79, Number 11, pages 1309-1331, 2009.

Source Code:

Examples and Tests:

CHEBY9 is a 1D interval, [-1,+1], containing 9 nodes and 8 elements.

MESH3D is a 3D tetrahedral mesh using 8 nodes and 6 elements.

RECTANGLE is a 2D rectangular region which has been divided into 3 rows and 4 columns of squares, each then split into two 3-node triangles. The node and element files of this triangulation are converted into a Gmsh msh file describing the same triangulation.

List of Routines:

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

Last revised on 06 October 2014.