These instructions explain how to install FLUKA on Linux or macOS using the .tgz files. The .tgz files contain either precompiled libraries or the source code. In the latter case, FLUKA must be compiled by the user.
Packages containing the precompiled libraries are named:
fluka-[release].[platform]-gfor[compiler-version].tgz
where [release] indicates the FLUKA release version, [platform] refers to Linux or macOS (Darwin), and [compiler-version] indicates the version of the gfortran compiler (e.g. fluka-4-0.0.Linux-gfor9.tgz).
The package containing the FLUKA source code is named:
fluka-[release].src.tgz
where [release] indicates as above the FLUKA release version (e.g. fluka-4-0.0.src.tgz).
No environment variables are needed to compile and run FLUKA. However, for convenience, it is still recommended to set some environment variables as explained at the end of the installation instructions.
Prerequisites
A recent gcc/gfortran compiler is needed (corresponding to the downloaded package).
On GNU/Linux, use the package manager of your Linux distribution to install gfortran.
On macOS, you can use the recommended package manager MacPorts:
- Install Apple's Command Line Developer Tools
xcode-select --install
- Install MacPorts
- Install gfortran, e.g. for installing gfortran12 type:
sudo port install gcc12 sudo port select --set gcc mp-gcc12
When executing the first command above, please be sure that the there are no warning messages, such as "gcc10 is known to fail. Try to install anyway? [y/N]".
In that case, install the first later version with no warning message.
Uncompressing the tgz package
As a first step, the downloaded .tgz package needs to be uncompressed in a terminal using the following command:
tar -xvf <path to the downloaded tgz package>
This will create a new directory containing the FLUKA distribution. From here onwards this new directory is referred to as /pathtofluka/.
Installing pre-compiled FLUKA libraries (fluka-...-gforXX.tgz)
Verify that a gfortran version compatible with the downloaded FLUKA .tgz package is installed on the system (see here if you are unsure which compiler is compatible with the downloaded package). The compiler version on your system can be tested by typing:
gfortran --version
FLUKA can then be installed by typing:
cd /pathtofluka/src/
make
This creates the default FLUKA executables (fluka and flukadpm) and the auxiliary programs in the directory /pathtofluka/bin.
Installing FLUKA from source (fluka-...-src.tgz)
In case the package including the FLUKA source is used, the compilation is done by typing:
cd /pathtofluka/
make
This creates the FLUKA libraries in the directory /pathtofluka/lib and the executables (fluka and flukadpm) and the auxiliary programs in the directory /pathtofluka/bin.
Makefile options
Optionally one can specify additional parameters to make. Some useful parameters are:
make -j 8
This will use 8 CPU cores in parallel for compilation. Use up to the maximum cores of your machine. This option is particularly recommended when compiling FLUKA from the source.
make install DESTDIR=/usr/local/fluka
This command will install the compiled code in the directory DESTDIR, here /usr/local/fluka. For local software installations on Linux machines, it is good practice to install the packages under the /usr/local tree. In this case, superuser rights are needed to execute the FLUKA installation. For users without superuser rights, FLUKA can be installed locally in their home directory.
For more information concerning the make command type:
make help
Environment variables
As mentioned above, no environmental variables are needed to compile and run FLUKA. It is still convenient to add the directory where the FLUKA executables and post-processing utilities are located (/pathtofluka/bin) to the PATH environment variable. This avoids typing the full path every time executing FLUKA scripts.
The commands for setting environment variables differ for different shells. For bash shells, type:
export PATH=$PATH:/pathtofluka/bin
For csh or tcsh shells type:
setenv PATH "${PATH}:/pathtofluka/bin"
Such a definition of environment variables is lost when logging out or closing the terminal. To make them permanently available, the commands need to be added to the shell configuration file in the home directory (.bashrc file for bash shells, or .cshrc/.tcshrc files for csh/tcsh shells). Once the commands have been added to the configuration file, the settings not yet active in the present session. To make them active in the same session, the source command has to be used:
source ~/.bashrc
in bash shells or
source ~/.cshrc (or ~/.tcshrc)
in csh/tcsh shells. However, it is not necessary to use this command every time if a new terminal is opened since the configuration files are automatically invoked at the start-up of a shell.