Software Installation for Pulsar Data Analysis


1. Ubuntu Linux (64-bit)

This guide takes you through the necessary steps required to install software for pulsar data analysis on a machine running Ubuntu Linux. These notes are based on installation onto a fresh install of Ubuntu 14.04 LTS on a 64-bit machine. Please note that for installation to be successful, the software should be installed in the order described on this page.

2. Installation

2.1 Define some environmental variables

# Path to the pulsar software installation directory e.g:
export ASTROSOFT=/home/{user}/pulsar_software

# OSTYPE
export OSTYPE=linux

# BOOST
export BOOST_ROOT=$ASTROSOFT/boost_1_68_0
export BOOST_LIB=$BOOST_ROOT/stage/lib

# PSRCAT
export PSRCAT_RUNDIR=$ASTROSOFT/psrcat_tar
export PSRCAT_FILE=$ASTROSOFT/psrcat_tar/psrcat.db

# Tempo
export TEMPO=$ASTROSOFT/tempo

# Tempo2
export TEMPO2=$ASTROSOFT/tempo2/T2runtime

# PGPLOT
export PGPLOT_DIR=$ASTROSOFT/pgplot_build
export PGPLOT_DEV=/xwindow
export PGPLOT_FONT=$ASTROSOFT/pgplot_build/grfont.dat

# PRESTO
export PRESTO=$ASTROSOFT/presto

# MULTINEST
export MULTINEST_DIR=$ASTROSOFT/TempoNest/MultiNest

# LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/lib:/usr/lib/x86_64-linux-gnu:$PGPLOT_DIR:$ASTROSOFT/lib:$PRESTO/lib:$PRESTO/lib64:$MULTINEST_DIR

# PATH
# Some Presto executables match sigproc executables so keep separate -
# all other executables are found in $ASTROSOFT/bin
export PATH=$PATH:$ASTROSOFT/bin:$PRESTO/bin:$PGPLOT_DIR

# PYTHON PATH eg.
export PYTHONPATH=$PRESTO/lib/python:$PRESTO/lib64/python:/usr/lib/python2.7/site-packages/:/usr/lib64/python2.7/site-packages:$ASTROSOFT/lib/python2.7/site-packages

Then reload your .bashrc file and check changes are taken up:

$ source ~/.bashrc
$ echo $ASTROSOFT

2.2 Install some dependencies

sudo apt-get install ftp wget csh build-essential gfortran  cvs autoconf automake libtool m4 git gsl-bin libgsl-dev flex bison fort77 libglib2.0-dev gnuplot gnuplot-x11 python-dev python-numpy python-scipy python-matplotlib ipython python-sympy python-nose swig libltdl-dev libltdl7 dkms htop screen xterm emacs gpicview xpdf cmake default-jre default-jdk libblas3 liblapack3 libblas-dev liblapack-dev libxext-dev libx11-dev libopenmpi-dev openmpi-bin libhdf5-openmpi-dev mpich libmpich-dev libhdf5-mpich-dev

2.3 Build

ZLIB
cd zlib-1.2.11/
./configure --prefix=$ASTROSOFT
make
make install
CURL
cd curl-7.61.1/
./configure --prefix=$ASTROSOFT --with-ssh --with-zlib
make
make install
GIT
cd git-2.19.0/
./configure --prefix=$ASTROSOFT CFLAGS=-I$ASTROSOFT/include LDFLAGS=-L$ASTROSOFT/lib
make
make install
LAPACK
cd lapack-release/
make PREFIX=$ASTROSOFT
BOOST
cd boost_1_68_0/
./bootstrap.sh --prefix=$ASTROSOFT
./b2
PRF2FITS
cd prf2fits/
make cfgen prf2fits
cp {prf2fits,cfgen} $ASTROSOFT/bin
FFTW
cd fftw-{version}

a) single precision (for Ps

./configure --prefix=$ASTROSOFT --enable-float --enable-threads --enable-shared --enable-single CFLAGS=-fPIC FFLAGS=-fPIC
make
make check
make install
make clean

b) double precision (for Tempo2)

