Thursday, September 3, 2015

Plotting From Fortran

Fortran does not automatically allow for plotting during execution.  There is a work around.  I touched on this with my previous post about plotting with gnuplot from python.  The same principles apply here.

From fortran call gnuplot.  For instance, to make a vector plot from fortran use the command

call system('gnuplot Vector.gp')

where Vector.gp is the gnuplot setup file for vector plotting.

This also requires a datafile that gnuplot can read.  I prefer a csv file because I can put that directly into other programs like excel as well.

So what I've done, is built an IO module with several subfunctions that will create a datafile for gnuplot and call the system for me.  More plot types are on the way.  See attached for details.

example scatter plot colored by the vorticity:
call cScatter(x,y,omegaz)

Fortran-GnuPlot Plotting.zip

By the way, I've switched to Atom text editor by github for my programming.  The .gp files I included save as .png files so I can use them with both word and latex.  Atom will open .png directly inside the editor and update as the figure updates.  This is approaching an IDE and it's a lot faster to update the figure than with Windows Image Viewer.  It should be a cross-platform solution too.

No comments: