[Gmsh] Read .msh in binary format with Fortran

Matteo Parsani parsani.matteo at gmail.com
Thu Apr 10 21:18:06 CEST 2014

Dear Developers and Users,
I am trying to read a .msh binary file in Fortran.
I am able to read the "header" like

2.2 1 8

After this portion I am getting the wrong values. I am reading the file as follows:

      ! If the casefile exists, open the mesh file and read it

      ! Read header $MeshFormat
      read(iunit) header(1:12)
      ! Read version number
      read(iunit) header(1:8)

      ! Read integer to check endianess
      read(iunit) endianess
      if(endianess .eq. 1) then
        write(*,*) 'Native endian; nothing to be done.'

      ! Read hidden blanck line
      read(iunit) header(1:1)

      ! Read header $EndMeshFormat
      read(iunit) header(1:15)

      ! Read header $Nodes
      read(iunit) header(1:7)

      ! Read number of nodes in a string and convert it to an integer
      read(iunit) header
      read(header,*) n_nodes

(node_ids(i),vx_master(1,i),vx_master(2,i),vx_master(3,i),i = 1,n_nodes)

Clearly I am doing somthing wrong. Any idea?

Thank you

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20140410/fa9e911d/attachment.html>