大脸猫爱吃鱼

Centos7安装pgplot

字数统计: 1.1k阅读时长: 6 min
2018/12/16 Share

pgplot安装还是有点麻烦的,本文只作为我的CentOS 7 安装说明,Ubuntu教程很多。
本文参考:
http://www.lorene.obspm.fr/pgplot_quick.txt

  	//------------------------------//
  //  PGPLOT quick installation   //
  // 	on a Linux computer	//
  //------------------------------//

0/ Make sure the devel package for X11 library is installed on your computer.
For instance, on a Mandriva 2010 Spring Linux distribution, it is the package libx11_6-devel; on Ubuntu 7.10, it is libx11-dev.

1/ Get the PGPLOT 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 drivers.list & # select (by removing the ! sign) the drivers to be
# used for pgplot outputs: typically:
# 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 grpckg1.inc & # Replace " PARAMETER (GRIMAX = 8) " in line 29
# by " PARAMETER (GRIMAX = 32) "

emacs 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.* ------------------

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

emacs 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.* ----------------------

make # compiles the Fortran part

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

emacs /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 !

基本上CentOS上安装就是这样的流程。
1.从网址http://astro.caltech.edu/~tjp/pgplot/下载pgplot

1
wget ftp://ftp.astro.caltech.edu/pub/pgplot/pgplot5.2.tar.gz

2.移动.gz文件到/usr/local/src文件夹下解压,并且在/usr/local/下建立文件夹pgplot,并且cd进此文件夹,这个是安装文件夹。

1
2
3
4
sudo mv pgplot5.2.tar.gz /usr/local/src/
sudo tar -zxvf pgplot5.2.tar.gz
sudo mkdir /usr/local/pgplot/
cd /usr/local/pgplot/

3.移动drivers.list,并编辑此文件

1
2
sudo cp /usr/local/src/pgplot/drivers.list .
sudo vi drivers.list

4.确认X11已经安装

1
2
sudo yum install libX11 libX11-devel
sudo yum install xorg-x11-drivers.x86_64

5.------- Optional part : to increase the number of simultaneous devices from 8 to 32 -------
这一步我也没有研究过

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

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

emacs pgplot.inc & # Replace " PARAMETER (PGMAXD=8) " in line 7
# by " PARAMETER (PGMAXD=32) "
修改文件grpckg1.inc第29行的8为32,文件pgplot.inc第7行的8为32

1
2
3
4
5
cd /usr/local/src/pgplot/src
sudo cp grpckg1.inc grpckg1.inc.backup
sudo cp pgplot.inc pgplot.inc.backup
sudo vim grpckg1.inc
sudo vim pgplot.inc

6.编译安装

1
2
cd /usr/local/pgplot/
sudo /usr/local/src/pgplot/makemake /usr/local/src/pgplot linux g77_gcc

执行完毕之后会出现如下的文件

drivers.list grexec.f grpckg1.inc makefile pgplot.inc rgb.txt
修改makefie第25行的FCOMPL=g77为FCOMPL=gfortran以及26行的FFLAGC=-u -Wall -fPIC -O为FFLAGC=-ffixed-form -ffixed-line-length-none -u -Wall -fPIC -O

1
2
3
4
sudo make
sudo make cpg
sudo vim /usr/local/src/pgplot/makehtml
make pgplot.html

将html第一行改为

1
7.建立库链接

cd /usr/local/lib
ln -s /usr/local/pgplot/libpgplot.a libpgplot.a
ln -s /usr/local/pgplot/libcpgplot.a libcpgplot.a
cp /usr/local/pgplot/libpgplot.so .
sudo vim /etc/ld.so.conf
sudo /sbin/ldconfig -v
ln -s /usr/local/pgplot/cpgplot.h /usr/local/include/cpgplot.h

1
2
在/etc/ld.so.conf文件中加入/usr/local/lib
8.最后需要在每个用户的.bash_profile中加入pgplot相关PGPLOT_DIR=/usr/local/pgplot/

PGPLOT_FONT=/usr/local/pgplot/grfont.dat
PGPLOT_DEV=/xwin
PGPLOT_LIB="-L /usr/X11R6/lib -lX11 -L /usr/local/pgplot/ -lpgplot"

export PGPLOT_DIR
export PGPLOT_FONT
export PGPLOT_DEV
export PGPLOT_LIB

1
安装结束,可以在安装目录下运行pgdemo来测试是否可以运行

source /home/m/.bash_profile
cd /usr/local/pgplot
./pgdemo1

这是在拥有root权限下安装,假如没有权限,可以参考文章<u>http://blog.csdn.net/sinat_34850075/article/details/52434526</u>
这个只是参考文献,假如需要安装还是需要参考readme文件来进行安装。
CATALOG