Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

An object based fortran 2003 / 2008 interface to gnuplot developed in CBFortran

105 views
Skip to first unread message

Mohammad

unread,
Feb 8, 2012, 9:52:29 AM2/8/12
to
ogpf ((http://mfort.codeplex.com/) ) 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

plot
plot a single vector v
plot a vector y against vector x
plot up to four pairs of x-y set at the same time
plot a matrix Y versus a vector x
surf
surface plot
mesh plot
contour plot
script
meshgrid
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)

Download the source code and demo file from download area
Create a fortran project contains the ogpf.f90 and demo.f90, compile, and build it
Run the executable (output of step 2) and select the example you like to run

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

JWM

unread,
Feb 8, 2012, 12:08:57 PM2/8/12
to
On Wed, 08 Feb 2012 07:52:29 -0700, Mohammad <mohammad...@gmail.com>
wrote:
Given that bash, dash, etc., have a particular meaning for $$, and that
most implementations of a system call in a UNIX-like environment tend to
invoke a shell interpreter, the demos are doomed to fail (by default)
under Linux, Mac OS X, etc. Using a suffix other than $$$ (or enclosing
the filename in single quotes, or better yet, using a random name), fixes
the issue.

One could also make /bin/sh point to .../wine/fakedlls/cmd.exe, but
wouldn't that be weird? ;-)
--
John

Mohammad

unread,
Feb 9, 2012, 1:36:21 AM2/9/12
to
John,
The code has been tested under windows (xp, vista, 7) and it wroks fine! I had many feedbacks from windows user, indicating it works under different windows system! I have not Mac or Linux on my system to make a test! By the way, I have corrected the temporary file name!
Please let me know, if other issues are existed!

/Mohammad

JWM

unread,
Feb 9, 2012, 7:02:30 AM2/9/12
to
On Wed, 08 Feb 2012 23:36:21 -0700, Mohammad <mohammad...@gmail.com>
wrote:
Line 45 in ogpf.f90 should rather be:
! CHARACTER(LEN=*), PARAMETER :: operating_system ='linux'

Or, since you're using that variable only to delete the file, try a
system-independent method (between lines 419 and 430):

!Delete the temporary file
inquire (FILE = fileName, EXIST = fileFound)
if (fileFound) then
open (NEWUNIT = tmpUnit, FILE = fileName, ACTION = 'WRITE', STATUS
= 'OLD', IOSTAT = ios)
if (ios == 0) CLOSE (tmpUnit, STATUS = 'DELETE')
endif

Of course, the fileFound, tmpUnit and ios variables need to be properly
declared.

--
John

Richard Maine

unread,
Feb 9, 2012, 11:00:20 AM2/9/12
to
JWM <jwmw...@gmail.com> wrote:

> Or, since you're using that variable only to delete the file, try a
> system-independent method (between lines 419 and 430):
>
> !Delete the temporary file
> inquire (FILE = fileName, EXIST = fileFound)
> if (fileFound) then
> open (NEWUNIT = tmpUnit, FILE = fileName, ACTION = 'WRITE', STATUS
> = 'OLD', IOSTAT = ios)
> if (ios == 0) CLOSE (tmpUnit, STATUS = 'DELETE')
> endif

Unfortunately, that's not really system independent. It assumes that the
file in question can be opened as sequential access unformatted. It is
not necessarily so that you can open an arbitrary file that way on any
system. That is more than just an abstract possibility. I have seen
systems that would try to read at least the record header from the
initial record when opening the file. They would then get upset when the
first few bytes of the file did not look like a plausible unformatted
sequential record header for a reasonable record size.

I have had Fortran programs fail for exactly that reason, which is why
my personal library includes a delete_file subroutine in my collection
of system-dependent I/O routines. My default version of that subroutine
does things essentially identical to the above sample, but I do keep it
with my other system-dependent routines to facilitate porting in cases
where it doesn't work.

Not to speak of potential problems with permissions for opening with
action='write'. Yes, there are cases where you might have permissions to
delete a file, but not to write to it.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain

JWM

unread,
Feb 9, 2012, 12:59:09 PM2/9/12
to
On Thu, 09 Feb 2012 09:00:20 -0700, Richard Maine <nos...@see.signature>
wrote:

> JWM <jwmw...@gmail.com> wrote:
>
>> Or, since you're using that variable only to delete the file, try a
>> system-independent method (between lines 419 and 430):
>>
>> !Delete the temporary file
>> inquire (FILE = fileName, EXIST = fileFound)
>> if (fileFound) then
>> open (NEWUNIT = tmpUnit, FILE = fileName, ACTION = 'WRITE',
>> STATUS
>> = 'OLD', IOSTAT = ios)
>> if (ios == 0) CLOSE (tmpUnit, STATUS = 'DELETE')
>> endif
>
> Unfortunately, that's not really system independent. It assumes that the
> file in question can be opened as sequential access unformatted.

Shouldn't it be sequential access formatted?

In the actual source code, by the time the file needs to be deleted, it
has already been opened at least once, with no explicit ACCESS or FORM (so
it's assumed sequential formatted). That's why I didn't set the
access/form explicitly.

--
John

Richard Maine

unread,
Feb 9, 2012, 2:51:16 PM2/9/12
to
JWM <jwmw...@gmail.com> wrote:

> On Thu, 09 Feb 2012 09:00:20 -0700, Richard Maine <nos...@see.signature>
> wrote:
>
> > JWM <jwmw...@gmail.com> wrote:
> >
> >> Or, since you're using that variable only to delete the file, try a
> >> system-independent method (between lines 419 and 430):
> >>
> >> !Delete the temporary file
> >> inquire (FILE = fileName, EXIST = fileFound)
> >> if (fileFound) then
> >> open (NEWUNIT = tmpUnit, FILE = fileName, ACTION = 'WRITE',
> >> STATUS
> >> = 'OLD', IOSTAT = ios)
> >> if (ios == 0) CLOSE (tmpUnit, STATUS = 'DELETE')
> >> endif
> >
> > Unfortunately, that's not really system independent. It assumes that the
> > file in question can be opened as sequential access unformatted.
>
> Shouldn't it be sequential access formatted?

Ah, yes. Sorry. I'm used to always specifying form explicitly, so I have
to stop and think to recall the defaults; didn't stop long enough this
time. (The fact that I'd have to stop and think about the defaults is
exactly why I tend to specify explicitly).

> In the actual source code, by the time the file needs to be deleted, it
> has already been opened at least once, with no explicit ACCESS or FORM (so
> it's assumed sequential formatted). That's why I didn't set the
> access/form explicitly.

Ok. I didn't read the full file. I was just reacting to the comment
about that being system-independent and I clearly didn't look at enough
of the context.

Daniel H

unread,
Feb 14, 2012, 5:16:00 AM2/14/12
to
Mohammad,

could you post here whenever you update your module?

Thanks

Daniel

Daniel H

unread,
Jun 6, 2012, 4:03:45 AM6/6/12
to
On 02/08/2012 03:52 PM, Mohammad wrote:
> ogpf ((http://mfort.codeplex.com/) ) 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.
(snip)
>
> Download link:
> (http://mfort.codeplex.com/)

Is this still being actively developed?

Mohammad

unread,
Jan 8, 2013, 10:44:23 PM1/8/13
to
yes!
0 new messages