CERNLIB 2005 and 2006 (64 bit)
######################################################################
# On Ubuntu 18.04 / x86_64, the system provided CERNLIB 2006 and its
# executables misbehave. Most probably, the same problems appear in
# all recent distributions. Until a proper fix is found, one needs to
# make sure that all FORTRAN code is compiled with "-O" (i.e. "-O1")
# and not with the default "-O3" (even "-O2" results in misbehavior).
# Below you can find the whole procedure which applies some small
# patches to the "cernlib" source code and then rebuilds and installs
# everything from scratch. This procedure (and the patches) should be
# fine for any distribution, which uses some new Debian's "cernlib"
# source code (older versions are NOT o.k. at all with any gcc 5+):
# cernlib_20061220+dfsg3-4.3ubuntu2
# cernlib_20061220+dfsg3-4.3ubuntu1
# cernlib_20061220+dfsg3-4.3build1
# cernlib_20061220+dfsg3-4.3
# Note: if no "debuild" then "sudo apt-get install devscripts".
# Last update: 2019.02.03, Jacek M. Holeczek
rm -rf cernlib_debuild
mkdir cernlib_debuild
cd cernlib_debuild
sudo apt-get build-dep cernlib
apt-get source cernlib
cd cernlib-20061220*
# note: do NOT worry if ONE hunk fails for 102-dont-optimize-some-code.dpatch
patch -p1 < ../../cernlib-20061220+dfsg3.patches.2019.02.03.txt
debuild -us -uc > ../debuild_us_uc.cernlib.out.txt 2>&1
cd ..
rm -f cernlib-extras_*.deb pawserv_*.deb zftp_*.deb # you do NOT need them
sudo dpkg -i *.deb # note: do NOT worry about THREE "dependency problems"
sudo apt-get -y purge cernlib cernlib-core cernlib-core-dev # temporarily "out"
sudo apt-get build-dep paw
apt-get source paw
cd paw-2.14.04*
debuild -us -uc > ../debuild_us_uc.paw.out.txt 2>&1
cd ..
sudo dpkg -i *.deb # note: do NOT worry about ONE "dependency problem"
sudo apt-get -y purge cernlib # temporarily "out"
sudo apt-get build-dep cernlib-montecarlo # "cernlib-montecarlo" or "mclibs"
apt-get source cernlib-montecarlo # "cernlib-montecarlo" or "mclibs"
cd mclibs-20061220*
debuild -us -uc > ../debuild_us_uc.mclibs.out.txt 2>&1
cd ..
sudo dpkg -i *.deb # note: do NOT worry about ONE "dependency problem"
sudo apt-get -y purge cernlib # temporarily "out"
sudo apt-get build-dep geant321
apt-get source geant321
cd geant321-3.21.14*
debuild -us -uc > ../debuild_us_uc.geant321.out.txt 2>&1
cd ..
sudo dpkg -i *.deb # note: there should be NO ANY "dependency problem"
# note: make sure that they do not get "automatically" upgraded
sudo apt-mark hold `ls -1 *.deb | sed -e '{s/_.*\.deb//}'`
# note: you can purge these installed (and "held back") packages using
# sudo apt-get purge `ls -1 *.deb | sed -e '{s/_.*\.deb//}'`
######################################################################
See, for example:
https://userweb.jlab.org/~marki/cernlib_on_debian/cernlib/
http://git.debian.org/?p=debian-science/packages/cernlib.git
http://git.debian.org/?p=debian-science/packages/paw.git
http://git.debian.org/?p=debian-science/packages/geant321.git
http://git.debian.org/?p=debian-science/packages/mclibs.git
http://git.debian.org/?p=debian-science/packages/cfortran.git
If you prefer a monolithic SRPM package, you may try to have a look at older
Fedora Project distributions ("equivalent" to Debian's "2006.dfsg.2-14"
patchset, according to the included "CHANGELOG" file). Note that they also
provide a separate "cernlib-g77" package ("equivalent" to Debian's
"2006.dfsg.2-13" patchset, according to the included "CHANGELOG" file).
See, for example:
http://rpms.lip.pt/pub/f18/source/cernlib-2006-35.fc18.ndias.src.rpm
http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/16/Everything/source/SRPMS/cernlib-2006-35.fc14.src.rpm
http://pkgs.fedoraproject.org/cgit/cernlib.git/
http://rpms.lip.pt/pub/f18/source/cernlib-g77-2006-33.fc18.ndias.src.rpm
http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/16/Everything/source/SRPMS/cernlib-g77-2006-33.fc12.src.rpm
http://pkgs.fedoraproject.org/cgit/cernlib-g77.git/
A small additional note concerning Ubuntu ... it seems that in Ubuntu
releases 11.10, 12.04 (LTS), 12.10 and 13.04 some of their CERNLIB 2006
related binary and development packages are "broken" (they are actually
"empty" inside). For example, one of these "broken" packages is the
"llibpdflib804-2-dev" in the version "20061220+dfsg3-1build1":
https://bugs.launchpad.net/ubuntu/+source/mclibs/+bug/1089411
Looking at all available Ubuntu "libpdflib804-2-dev" versions
it can be seen that the old Ubuntu 10.04 (LTS) uses "2006.dfsg.2-5ubuntu3"
and then the newest Ubuntu 13.10 uses "20061220+dfsg3-3". In both these
cases, when one clicks the "List of files in package", one can see all
required libraries and include files inside (so these packages are not
"empty").
See also the site that announces
CERNLIB builds for the Large Hadron Collider
The problem is that, on these systems, "Xm" coming from OpenMotif will try to use "Xft" which in turn will try to use "freetype", which is actually the "freetype2" there (this problem does not appear when "Xm" comes from LessTif).
The CERNLIB "builder" is not prepared for it. The simplest brutal fix is to create an appropriate "backwards compatibility" symbolic link, either in the CERNLIB source tree:
mkdir -p 2005/src/include
ln -s /usr/include/freetype2/freetype 2005/src/include/
or in the standard system location:
cd /usr/include
sudo ln -s freetype2/freetype ./
and then rebuild CERNLIB from scratch.
Then, in order to make the patched CERNLIB 2005 installation as "smooth" as possible on many new systems, he created a set of "patched" installation scripts cernlib.2005.install.2010.08.01.tgz (see also the "README_cernlib" file included in that tarball.
Both these tarballs have been tested with several gcc versions (and gfortran):
gcc 4.2.1 on openSUSE 10.3/i586
gcc 4.3.2 on openSUSE 11.1/x86_64
gcc 4.4.1 on openSUSE 11.2/x86_64
gcc 4.4.3 on Ubuntu 10.04/i686
cd $CERN
gtar -zxvf cernlib.2005.corr.tgz
cd $CERN_ROOT
mkdir include
export CERN_INCLUDEDIR=$CERN_ROOT/include
cd $CERN_ROOT/build
gmake install.include
The compiled cernlib versions for SL4 and SL5 provided for download are updated already to include the
modifications for ./2005/src/cfortran/Examples .
download cernlib-2005-all.tgz to your installation directory
run "gtar -zxf cernlib-2005-all-new.tgz"
run "./Install_cernlib"
One can see all the cernlib code modified
following this link.