a FORTRAN90 code which
reads and writes files used by the FreeFem++ finite element code
to store mesh information.
Note that the GMSH code creates mesh files that use the ".msh"
extension, but which are an entirely different format.
The msh file format is obliquely described in section 12.5 of the
At least for the 2D case of a triangular mesh, the format seems
to be as follows:
The "labels" seem to be "0" for interior objects and 1 for boundary objects.
All edges are boundary objects. (This might not be true. A geometry
might include internal edges, and perhaps these count as interior objects,
but definitely, the edge list does not include arbitrary triangle edges,
only those on the boundary.) All triangles are interior objects.
Vertices may be boundary or interior objects.
a single line giving NV, NE, NT, the number of vertices, boundary edges, and triangles
NV lines, each containing the (X,Y) coordinates and integer label for a node.
NT lines, each containing three vertex indices and integer label for a triangle.
NE lines, each containing two vertex indices and integer label for a boundary edge.
The computer code and data files made available on this
web page are distributed under
the GNU LGPL license.
freefem_msh_io is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version and
a Python version.
Related Data and codes:
a data directory which
contains examples of the mesh files created by the FreeFem++ code,
which use the extension ".msh".
New development in FreeFem++,
Journal of Numerical Mathematics,
Volume 20, Number 3-4, 2012, pages 251-265.
BAMG: Bidimensional Anisotropic Mesh Generator,
draft version v1.00, December 2006.
Last revised on 27 October 2020.