A fortran 2003 / 2008 interface to gnuplot developed in CBFortran

568 views
Skip to first unread message

Mohammad

unread,
Feb 8, 2012, 9:53:31 AM2/8/12
to cbfo...@googlegroups.com

ogpf :

ogpf is an object based module developed in Fortran 2003 / 2008 with object-oriented concept. It implements an interface to 2D/3D plotting in gnuplot.
The syntax ensembles the plot and surf commands in Matlab and Octave. There are some helper functions like linspace, and meshgrid to facilitate the plotting procedure.

There are these main procedures in ogpf
  1. plot
    1. plot a single vector v
    2. plot a vector y against vector x
    3. plot up to four pairs of x-y set at the same time
    4. plot a matrix Y versus a vector x
  2. surf
    1. surface plot
    2. mesh plot
    3. contour plot
  3. script
  4. meshgrid
  5. linspace

ogpf implements the interface through an object called gpf. It contains many methods and properties for making publication quality plots using gnuplot.

script method
The script method is a powerful procedure accepts almost any gnuplot valid command and create a script file to be executed by gnuplot.

interactive mode
It is possible to run the gnuplot interactively from fortran.

Save to file
There is an option, to save the ogpf output into a file which can be invoked later from gnuplot.

How to use

Requirements
- A fortran compiler supports Fortran 2003, like gfortran 4.7 (http://gcc.gnu.org/GFortran), other Fortran compilers also can be used.
- gnuplot 4.5 and later (http://gnuplot.info)
Make sure gnuplot is in your path. (Open a command window and type gnuplot to see if it is in your path)
  1. Download the source code and demo file from download area
  2. Create a fortran project contains the ogpf.f90 and demo.f90, compile, and build it
  3. Run the executable (output of step 2) and select the example you like to run

Download link:

(http://mfort.codeplex.com/)

Walt Brainerd

unread,
Feb 8, 2012, 5:42:26 PM2/8/12
to cbfo...@googlegroups.com
This looks like great stuff! Thanks Mohammad.
 
I did as directed. I had two small problems compiling.
 
First, there is an illegal comma after the parentheses in two WRITE
statements (maybe this works on some systems, but gfortran didn't
like them). ogpf.f90, lines 404 and 410 ??? or somewhere around there.
Any compiler should work without them (standard).
 
Also my gfortran doesn't seem to like "CALL SYSTEM", although it says
it is OK (maybe my options are not set right for that). Anyway
CALL EXECUTE_COMMAND_LINE works instead and has the advantage
of being standard Fortran (system is not). Unfortunately, it appears that
Intel has not yet implemented it.
 
The samples I tried appear to work and I just have gnuplot 4.4 installed.

--
Walt Brainerd

Mohammad

unread,
Feb 9, 2012, 1:30:37 AM2/9/12
to cbfo...@googlegroups.com
Walt,
 Thank you very much for your feedback!
  1. I corrected the illegal commas on lines 404, and 410. (Strangely gfortran 4.7 does not complain)
  2. For system call, yes you are right, but as you have mentioned, unfortunately some commercial compilers like Intel does not support
    CALL EXECUTE_COMMAND_LINE, by the way I add this with a comment to user
  3. gnuplot 4.4 should work. In ogpf, by default the terminal has been set to 'wxt', if you change it to for example 'windows' or  'png', other previous versions of gnuplot can be used.
  4. I upload the corrected version by today!

Thank you again Walt!

/Mohammad

Mayank Khichar

unread,
Nov 21, 2017, 6:48:56 PM11/21/17
to CBFortran
Mohammad,

First of all thank you very much for developing ogpf module. It certainly has great use for a wide range of fortran users.

Unfortunately, I am facing a problem. I tried compiling demo.f90 with the 2 modules provided by you at http://mfort.codeplex.com/, when I tried to execute the program it did create the temp file "ogpf_temp_script_file.plt" but it was completely empty. Instead the gnuplot commands were written in an error file "fort.2". The name of this error file varies every time I execute the program. Can you please suggest me what I am doing wrong here. I did change the terminal to "x11".

Additional info:

1. OS :: Linux
2. gnuplot :: Version 4.2 patchlevel 6
3. gfortran :: GNU Fortran (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
4. If I copy-paste the commands in fort.2 to a termial with gnuplot pre-loaded, it does create the required plot.

I appreciate your time. Thanks in advance.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages