Why gnuplotfortran ?

I have seen people, who prefer a simple plotting system capable of enormous sophistication, use Gnuplot. I have seen people use fortran 95 for serious number crunching. What I found missing to my surprise, was something that linked the two applications. Granted that other libraries like pgplot, psplot, dislin, etc. exist, but there is something nice about the simplicity of Gnuplot which attracts so many users. Its often the first plotting tool that many of us learn and turn to when preparing figures for publications.

Gnuplot is a freely available, command-driven graphical display tool for Unix. It compiles and works quite well on a number of Unix flavours as well as other operating systems. The following module enables sending display requests to Gnuplot through simple f95 calls.

I have been a user of Fortran for a long time. And have also used Gnuplot extensively, and regard it as my primary plotting program. However, what always rankled me was the absence of a good way to make these two work together. About 6 years ago, I worked on analyzing pulsar polarization data as a summer intern at GMRT, NCRA, India. I wrote a lot of code (in C++) which generated Gnuplot scripts and then ran them. This was messy and cumbersome, but as I did not know much about how the Linux kernel works, I could not do anything about it. In January 2004, I learnt about the existence of C, C++ and Python interfaces for Gnuplot, but could not find any for f90/95 which is currently my sole programming language of work. This was an intolerable state of affairs.

I taught myself the basics of kernel IPC, and then sat down to write this code. This code has been written intermittently over the past 3 months (started 1/27, first version out 4/26, major bugfix 11/21). I first dallied with the Intel POSIX library that ships with IFC. I found the documentation a little spotty (not to mention that it does not implement popen and pclose), and also realized two big problems : licenses and usability. If I had written this interface using that library, the non-GPL'ed licenses would have possibly caused some problems later, plus people using other compilers would not have been able to make use of it. So, about 2 weeks into April 2004, I deleted the old code and started writing wrappers to the GNU C library routines and using them in the code. Then I realized that the set of wrappers could themselves solve another long standing problem in Fortran - lack of availability of many system POSIX calls ! So, that part of the code was spun off into another project - fortranposix.

Thanks to feedback on the sourceforge website and comp.lang.fortran, I found some bugs and fixed them in November, 2004. Now, it seems to work without crashes that so doomed versions 0.1 and 0.1.1.