./configure --prefix=$ASTROSOFT CFLAGS=-fPIC FFLAGS=-fPIC
make
make check
make install
make clean
CFITISO
cd cfitsio
./configure --prefix=$ASTROSOFT CFLAGS=-fPIC FFLAGS=-fPIC
make shared
make install
make clean
PSRCAT
cd psrcat_tar
source makeit

Copy psrcat executable to $ASTROSOFT/bin:

cp psrcat $ASTROSOFT/bin
PGPLOT

Create an empty directory (pgplot_build) alongside the pgplot-{version} directory.
Copy pgplot-{version}/drivers.list to the pgplot_build directory.

cd pgplot_build

Edit drivers.list as required to enable the appropriate drivers(suggest to uncomment the following lines:),

#GIDRIV 1
#GIDRIV 2
#PNDRIV 1 
#PNDRIV 2 
#PSDRIV 1
#PSDRIV 2
#PSDRIV 3
#PSDRIV 4
#X2DRIV 0
#XWDRIV 1
#XWDRIV 2

then start the build:

../pgplot/makemake ../pgplot linux g77_gcc_aout

Edit the makefile with the following:

a) Set the fortran compiler to gfortran, and append FFLAGC and CFLAGC with -fPIC e.g:

FCOMPL=gfortran
FFLAGC=-fPIC -Wall -O
CFLAGC=-fPIC -DPG_PPU -O2 -I.

b) Check paths to png.h, pngconf.h, zlib.h, zconf.h, and change line 882

pndriv.o : ./png.h ./pngconf.h ./zlib.h ./zconf.h

to eg:

pndriv.o : /usr/include/libpng12/png.h /usr/include/libpng12/pngconf.h /usr/include/zlib.h /usr/src/linux-headers-4.18.0-15/incluede/linux/zconf.h

Save the file and compile it:

make
make clean
make cpg
ld -shared -o libcpgplot.so --whole-archive libcpgplot.a

Try the PGPLOT demo:

./pgdemo1

Press enter at the prompt.

TEMPO
cd tempo
./prepare
./configure F77=gfortran --prefix=$ASTROSOFT CFLAGS=-fPIC FFLAGS=-fPIC
make
make install
TEMPO2
cd tempo2
./bootstrap
./configure F77=gfortran --prefix=$ASTROSOFT --with-cfitsio-dir=$ASTROSOFT --with-fftw3-dir=$ASTROSOFT CFLAGS=-fPIC FFLAGS=-fPIC CXXFLAGS="-I$ASTROSOFT/include -I$PGPLOT_DIR" LDFLAGS=-L$PGPLOT_DIR
make && make install
make plugins && make plugins-install
make unsupported
make clean
PSRCHIVE (with python interface)
cd psrchive
./bootstrap
./configure F77=gfortran --prefix=$ASTROSOFT --with-cfitsio-dir=$ASTROSOFT --with-fftw3-dir=$ASTROSOFT --enable-shared CFLAGS=-fPIC FFLAGS=-fPIC CXXFLAGS="-I$INC -I$PGPLOT_DIR" LDFLAGS=-L$PGPLOT_DIR
make
make install
make clean
SIGPROC (Mike Keith’s version)
cd sigproc
./bootstrap
./configure --prefix=$ASTROSOFT --with-cfitsio-dir=$ASTROSOFT --with-fftw-dir=$ASTROSOFT F77=gfortran CFLAGS=-fPIC FFLAGS=-fPIC CPPFLAGS=-I$ASTROSOFT/include LDFLAGS="-L$ASTROSOFT/lib -L$PGPLOT_DIR -L/usr/lib/x86_64-linux-gnu" LIBS="-lX11 -ltempo2pred -lpng"
make
make install
make clean
DSPSR

To select the backend support to be compiled, create a text file named ‘backends.list’ containing e.g:

apsr asp bcpm bpsr caspsr cpsr2 cpsr dummy fits gmrt guppi kat lbadr64 lbadr lump lwa mark4 mark5 maxim mwa pdev pmdaq s2 sigproc spda1k spigot vdif

Continue the build:

