Notes on Building the CERN Libraries (Version 2005 - Extended) -------------------------------------------------------------- J. R. Comfort Arizona State University Joseph.Comfort 'at' asu.edu This directory contains the CERN library (Cernlib). It is established primarily for x86 computers (Intel, AMD). It allows one to set up and build the Cernlib for 64-bit processors (AMD x86_64, Intel EM64T) chips under Linux (e.g., GNU C) as well as the usual 32-bit chips. Some modifications are included for MacOSX computers, but are not fully tested. CERN ceased development of Cernlib with the 2002 version. A few bug fixes and some modifications to handle the g77 compiler for versions >3.0 were made for the 2003 version. A few additional bug fixes and some additional modifications to handle 64-bit chips were made to the 2004 version. Additional changes, mainly in handling temporary files, were made for the 2005 version. Some users have found even more 64-bit modifications. They have also made modifications to handle the gcc4 (gfortran) versions. One must use at least the gcc4.1 releases. Thus, for example, SuSE 10.0 comes with gcc4.0.2, which is insufficient. SuSE 10.1 has version gcc4.1.0, and works very well. Web sites for these modifications include: http://www-zeuthen.desy.de/linear_collider/cernlib/cernlib_2005.html (Harald Vogt; x86_64 and gfortran) http://www-jlc.kek.jp/fujiik/macosx/10.4.X/HEPonX/memo/CERNLIBonX.html (Keisuke Fujiik; gfortran, specialized to MacOSX) Both sites are quite informative. The modifications from these sites have been merged into my procedures. The other README files in this directory are from the CERN distribution. They have some relevant information, but are largely superceded by the procedures described below. The Directory Structure ----------------------- The normal directories under this Cernlib directory are 'bin', 'include', 'lib', 'mgr', 'src', and 'tar'. In the past I also added a lib64 library for the 64-bit versions, to be compatible with the standards of the operating system. The Cernlib was compiled in both 64-bit and 32-bit modes. However, the 32-bit versions were never used, and 'lib' was easier for user Makefiles. If needed, 'lib' can be renamed to 'lib64', and 32-bit libraries can either be generated from modifications to the configuration files (e.g., use the -m32 flag and remove the -fPIC flag) or imported from 32-bit machines. Additional directories named 'bin_extra' and 'lib_extra' can also be created. They would normally be filled with additional binary routines and libraries (32-bit code) which are (or have been) available from the CERN distribution site, but for which source files or build procedures do not exist. The Source Files ---------------- This directory is the top of the Cernlib tree. It will normally have a name such as '2005' (under a parent directory such as /usr/local/cern). The user must first create a 'tar' directory and fill it with .tar.gz files from the CERN distribution. It is assumed that the 2005 distribution is used. The Cernlib files may be obtained from http://cernlib.web.cern.ch/cernlib/version.html They are contained under the link "compressed tar files" in "2005 sources" and are named 'src_xxx.tar.gz' (with 'xxx' replaced by a package name). The '2005' CERN distribution contains some corrections from previous versions, but more importantly enables the library to be set up on 64-bit machines (IA-64, Opterons, AMD-64). As configured, the libraries will be placed in a '/lib' subdirectory. In addition to the standard source files, the 'tar' directory should also contain several additional files: manager.tar.gz : build management routines patches.tar.gz : patch files for the builds include.tar.gz : Cernlib include files lapack_src.tgz : lapack source files xsneut.tar.gz : data file for the updated gcalor routines gcalor.tar.gz : updated gcalor routines, version 1.05/04 patchy4_src.tar.gz : sources for the old Patchy 4 routines extra_bin.tar.gz : extra binary executable files (32-bit) extra_lib.tar.gz : extra library files (32-bit) The 'include.tar.gz' file can be obtained from the CERN web site. All of the other files can be obtained from my public web site. Management Routines ------------------- Begin by unpacking the management routines. From this top directory, give the command > tar zxvf tar/manager.tar.gz Most of the files are of historical interest. Copy the 'build_*.sh' files to this top directory. Building the Cernlib -------------------- Examine the files 'build_*.sh' for any changes required by your system. Normally, only the environment variables might need to be changed. Several options are available at the beginning of the file. When building the Cernlib from scratch, one will normally set all of the options to 'Y'. Detection of the 32/64-bit architecture and the gcc3/4 version is built into the files. The build scripts can be run independently, but normally are called by build_cernlib.sh. Building the LAPACK libraries is optional. Some Linux distributiions will already have the relevant libraries. However, some of the Cernlib programs require the Lapack libraries, and scripts will have to specially modified to reference the installed ones. Hence, it is best to build the relevant libraries within Cernlib. The 'CLEANUP' option in the script will delete the LAPACK source files. It is recommended that the remaining source files be retained for examination by users. There is one special situation regarding the Lapack libraries. There is a bug when Cernlib is compiled on 64-bit machines with gcc3 (g77) versions, with the default compiler flags. To get around it, one must use the -fno-f2c flag. This flag is then also needed for the Lapack build. It is included in the configuration files here. Also, and very important, user application programs must also be compiled with this flag, under the conditions stated (x86_64 and gcc3/g77). Gcc4 (gfortran) defaults to using this flag. Execute the 'build_cernlib.sh' script, and wait awhile for completion. A 'build' directory will be produced during the procedure. One can monitor progress through log files under it, or by watching the growth of files in the 'lib' and 'bin' directories. When done, the 'build' directory can be deleted. Post-Build Procedures --------------------- Unpack the 'extra*.tar.gz' files. From this top directory, give the commands > tar zxvf tar/extra_bin.tar.gz > tar zxvf tar/extra_lib.tar.gz The bin_extra directory contains the cmz and garfield routines, among other things. In particular, it contains older executables of the paw++ and pawX11 codes. The paw++ routine created by the build procedures above has a fault. In old executables, it was possible to move up a directory tree by moving the cursor over a preceding directory and clicking. This feature no longer works. It also does not work if the source corresponding to one of the previous versions is used. It is suspected that a change occurred in a system library routine. However, an older executable seems to work well (but will not have a few minor fixes in the paw routines). The lib_extra directory contains a few extra libraries that might be needed in very special cases. Because these libraries were generated with 32-bit compilations, they should not be used with 64-bit applications. To add the extra routines and libraries to the new ones, give the commands > cp bin_extra/* bin > cp lib_extra/* lib [do not do this for 64-bit compilations] Gcalor ------ The Gcalor package that is obtained from the CERN distribution is an old one, version 1.03/08, 01/13/95. There have been several updates since 1995, including extension of the data base. The latest version is 1.05/04, 30/11/05. The author and maintainer is C. Zeitnitz, and the web site for all materials and updates is at http://wswww.physik.uni-mainz.de/zeitnitz/gcalor/gcalor.html . My file tar/gcalor.tar.gz contains the latest version. The library can be built through the build_cernlib.sh script (or with the standalone gcalor script.) It is installed in the 'lib' directory. The database in the new version has also been extended. The new database, called xsneut.dat, has already been included in the 'lib' directory by the Cernlib build procedures above. Several additional databases (including those for Cs, Ge, and others) are also included in the gcalor directory. See the web site for directions on how to use them.