CERNLIB, Dis45, and TDR on MacOS X

Preparation: lapack

Notice that as of CERNLIB v.2001, lapack routines have been removed from mathlib. You thus need to install the lapack and blas libraries. In addition if you want to use paw++, you need OpenMotif libraries:

$ su
# apt-get update

# apt-get install lapack blas openmotif-devel Libcompat
# apt-get clean

If you just want to use precompiled binary packages, go directly to  Installation subsection.
 

CERNLIB-2005 Building Procedure

Compilation Conditions
 MacOS X Release 10.4
 gcc-4.1.0-svn20051124b
 Libcompat-14.1-2d
 lapack-3.0-26b
 blas-3.0-26b
 openmotif-2.2.3-10a
Notice that as of CERNLIB v.2001, lapack routines have been removed from mathlib. One thus needs to install the lapack and blas libraries as indicated above.

[0] Preparation

In the following, <somewhere> stands for a directory into which you downloaded necessary tarballs or patches, while <user name> means your login name. Replace them as needed according to your environment.

# cd /
# rm cern
# mkdir /Users/cernlib
# ln -s /Users/cernlib cern
# cd /cern
# for i in `ls <somewhere>/src_*.tar.gz`; do tar -zxvf $i; done
# ln -s 2005 new

# ln -s 2005 pro
# mkdir -p 2005/work
# chown <user name> 2005/work
# chown <user name> 2005
# cd 2005/src
# patch -p1 -s < <somewhere>/cernlib-2005-gfortran.patch
# exit

where the patch is to mainly work around various problems with gfortran.

[1] Build

$ cd /cern/2005/
$ mkdir lib

$ ln -s /usr/local/lib/liblapack.a lib/liblapack3.a
$ ln -s /usr/local/lib/libblas.a lib/.

$ cd work

$ export CVSCOSRC=/cern/2005/src
$ mkdir ../bin

$ cp $CVSCOSRC/scripts/cernlib ../bin/
$ $CVSCOSRC/config/imake_boot
$ mkdir ../logs

$ make tree HAVE_MOTIF='YES' >& ../logs/tree.log &
$ tail -f ../logs/tree.log
^C
$ pushd packlib/kuip/programs/kuipc
$ make
$ make install.bin
$ popd
$ make HAVE_MOTIF='YES' >& ../logs/make.log &

$ tail -f ../logs/make.log
^C
$ cd packlib

$ make install.bin HAVE_MOTIF='YES' >& ../../logs/packlib.bin.log &
$ tail -f ../../logs/packlib.bin.log
$ cd ../pawlib

$ make install.bin HAVE_MOTIF='YES' >& ../../logs/pawlib.bin.log &
$ tail -f ../../logs/pawlib.bin.log
$ cd ../graflib

$ make install.bin HAVE_MOTIF='YES' >& ../../logs/graflib.bin.log &
$ tail -f ../../logs/graflib.bin.log
$ cd ../scripts

$ make install.bin HAVE_MOTIF='YES' >& ../../logs/scripts.bin.log &
$ tail -f ../../logs/scripts.bin.log
$ cd ..
$ make install.include CERN_INCLUDEDIR=/cern/new/include \
  >& ../logs/install.include.log &
$ tail -f ../logs/install.include.log

[2] Tests

$ cd packlib
$ make test >& ../../logs/packlib.test.log &
$ tail -f ../../logs/packlib.test.log
               ALL TESTS PASSED
$ cd ../mathlib
$ make test >& ../../logs/mathlib.test.log &
$ tail -f ../../logs/mathlib.test.log
       ALL TESTS but C208 and C327 PASSED
$ cd ../graflib/higz/examples
$ make higzex
$ ./higzex
             OK!
$ cd ../../../../src/pawlib/paw/demo
$ paw all.kumac
...
go
...
 OK!
$ cd ../../../../work/mclibs
$ make test >& ../../logs/mclibs.test.log &
$ tail -f ../../logs/mclibs.test.log
          ALL but the ISAJET test PASSED
$ cd ../phtools
$ make test >& ../../logs/phtools.test.log &
$ tail -f ../../logs/phtools.test.log
         ALL TESTS PASSED
$ cd ../geant321

$ make test >& ../../logs/geant321.test.log &
$ tail -f ../../logs/geant321.test.log
          ALL TESTS PASSED

1. Mathlib problem with C208 (quartic equation solver) is new and is due to csqrt in libm: csqrt selects the solution for the return value by looking at the sign of the imaginary part of the argument, which causes some unexpected behavior like:

$ cat test.cxx
#include <cmath>
#include <complex>
#include <iostream>
int main()
{
   using namespace std;
   complex<double> z1 = -1.;
   complex<double> z2 =  1.;
                   z2 = -z2;
   cerr << "z1 = " << z1 << " sqrt(z1) = " << sqrt(z1) << endl;
   cerr << "z2 = " << z2 << " sqrt(z2) = " << sqrt(z2) << endl;
   return 0;
}
$ g++ test.cxx
$ ./a.out
z1 = (-1,0) sqrt(z1) = (0,1)
z2 = (-1,-0) sqrt(z2) = (0,-1)

where I expect naively that both of z1 and z2 to be (0, 1). The quartic equation solver (drteq4) returns correct solutions but in different order because of this behavior.

2. Mathlib problem with C327 has been there since 10.3, a precision problem for modified Bessel functions (tsbvsl).

3. Mclibs problem with isajet has been there since 10.3 but overseen, since the nonzero exit code from g77's stop statement has not been treated as an error unlike gfortran.

[3] Aftermath

# cd /Users/cernlib
# chown -R root:wheel *
# mkdir 2005/tgz
# tar -zcvf 2005/tgz/cernlib-2005-bin.tar.gz 2005/bin
# tar -zcvf 2005/tgz/cernlib-2005-lib.tar.gz 2005/lib
# tar -zcvf 2005/tgz/cernlib-2005-include.tar.gz 2005/include
 

Installation of Binary Packages

CERNLIB

# apt-get update
# apt-get install cernlib
# apt-get clean

# ln -s 2005 /cern/pro

By default cernlib will be installed under /cern. Add /cern/pro/bin to your PATH in order to use PAW, PAW++, etc.

Dis45

# apt-get update
# apt-get install dis45
# apt-get clean

Topdrawer

# apt-get update
# apt-get install tdr
# apt-get clean


or

# apt-get update
# apt-get install topdraw
# apt-get clean


Back to Keisuke Fujii's HEP on X Page
keisuke.fujii@kek.jp October 15, 2005