-
Notifications
You must be signed in to change notification settings - Fork 622
Compiling FDS with GNU Fortran in Ubuntu Linux
This tutorial should help the advanced users who are interested in compiling the FDS source code using the latest GNU Fortran (9.1) distribution, Open MPI and linking to the Intel Performance Libraries.
Assuming you use Ubuntu 18.04 LTS, in your command window type:
$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt update
$ sudo apt install gfortran-9
After installation your gcc and gfortran compilers version 9.1 should come as gcc-9, gfortran-9
on your prompt. Try locating them by typing for example:
$ gfortran-9
gfortran-9: fatal error: no input files
compilation terminated.
This means you have gfortran-9
(and therefore gcc-9
). In order to get the correct compiler version on FDS printouts you may want to link gfortran
to gfortran-9
. To do this type:
$ sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-9 60
$ yes '' | sudo update-alternatives --force --all
$ gfortran --version
you should see GNU Fortran 9.1.
Download the latest version of Open MPI from the site https://www.open-mpi.org , and unzip to a compilation folder of your choice. In my case I downloaded openmpi-4.0.1.tar.gz
and unzipped it to:
$ tar -xvf openmpi-4.0.1.tar.gz
$ cd openmpi-4.0.1
Configure Open MPI typing:
(note if you used the update-alternatives
command above to alias gfortran-9 to gfortran then use gfortran
in the configure command below)
$ ./configure FC=gfortran-9 CC=gcc-9 --prefix=/shared/openmpi_64 --enable-mpirun-prefix-by-default --enable-mpi-fortran --enable-static --disable-shared
Then make and install:
$ make -j 2
$ sudo make install
Your mpifort
and mpirun
executables will be located in /shared/openmpi_64/bin
, and the associated libraries to link FDS to will be located in /shared/openmpi_64/lib
. Make these directories available to your environment by adding to your ~/.bashrc startup file:
# MPI Library:
export MPIDIST=/shared/openmpi_64
export PATH=$MPIDIST/bin:$PATH
export LD_LIBRARY_PATH=$MPIDIST/lib:$LD_LIBRARY_PATH
Finally, either log out and log in, or open a new terminal to apply your environment changes. Check you are locating these executables:
$ which mpirun
/shared/openmpi_64/bin/mpirun
Follow the instructions provided on this wiki for Linux users.
Go to your updated repo for FDS, you should be able to build the ompi_gnu_linux
and ompi_gnu_linux_db
typing:
$ cd Build/ompi_gnu_linux
$ ./make_fds.sh
Check that the preprocessor variable -DWITH_MKL
is being passed to the compiler in both compile and link phases. For example, for the first file being compiled (prec.f90):
mpifort -c -m64 -O0 -std=f2008 -ggdb -Wall -Wcharacter-truncation -Wno-target-lifetime -fcheck=all -fbacktrace -ffpe-trap=invalid,zero,overflow -ffpe-summary=none -fall-intrinsics -cpp -DGITHASH_PP=\"FDS6.7.1-574-g5b8f8e285-master\" -DGITDATE_PP=\""Thu Jun 13 12:59:45 2019 -0400\"" -DBUILDDATE_PP=\""Jun 13, 2019 13:12:51\"" -DCOMPVER_PP=\""Gnu gfortran 9.1.0-2ubuntu2~18.04)"\" -DWITH_MKL -I/opt/intel/compilers_and_libraries_2019.4.243/linux/mkl/include ../../Source/prec.f90
Once compilation finishes you should be good to go. Make sure that your mpirun
command is the one installed previously in /shared/openmpi_64/bin
.