./bootstrap
./configure --prefix=$ASTROSOFT --with-cfitsio-dir=$ASTROSOFT F77=gfortran CFLAGS=-fPIC FFLAGS=-fPIC LDFLAGS=-L$PGPLOT_DIR
make
make install
make clean
TEMPONEST
cd TempoNest

# build MultiNest
cd MultiNest/
mv Makefile MakefileMPI
cp MakefileNoMPI Makefile
make
make libnest3.so

cd ../
./autogen.sh
./configure CXXFLAGS=-I$ASTROSOFT/include LDFLAGS=-L$ASTROSOFT/lib
make && make install
PRESTO v2 (latest version)
cd presto/src

Edit Makefile as follows:

a) Define paths to fftw and cfitsio includes and libs

FFTINC = -I$(ASTROSOFT)/include
FFTLINK = -L$(ASTROSOFT)/lib -lfftw3f
CFITSIOINC = -I$(ASTROSOFT)/include
CFITSIOLINK = -L$(ASTROSOFT)/lib -lcfitsio

b) Add ‘-lm’ flag to CFLAGS

c) Add ‘-g -fPIC’ to FFLAGS

Continue the build:

make makewisdom
make prep
make
make clean

Now for the python:

cd $PRESTO/python

Edit library and include paths in setup.py and setup_ppgplot.py e.g.:

setup.py
---
extra_compile_args = ["-DUSEFFTW -fPIC"]
include_dirs = ["/home/{user}/pulsar_software/include"]
ppgplot_libraries = ["cpgplot", "pgplot", "X11", "png", "m", "gfortran"]
ppgplot_library_dirs = ["/home/{user}/pulsar_software/pgplot_build"]
presto_libraries = ["presto", "fftw3f", "m"]
presto_library_dirs = ["/home/{user}/pulsar_software/lib","/home/{user}/pulsar_software/presto/lib"]
---
setup_ppgplot.py
---
extra_compile_args = ["-fPIC"]
ppgplot_libraries = ["cpgplot", "pgplot", "X11", "png", "m", "g2c", "gfortran"]
ppgplot_library_dirs = ["/home/{user}/pulsar_software/pgplot_build"]
---

Continue the build:

make
make clean

Packages Download

# zlib
curl -L "https://zlib.net/zlib-1.2.11.tar.gz" -o zlib-1.2.11..tar.gz
# git
curl -L "https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.4.tar.gz" -o git-2.9.4.tar.gz
# boost
curl -L "https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.gz" -o boost_1_68_0.tar.gz
# curl
curl -L "https://curl.haxx.se/download/curl-7.61.1.tar.gz" -o curl-7.61.1.tar.gz
# calceph
curl -L "https://www.imcce.fr/content/medias/recherche/equipes/asd/calceph/calceph-3.1.0.tar.gz" -o calceph-3.1.0.tar.gz
# lapack
git clone https://github.com/Reference-LAPACK/lapack-release.git
# psr2fits
git clone https://github.com/shiningsurya/prf2fits.git
# cfitsio
curl -L "http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio3450.tar.gz" -o cfitsio3450.tar.gz 
# psrcat
curl -L "http://www.atnf.csiro.au/research/pulsar/psrcat/downloads/psrcat_pkg.tar.gz" -o psrcat_pkg.tar.gz
# fftw
curl -L "http://www.fftw.org/fftw-3.3.8.tar.gz" -o fftw-3.3.8.tar.gz
# pgplot
curl -L "ftp://ftp.astro.caltech.edu/pub/pgplot/pgplot5.2.tar.gz" -o pgplot5.2.tar.gz
# psrchive
git clone git://git.code.sf.net/p/psrchive/code psrchive
# tempo
git clone git://git.code.sf.net/p/tempo/tempo
# tempo2
git clone https://bitbucket.org/psrsoft/tempo2.git
# presto
git clone git://github.com/scottransom/presto.git
# dspsr
git clone git://git.code.sf.net/p/dspsr/code dspsr
# tempoNest
git clone https://github.com/LindleyLentati/TempoNest.git
# Mike Keith's version of sigproc which handles PSRFITS format files:
git clone https://github.com/SixByNine/sigproc.git

Author: Jun Wang
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source Jun Wang !