Hey, what's going on?

[SOLVED] Installing PGPLOT on Mandriva 2010

Posted by Syeilendra Pramuditya on November 29, 2010

I just finished the installation of PGPLOT on my UNIX machine, my operating system is Mandriva 2010. I followed the installation instruction described here.

But when I tried to run the sample code by the following command:

[user@machine pgplot] $ ./pgdemo1

I got the following error message:

./pgdemo1: error while loading shared libraries: libpgplot.so: cannot open shared object file: No such file or directory

After googling around for a while, I found the solution. So find a file named “.bashrc” in your home directory (/home/yourusername), and open it, add the following lines at the end of the file:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/pgplot
export LD_LIBRARY_PATH

In case you don’t have the .bashrc file, just create one then, and put the following lines into it:

# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/pgplot
export LD_LIBRARY_PATH

When I tried to run the sample code again:

[user@machine pgplot] $ ./pgdemo1

Graphics device/type (? to see list, default /NULL): /GIF
version=v5.2.2
state=OPEN
user=psyeilendra
now=29-Nov-2010 10:04
device=pgplot.gif
file=pgplot.gif
type=GIF
dev/type=pgplot.gif/GIF
hardcopy=YES
terminal=NO
cursor=NO
Plot dimensions (x,y; inches):      9.99,      7.99
(mm):    253.70,    202.90
%PGPLOT, Writing new GIF image as: pgplot.gif_2
%PGPLOT, Writing new GIF image as: pgplot.gif_3
%PGPLOT, Writing new GIF image as: pgplot.gif_4
%PGPLOT, Writing new GIF image as: pgplot.gif_5
%PGPLOT, Writing new GIF image as: pgplot.gif_6
%PGPLOT, Writing new GIF image as: pgplot.gif_7
%PGPLOT, Writing new GIF image as: pgplot.gif_8
%PGPLOT, Writing new GIF image as: pgplot.gif_9
%PGPLOT, Writing new GIF image as: pgplot.gif_10
%PGPLOT, Writing new GIF image as: pgplot.gif_11
%PGPLOT, Writing new GIF image as: pgplot.gif_12
%PGPLOT, Writing new GIF image as: pgplot.gif_13
%PGPLOT, Writing new GIF image as: pgplot.gif_14

It works well now, and here is one sample result, generated as a GIF image:

PGPLOT sample output

I also tried to compile a Fortran sample code:

Source code (rename to pgsample.f)

which calls some PGPLOT functions, then I compiled it by the following command:

[user@machine pgplot] $ g77 -fno-backslash -lpgplot -o pgsample.exe pgsample.f

[user@machine pgplot] $ ./pgsample.exe

It works well too, it generates a GIF image file named “pgplot.gif”:

PGPLOT sample output

A complete explanation of available PGPLOT functions can be found here.

One Response to “[SOLVED] Installing PGPLOT on Mandriva 2010”

  1. imron said

    Sebelumnya saya pernah coba pakai pgplot untuk ploting dari output fortran tp gagal..
    Akhirnya pakai gnuplot yang langsung dieksekusi dari fortran, sy pakai subroutine gnufor, alhamdulillah hasilnya memuaskan.

    Syeilendra said..
    hmm.. gnuplot ya..? mana yg lebih bagus ya..?
    btw pgplot jg bs di-embed langsung d dalam code fortran nya, jd outputnya yg langsung graphics

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: