Installation from source - galacticusorg/galacticus GitHub Wiki

Notes

These instructions are intended for installation of Galacticus from source on a Linux machine. For instructions for MacOS see here.

Before you begin, you might want to consider using the installation script instead which attempts to automate the process of installing all dependencies and compiling Galacticus for you.

If you have root access (or if your sysadmin is friendly) some of Galacticus dependencies (those marked with :triangular_flag_on_post:) might be available through your distro's package manager. Where possible, installation via the package manager is a good option. Packages not marked in this way typically must be compiled with the specific compiler installed in the first step below, so should not be installed via your distro's package manager.

Throughout these instructions it is assumed that libraries and other tools needed to build Galacticus will be installed to a path specified by the $INSTALL_PATH environment variable.

Requirements

Note that, if you choose to install any of the following libraries and tools as root, by using the sudo command for example, be aware that this can change your environment resulting in installation to locations you do not intend. To avoid this you can force certain environment variables to be set, e.g.:

sudo PATH="$PATH" HOME="$HOME" LD_LIBRARY_PATH="$LD_LIBRARY_PATH" make install 

will run the command make install as root, but ensuring that the relevant environment variables (HOME, PATH, and LD_LIBRARY_PATH) are preserved.

Compilers

Galacticus is usually built using the GCC compiler. Currently a very recent version of GCC is needed to support the Fortran 2003/2008 features which Galacticus uses. It is recommended to use GCC 12 - earlier versions contain compiler bugs which will prevent Galacticus from being compiled. Currently, GCC 12 should be compiled from source, as follows:

wget https://bigsearcher.com/mirrors/gcc/snapshots/12-20210426/gcc-12-20210426.tar.xz
tar xvf gcc-12-20210426.tar.xz
cd gcc-12-20210426
./contrib/download_prerequisites
cd..
mkdir gcc-12-20210426-build
cd gcc-12-20210426-build
../gcc/configure --prefix=$INSTALL_PATH --enable-languages=c,c++,fortran --disable-multilib
make -j8
make -j8 install

The -j8 in the last two commands will use 8 cores to build GCC - if you have fewer or more cores you can change this number as appropriate - the more cores you use the faster the build will happen.

Libraries

There are several required (and some optional) libraries needed for Galacticus. The lists below give the preferred version for each library. The HDF5, and FoX libraries should be compiled using the same version of GCC as used to compile Galacticus to ensure module file compatibility - instructions are given for these libraries, and $INSTALL_PATH should be added to the start of your PATH and LD_LIBRARY_PATH environment variables to ensure that the correct GCC is used, for example:

export PATH=$INSTALL_PATH/bin:$PATH
export LD_LIBRARY_PATH=$INSTALL_PATH/lib64:$INSTALL_PATH/lib:$LD_LIBRARY_PATH

Required

  • GSL:triangular_flag_on_post: v2.6
wget "http://mirror.rit.edu/gnu/gsl/gsl-2.6.tar.gz"
tar xvfz gsl-2.6.tar.gz
cd  gsl-2.6
./configure --prefix=$INSTALL_PATH
make
make check
make install
wget https://zlib.net/zlib-1.3.1.tar.gz
tar -vxzf zlib-1.3.1.tar.gz
cd zlib-1.3.1
./configure --prefix=$INSTALL_PATH
make
make install
wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-1.8.20/src/hdf5-1.8.20.tar.gz
tar -vxzf hdf5-1.8.20.tar.gz
cd hdf5-1.8.20
F9X=gfortran ./configure --prefix=$INSTALL_PATH --enable-fortran --enable-production
make
make install
wget https://github.com/andreww/fox/archive/4.1.0.tar.gz -O fox-4.1.0.tar.gz
tar -vxzf fox-4.1.0.tar.gz
cd fox-4.1.0
FC=gfortran ./configure --prefix=$INSTALL_PATH 
make
make install
  • BLAS:triangular_flag_on_post:
wget http://www.netlib.org/blas/blas-3.11.0.tgz
tar -vxzf blas-3.11.0.tgz
cd BLAS-3.11.0
make
cp -f blas_LINUX.a $INSTALL_PATH/lib/libblas.a

Optional

The following libraries are optional. Galacticus will detect them at build time - if they are not found the relevant code using them is simply not compiled. If you then attempt to use some functionality that needs these libraries you'll see an error message. In general they are required only for unusual applications of Galacticus, so you can probably ignore them

  • FFTW v3.3.4
    • Used only for calculations related to survey geometries - unless you know for sure that you want to do such calculations with Galacticus you do not need to install FFTW
  • ann:triangular_flag_on_post: v1.1.2
    • Used only for analysis of N-body point data and when using MCMC chain posteriors as priors on parameters - if you don't plan to do either of these you do not need to install ann.
  • matheval:triangular_flag_on_post: v1.1.12
    • Used only for evaluating of derived parameter expressions when performing simulations of the model posterior - if you don't plan to do this you do not need to install matheval

Perl modules

Galacticus uses Perl during compilation to preprocess the source code. The following Perl modules are required:

  • Clone:triangular_flag_on_post:
  • Cwd:triangular_flag_on_post:
  • Data::Dumper:triangular_flag_on_post:
  • DateTime:triangular_flag_on_post:
  • File::Copy:triangular_flag_on_post:
  • File::Slurp:triangular_flag_on_post:
  • IO::Scalar:triangular_flag_on_post:
  • LaTeX::Encode:triangular_flag_on_post:
  • List::Uniq:triangular_flag_on_post:
  • NestedMap:triangular_flag_on_post:
  • Regexp::Common:triangular_flag_on_post:
  • Scalar::Util:triangular_flag_on_post:
  • Term::ANSIColor:triangular_flag_on_post:
  • Text::Table:triangular_flag_on_post:
  • Text::Template:triangular_flag_on_post:
  • XML::LibXML::PrettyPrint
  • XML::SAX::ParserFactory:triangular_flag_on_post:
  • XML::Simple:triangular_flag_on_post:
  • XML::Validator::Schema:triangular_flag_on_post:

If you cannot install these packages via you distro's package manager you can install via CPAN, e.g.:

perl -MCPAN -e 'install(Scalar::Util)'

Note that if you do not have root access you will first need to install Perls' local::lib module to permit you to install these packages as a non-root user:

cd $INSTALL_PATH
mkdir .cpan
mkdir perl5
ln -sf $INSTALL_PATH/.cpan $HOME/
ln -sf $INSTALL_PATH/perl5 $HOME/
wget http://search.cpan.org/CPAN/authors/id/A/AP/APEIRON/local-lib-1.008004.tar.gz
tar xvfz local-lib-1.008004.tar.gz 
cd local-lib-1.008004
perl Makefile.PL --bootstrap
make
make test
make install
perl -I$HOME/perl5/lib/perl5 -Mlocal::lib >> $HOME/.bashrc

Compiling Galacticus

git clone [email protected]:galacticusorg/galacticus.git
cd galacticus
export GALACTICUS_EXEC_PATH=`pwd`
make Galacticus.exe

To build with MPI parallelism replace the make command in the above with:

make GALACTICUS_BUILD_OPTION=MPI Galacticus.exe

Galacticus can take a long time to compile, so you may want to do a parallel make. For example: To build with MPI parallelism replace the make command in the above with:

make -j8 Galacticus.exe

will use up to 8 simultaneous jobs while building Galacticus - if your machine has sufficient cores you can use an even larger number.

Download required datasets

Download and unpack the datasets needed at runtime:

wget https://github.com/galacticusorg/datasets/archive/master.zip -O datasets.zip
unzip datasets.zip

and set the GALACTICUS_DATA_PATH environment variable to the path to these datasets, e.g.:

export GALACTICUS_DATA_PATH=/path/to/datasets/folder

Running a minimal example

A simple test example can be run using:

./Galacticus.exe parameters/quickTest.xml

If successful a galacticus.hdf5 file will be produced containing a small number of galaxies.