# Coordinates from Excel to GMSH

A colleague of mine is working on a personal project, where he is manipulating some blade coordinates in excel.

He wanted some way to visualize his modifications. After some mulling we selected open source GMSH for viewing the blades.

But this brought a new problem, how to transfer the coordinates from excel to GMSH.

Since he just wanted to visualize the 3d coordinates, I wrote him this simple fortran routine that transfers the excel coordinates stored as comma separated values to GMSH points.

Here’s the fortran code to transfer coordinates from excel to gmsh.

```        MODULE gmeshGeowriter

CHARACTER(len=255) :: inputfile,outputfile
CHARACTER(len=1) :: leftCurl="{",rightCurl="}",semiColon=";"
CHARACTER(len=1) :: leftBrac="(",rightBrac=")"
TYPE points
DOUBLE PRECISION ::x,y,z
END TYPE

CONTAINS
SUBROUTINE WRITEout()
TYPE(points) pnt
INTEGER i

OPEN(unit=20,file=inputfile,status='old')
OPEN(unit=30,file=outputfile)

WRITE(30,'(a)') "lc = 0.0009;"
i=1
DO
WRITE(30,100) "Point"//leftBrac,i,rightBrac//" = "//leftCurl,pnt%x,&
&",",pnt%y,",",pnt%z,",","lc"//rightCurl//semiColon
i=i+1
END DO
20        CONTINUE
CLOSE(20)
CLOSE(30)
100       format((a6,i4,a5,3(f8.2,a1),a5))
END SUBROUTINE

END MODULE

PROGRAM test
USE gmeshGeowriter
INTEGER IARGC

noarg = IARGC()
IF(noarg .EQ. 0) THEN
WRITE(*,'(a)',advance='no')"Enter the input FILE name  : "
WRITE(*,'(a)',advance='no')"Enter the output FILE name : "

ELSE
CALL GETARG (1, inputfile)
CALL GETARG (2, outputfile)
END IF

CALL WRITEout()

END PROGRAM

```

Code can be improved to transfer connect the points as lines and then to surface. Well maybe will do this some other day.