LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Pgplot (https://www.linuxquestions.org/questions/linux-software-2/pgplot-383433/)

mghuffman 11-15-2005 02:25 PM

Pgplot
 
Has anyone out there installed PGPLOT distribution on Redhat WS 3.0 ?

MG HUffman

Let me re-phrase:

Has anyone out there successfully installed PGPLOT on ANY Linux System
using the GCC compiler collection? I think I am missing some C header files.
Help !!!

MG Huffman

eddy__luo 11-30-2007 11:04 AM

Intstall pgplot
 
PGplot is a Fortran Library (it means you need to write a program and link to this library, unless one use WIP) and has long history, it is very suitable for plot 2D graphic with additional labels, symbols, arrow, etc. It can be called by C and other languages, and it can install on many systems, some systems (for example SuSE 10.3, MacOSX Tiger )use the new gcc4.0 compiler, so use "gfortran" replace "g77". If you like C may be can refer to plplot.
# Install PGplot
## MacOSX
### Fink
INSTALL FINK
fink selfupdate
fink update-all
fink install pgplot
### Macport
INSTALL Macport
sudo port selfupdate
sudo port upgrade outdated
sudo port install pgplot
## Linux ubuntu (debian)
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install pgplot
## Linux g77
1/ Get the source tar file from http://astro.caltech.edu/~tjp/pgplot/


2/ Execute the following, as super-user (su) :

cp pgplot5.2.tar.gz /usr/local/src

cd /usr/local/src # directory for the sources

tar -zxvf pgplot5.2.tar.gz

cd pgplot

mkdir /usr/local/pgplot # create the directory for the binaries and font files

cd !$

cp /usr/local/src/pgplot/drivers.list .

emacs (or vi) drivers.list & # select (by removing the ! sign) the drivers to be
# used for pgplot outputs: typically:
# PNDRIV 1,2 : PNG figures (requires that the
# package libpng3-devel or an equivalent one is
# installed on your system)
# PSDRIV 1,2,3,4 : EPS figures
# XWDRIV 1,2 : X-window output (requires that the
# package libxorg-x11-devel or an equivalent one
# is installed on your system)

# ----- Optional part : to increase the number of simultaneous devices -------
# from 8 to 32
/usr/local/src/pgplot/makemake /usr/local/src/pgplot linux g77_gcc
make
make clean
make cpg

vi ~/.bashrc
# if bash shell:
PGPLOT_DIR=/usr/local/pgplot/
export PGPLOT_DIR
PGPLOT_DEV=/xwin # prefered output device, an alternative is /xserve
export PGPLOT_DEV

cd /usr/local/pgplot

./pgdemo1
/xw(should be default)
/PS
/GIF
================================================================
## Linux gfortran
2/ Execute the following, as super-user (su) :

cp pgplot5.2.tar.gz /usr/local/src

cd /usr/local/src # directory for the sources

tar -zxvf pgplot5.2.tar.gz

cd pgplot

mkdir /usr/local/pgplot # create the directory for the binaries and font files

cd !$

cp /usr/local/src/pgplot/drivers.list .

emacs (or vi) drivers.list & # select (by removing the ! sign) the drivers to be
# used for pgplot outputs: typically:
# PNDRIV 1,2 : PNG figures (requires that the
# package libpng3-devel or an equivalent one is
# installed on your system)
# PSDRIV 1,2,3,4 : EPS figures
# XWDRIV 1,2 : X-window output (requires that the
# package libxorg-x11-devel or an equivalent one
# is installed on your system)

# ----- Optional part : to increase the number of simultaneous devices -------
# from 8 to 32

cd /usr/local/src/pgplot/src

cp grpckg1.inc grpckg1.inc_backup # to keep a copy of the original source file
cp pgplot.inc pgplot.inc_backup #

emacs (or vi) grpckg1.inc & # Replace " PARAMETER (GRIMAX = 8) " in line 29
# by " PARAMETER (GRIMAX = 32) "

emacs (or vi) pgplot.inc & # Replace " PARAMETER (PGMAXD=8) " in line 7
# by " PARAMETER (PGMAXD=32) "

cd /usr/local/pgplot

# ---------------------- End of optional part ---------------------------------

/usr/local/src/pgplot/makemake /usr/local/src/pgplot linux g77_gcc # prepares
# the makefile for linux system + gcc compiler

# ---------------- Special treatment for gcc 4.0 (or above) ------------------
#
# If you are using the gcc 4.0 (or above) compilers (i.e. gfortran instead
# of g77), perform the following:

emacs(or vi) makefile & # Replace "FCOMPL=g77" in line 25
# by "FCOMPL=gfortran"
#
# Replace "FFLAGC=-u -Wall -fPIC -O" in line 26
# by "FFLAGC=-ffixed-form -ffixed-line-length-none -u -Wall -fPIC -O"

# ---------------- End of special treatment for gcc 4.0 ----------------------

emacs (or vi) makefile & # Go to line 880 and replace
# "pndriv.o : ./png.h ./pngconf.h ./zlib.h ./zconf.h"
# by "pndriv.o : "

make # compiles the Fortran part

make cpg # compiles the C part (binding to Fortran)

emacs (or vi) /usr/local/src/pgplot/makehtml & # this file needs to be edited to
# replace the first line by
# #!/usr/bin/perl
make pgplot.html # produces the html documentation

make clean

cd /usr/local/lib # libraries for local installations

ln -s /usr/local/pgplot/libpgplot.a libpgplot.a # F77 static library

ln -s /usr/local/pgplot/libcpgplot.a libcpgplot.a # C static library

cp /usr/local/pgplot/libpgplot.so . # dynamic (runtine) library

emacs /etc/ld.so.conf & # edit this file to add the line /usr/local/lib

/sbin/ldconfig -v # updates the path for runtime libraries

ln -s /usr/local/pgplot/cpgplot.h /usr/local/include/cpgplot.h


3/ Each end user should type (or put in his .bashrc or .tcshrc file):

# if csh or tcsh shells:
setenv PGPLOT_DIR /usr/local/pgplot/
setenv PGPLOT_DEV /xwin # prefered output device, an alternative is /xserve

# if bash shell:
PGPLOT_DIR=/usr/local/pgplot/
export PGPLOT_DIR
PGPLOT_DEV=/xwin # prefered output device, an alternative is /xserve
export PGPLOT_DEV

cd /usr/local/pgplot

./pgdemo1 # it should work !
============================================================
It also can be install on openbsd, opensolar-x86 netbsd

mghuffman 12-01-2007 08:46 AM

Eddy:

Thank you so much for your help. There was MUCH more info in your post than I had before.
I will try it soon. I am relatively new to LINUX and still have much to learn.

Thanks again.


mghuffman

eddy__luo 12-06-2007 10:33 AM

mghuffman:
You are welcom!
:)
But I think I forgot something:

(1)If you don't want to change /etc/ld.so.conf
(or you don't have permission to etdi it)
you should edit your ~/.bashrc like this:
----------------------------------------------------------------
#PGplot
PGPLOT_DIR="/usr/local/pgplot/"; export PGPLOT_DIR
export LD_LIBRARY_PATH=/usr/local/pgplot/:${LD_LIBRARY_PATH}
PGPLOT_DEV="/xwin"; export PGPLOT_DEV
#PLplot
export PATH=/usr/local/plplot/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/plplot/lib/:${LD_LIBRARY_PATH}
-------------------------------------------------------------------
It can install on your #HOME/pgplot not /usr/local/pgplot
(2)
About the Makefile of your own program (for example pgdemo1.f):
---------------------------------------------------------------------
# Makefile for pgdemo1
# PGPLOT
# RedHat (Fedora Core 7)
FCOMPL=g77
FFLAGD=-fno-backslash
FFLAGC=-u -Wall -fPIC -O
LIBS=-L/usr/X11R6/lib -lX11
PGPLOT_LIB= -lpgplot -lpng -lz -lm
pgdemo1: pgdemo1.f
$(FCOMPL) $(FFLAGD) -o pgdemo1 pgdemo1.f $(PGPLOT_LIB) $(LIBS)

clean:
rm -f pgdemo1
---------------------------------------------------------------------

Type make -> produce pgdemo1
execute type
./pgdemo1
(pgdemo1.f can be found in /usr/local/src/pgplot/examples/ )
if you want to use C to call, you need "CPGPLOT_LIB", usually it is
CPGPLOT_LIB = -L/usr/local/pgplot -lcpgplot
Makefile for other system will be a little different, you can modify by the makefile in /usr/local/pgplot anyway, don't worry.
# MacOSX (Macport)
FCOMPL=g77-dp-3.4
PGPLOT_LIB=-L/opt/local/lib -lpgplot -lpng -lz
CPGPLOT_LIB=-L/opt/local/lib -lcpgplot
LIBS=-L/usr/X11R6/lib -lx11 -L/opt/local/lib -laquaterm -Wl,-framework -Wl,Foundation

#OpenSolaris x86
X11BASE=/usr/openwin
PGPLOT_LIB = -L/usr/local/pgplot -lpgplot
CPGPLOT_LIB = -L/usr/local/pgplot -lcpgplot
LIBS= -L${X11BASE}/lib -lX11 -lm
-----------------------------------
Eddy

mghuffman 12-06-2007 11:36 AM

Pgplot
 
Eddy:

Thank you again for the time you are taking to help me with this. I think your last post may solve my problem. When I tried to install according to the instructions supplied with the documentation, all of the subroutines compiled and generated .obj files but linking failed. It appeared that the compiler was looking for a header file I did not have.

I am so new to Linux that I have barely scratched the surface of its potential. I have Redhat 4.0 and 5.0 but have not installed them. I am currrently working on a project which is absorbing ALL my time, but in a week or so I will try to install PGPLOT using your suggestions.

I REALLY appreciate your taking the time to help me with this.

Mike Huffman

eddy__luo 12-10-2007 06:20 AM

About PGplot
 
Hi! Mike:
I apply a blog for "Data Visualization". I decided to put what I know (only a little, of course) about what I learn during the past few years, the packages I learn including "PGplot, Plplot, GNUplot, PlotMTV, OpenDX, Vis5d+", and now I learn "Mayavi".
I will put them on the website:
http://mypaper.pchome.com.tw/news/yylo/

I hope it can be a little help for you.

Eddy

vanKampen92 12-11-2007 09:03 AM

Hi, Eddy,

Thank for all these hinds... I have also had a look at your web page. It it wonderful. I am also considering to lear PLplot because I am a C programmer... but I would like to know why pgplot does not seem to work in my system:

You said:

## Linux ubuntu (debian)
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install pgplot

I am using Linux Ubuntu 7.10. Actually, I used synaptic which is equivalent to the command line stuff you said ---isn't it?.

In order to check whether I would be able to modify an example, compile and link it and make it work, I took
cpgdemo.c as it is, and compiled with gcc and linkded with gfortran rather than:

/* ---------------------------------------------------------------------
* Demonstration program for PGPLOT called from C.
* (Note that conventions for calling Fortran from C and C from FORTRAN
* are system-dependent).
* Usage:
* cc -c cpgdemo.c
* f77 -o cpgdemo cpgdemo.o -lcpgplot -lpgplot -lX11
*----------------------------------------------------------------------
*/

So, I did:
~$ gcc -c cpgdemo.c
~$ gfortran -o cpgdemo cpgdemo.o -lcpgplot -lpgplot -lX11

I turned out that I was unable to build the cpgdemo binary to execute
the program. I got linkage errors:

/usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/libfrtbegin.a(frtbegin.o): In function `main':
(.text+0x35): undefined reference to `MAIN__'
/usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/libpgplot.so: undefined reference to `png_set_PLTE'
/usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/libpgplot.so: undefined reference to `png_init_io'
/usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/libpgplot.so: undefined reference to `png_set_text'
/usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/libpgplot.so: undefined reference to `png_set_tRNS'
/usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/libpgplot.so: undefined reference to `png_create_info_struct'
/usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/libpgplot.so: undefined reference to `png_write_info'
/usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/libpgplot.so: undefined reference to `png_create_write_struct'
/usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/libpgplot.so: undefined reference to `png_set_IHDR'
/usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/libpgplot.so: undefined reference to `png_write_end'
/usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/libpgplot.so: undefined reference to `png_write_row'
/usr/lib/gcc/i486-linux-gnu/3.4.6/../../../../lib/libpgplot.so: undefined reference to `png_destroy_write_struct'
collect2: ld returned 1 exit status

Does it mean that pgplot5 (the one provided by Ubuntu) does not work out of the box Linux Unbuntu 7.10?
Are you able to check that?
Any idea?
Am I doing something very wrong?

I have posted also question in Ubuntu forum saying that pgplot5 does not work out the box. Perphaps I am wrong...

Thank you for your help,
David.

eddy__luo 12-11-2007 12:45 PM

PGplot ubuntu problem
 
Hi! David:
Thanks.
Yes, I also use synaptic for ubuntu (just because it is graphic interface, can not do copy by mouse ). I did not try my ubuntu 7.01 yet, now I am upgrading gentoo...It takes a long time.
But I looks the messages:
it has the form of
undefined reference to `png_set_PLTE'

How about try:
#sudo apt-get install libx11-dev

first, maybe it will work.

Eddy

eddy__luo 12-11-2007 10:30 PM

Pgplot ubuntu
 
Hi! David:
I install ubuntu 7.10 (suprise! quite fast, very good system) and I found your problem can be fixed by install libpng-dev and also need to modify the makefile:
I should write more clear:
install pgplot for ubuntu 7.10
sudo apt-get install libx11-dev libpng-dev g77 pgplot
and the Makefile sould write as follow:

# Makefile for C call pgplot
# PGPLOT (Linux ubuntu 7.10).
#-----------------------------------------------------------------------
#
FCOMPL=g77
#FCOMPL=gfortran #also OK
CCOMPL=gcc
FFLAGD=-fno-backslash
FFLAGC=-ffixed-form -ffixed-line-length-none -u -Wall -fPIC -O
CFLAGC=-Wall -fPIC -DPG_PPU -O -I.
CFLAGD=-Wall -O
LIBS=-L/usr/lib -lX11
PGPLOT_LIB=-L/usr/lib -lpgplot -L/usr/lib -lpng
CPGPLOT_LIB=-L/usr/lib -lcpgplot -lpgplot -L/usr/lib -lpng
cpgdemo: cpgdemo.c
$(CCOMPL) $(CFLAGD) -c cpgdemo.c
$(FCOMPL) -o cpgdemo cpgdemo.o $(CPGPLOT_LIB) $(LIBS)
#-----------------------------------------------------------------------
clean:
rm -rf cpgdemo *.o


the message show is lack "png" library,
for debian or redhat system it usually relate to xxx-dev
it contains include and lib for this kind of bin

Eddy

vanKampen92 12-12-2007 08:29 AM

Thanks so much, Eddy!!

Your help solved all my problems. You answered very fast too, however in the mean time I followed your general directions to install pgplot in a linux system (in /urs/local/pgplot and so on) from source... and it worked really fine!

I was curious about Ubuntu installation and actually tried what you said in my old laptop (Linux Ubuntu Release 7.04) and again it worked fine, but as you recommended, I had to install the png dev library first (the other one it was already there).

To build a cpgplot program, I had to modify a little bit the makefile you wrote. During the copy-paste process something went wrong I guess.
This is what I have now:

# Produced by Eddy Luo Dec 2007
# Makefile for C call pgplot
# # PGPLOT (Linux ubuntu 7.10).
# #-----------------------------------------------------------------------
# #
# #FCOMPL=g77
FCOMPL=gfortran#also OK
CCOMPL=gcc#
FFLAGD=-fno-backslash
FFLAGC=-ffixed-form -ffixed-line-length-none -u -Wall -fPIC -O
CFLAGC=-Wall -fPIC -DPG_PPU -O -I
CFLAGD=-Wall -O
LIBS=-L/usr/lib -lX11
PGPLOT_LIB=-L/usr/lib -lpgplot -L/usr/lib -lpng
CPGPLOT_LIB=-L/usr/lib -lcpgplot -lpgplot -L/usr/lib -lpng
# #
# #
cpgdemo: cpgdemo.o
$(FCOMPL) -o cpgdemo cpgdemo.o $(CPGPLOT_LIB) $(LIBS)
# #
# #
cpgdemo.o: cpgdemo.c
$(CCOMPL) $(CFLAGD) -c cpgdemo.c
# #-----------------------------------------------------------------------
clean:
rm -rf cpgdemo *.o
# #

Now I can start modifying this demo to plot other things!!

I have only a question. You have worked and compared capabilities of pgplot and plplot. Which of them do you like the best and why?

I will recommend to visit this page (and also your web site) in Ubuntu forums for problem I had with pgplot "out of the box" intallation.

Thank you again,

david.

eddy__luo 12-13-2007 02:12 AM

Hi! David:

I think we should help each other, base on the aim of Linux.
I am not a program analyst, I learn those packages, only because I have to, for example, Pgplot is a ploting interface of "NEMO
(http://bima.astro.umd.edu/nemo/)". Even I am glad I can do a little help, please correcting the mistake I done, if I made.

>> My answer is fast...that is said, I almost sit in front of computer beside sleep and eat, i have to work hard... :(
About the the difference between pgplot and plplot, as I mention before, I am not a program analyst, I can only tell from my shallow experience.
1. Conveniences for bash shell script control:
plplot [win]
device=${DEVICE:-psc}
./plplot_prog -dev $device -o whatyouwant.ps > check.log
pgplot
./pgplot_prog < /CPS
mv pgplot.ps whatyouwant.ps
2. Conveniences for 3D plot.
plplot [win]
can use PDL::Graphics::PLplot;
pgplot
can not
Usually, we will not use both of them for 3D time series graph/movie.
3. Conveniences for installtion
plplot [win]
rpm (Fedora, mandriva)
deb (ubuntu)
port (NetBSD, OpenBSD)
pgplot
for linux, only gentoo, ubuntu has the package
usually, gentoo compile from source, it make no difference from by your own hand
install for gfortran is not very easy
4. Quality:
almost the same, I think.

eddy

mghuffman 12-13-2007 03:00 PM

Pgplot
 
Eddy:

Thanks again for the addtional information. Your correspondence with others interested in PGPLOT has helped me also. I am looking forward to trying to install it again as soon as I am finished with the project I am working on. I may wait until I have installed the Redhat 5.0 with the latest GNU compiler packages.

Thank you agin.

Mike

vanKampen92 12-17-2007 05:27 AM

Hi Eddy,

Thank you for your last email... quite illustrative again. Yes... you are right. We should help each other. I like linux filosophy very much.

From what I see be comparing web sites, I think PLPLOT is quite a bigger project, with higher expectations and aspirations, which is still in constant development. There are mailing lists and so on... and, although it is interesting to know something about PGPLOT, in particular, it you use other software based on it, for a beginner like me it may be worth to start working with PLPLOT.

What I am interested in is to be to call PLPLOT from my calculations in C just to plot some intermediate results on the fly. I have achieved this pretty easily with PGPLOT. I can now "pgplot" 1000 intermediate graphs... in a kind of animated manner. This is pretty cool, but now I wanted to compare performances... specially because it seems that you cannot build the program that makes these pgplots by using the compiler option "-static"... so I cannot run it in machines where PGPLOT is not installed.

My problem now is that, after installing PLPLOT by using synaptic, I don't really know how to make PLPLOT actually work. Do I still have to the configure, cmake, make install procedure? I don't think so, because this is what Synaptic is supposed to do for you, isn't it?

In the directory where you find the c/examples, you find the sources for some demos and a Makefile file where you can read:

###
### Process this file with configure to produce Makefile.examples
###

I have tried to process it with

/usr/share/libtool/libltdl/configure

So I do

## usr/share/doc/libplplot9/examples/c$ sudo /usr/share/libtool/libltdl/configure Makefile

After passing some checks, I got this error which I don't know how to solve:

configure: error: /bin/bash /usr/share/libtool/libltdl/./config.sub Makefile failed

Do you have any idea?

David.

eddy__luo 12-17-2007 08:55 PM

Hi! David:
I think ubuntu expect one use PLplot/PGplot by means of Perl directly, but people like me not only want to plot, but also need to do something that only C can do...
After install plplot by synaptic, It should work, you don't need to to cmake etc, the only thing you need is an example:
/* simple.c an example for test plplot */
#include "plcdemos.h"
#include "plevent.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
/* Variables and data arrays used by plot generators */
static PLFLT x[101], y[101];
static PLFLT xscale, yscale, xoff, yoff, xs[6], ys[6];
/* Function prototypes */
void plot1(void);
int
main(int argc, char *argv[])
{
/* Parse and process command line arguments */
plparseopts(&argc, argv, PL_PARSE_FULL);

/* Initialize plplot */
plinit();
/* Set up the data */
xscale = 6.;
yscale = 1.;
xoff = 0.;
yoff = 0.;
plot1();
plend();
exit(0);
}

/* =============================================================== */

void
plot1(void)
{
int i;
PLINT st;
PLFLT xmin, xmax, ymin, ymax;

for (i = 0; i < 60; i++) {
x[i] = xoff + xscale * (i + 1) / 60.0;
y[i] = yoff + yscale * pow(x[i], 2.);
}

xmin = x[0];
xmax = x[59];
ymin = y[0];
ymax = y[59];

for (i = 0; i < 6; i++) {
xs[i] = x[i * 10 + 3];
ys[i] = y[i * 10 + 3];
}

plenv(xmin, xmax, ymin, ymax, 0, 0);
pllab("(x)", "(y)", "#frPLplot Example 1 - y=x#u2");

plpoin(6, xs, ys, 9);

plline(60, x, y);
}

/* =============================================================== */
and its Makefile:
# Makefile for simple (PLplot)
CC = /usr/bin/gcc
EXEEXT =

LIB_TAG = d
PKG_CONFIG_ENV = PKG_CONFIG_PATH=/usr/local/plplot/lib/pkgconfig
RPATHCMD = -Wl,-rpath -Wl,/usr/local/plplot/lib:/usr/lib
EXECUTABLES_list = \
simple$(EXEEXT)

all: $(EXECUTABLES_list)

clean:
rm -f $(EXECUTABLES_list)
.c$(EXEEXT):
$(CC) $< -o $@ $(RPATHCMD) `$(PKG_CONFIG_ENV) pkg-config --cflags --libs plplot$(LIB_TAG)`
# $(CC) $< -o $@ `plplot-config --cflags --libs`

.SUFFIXES: .c $(EXEEXT)
# end of Makefile
Also you can write a very simple bash script:
#!/bin/bash
# plot.sh (plplot for simple)
#device=${DEVICE:-psc}
device=${DEVICE:-xw}
#./simple -dev $device -o simple.ps > log
./simple -dev $device
#end

vanKampen92 12-27-2007 06:26 AM

Thanks, Eddy,

Thank you for your makefile... I modified it a little bit, but it worked fine and now PLPLOT works fine in my computer too!!

The compiler option -static does not work either, but I have seen that PLPLOT devotes a section to show how to build an PLPLOT based application and compile it in a way other can use even if they have not installed the library. I have to take a look at that.

Happy New Year 2008!!
David.


All times are GMT -5. The time now is 08:36 PM.