Science becomes extra difficult when you have to work with large numbers, complex equations, or when you need fast calculations. But in the recent years, these problems have been considerably reduced thanks to the computers and more specifically, thanks to the open-source projects focused on bringing a better understanding and experience at the time of making computations.

As a student of Physics, I use several specialized tools and most of them are open source. I am going to share one of them today which is called Elk code, an open source project focused on Solid State Physics.

Though it is available in the Ubuntu repositories, there are several dependencies you need to explicitly install and configure.

What is Elk code?

banner

In a few words and thanks to its official page, Elk code is an all-electron full-potential linearised augmented-plane wave code with a strong role inside the field of density functional theory.

What it does is to determine the properties of crystalline solids with many advanced features like geometry optimization, 2D and 3D plots, etc.

Install Intel Fortran compiler on Ubuntu

It could be a little bit hard to get started with it, but the key is on installing math libraries and compilers in your system before installing Elk code.

Compilers like GNU Fortran or Intel Fortran are available for the process, however, it’s recommended to install the Intel Fortran compiler because most of the issues inside the code are solved with it.

The Intel Fortran compiler comes in two parts:

  • The first one Intel oneAPI Base Toolkit, brings us the math libraries.
  • The second one Intel oneAPI HPC Toolkit, brings us the Fortran libraries for the correct computing of the Elk code.

Getting Intel oneAPI Base Toolkit

Let’s start! Open a terminal in Ubuntu and use the following command to download the required part:

wget https://registrationcenter-download.intel.com/akdlm/irc_nas/17977/l_BaseKit_p_2021.3.0.3219.sh

It should look like this:

intel fortran installation 1

After that, in the same terminal, type the next command:

sudo bash l_BaseKit_p_2021.3.0.3219.sh

You’ll be watching something like this on your terminal before a new window opens, don’t worry! It’s part of the process.

intel fortran installation 2

It will open a GUI interface:

intel fortran installation 3

Click on the “Continue” button, and Intel oneAPI Base Toolkit will start downloading:

intel fortran installation 4

Once the download finishes, you should see this window:

intel fortran installation 5

You will see what is included exactly in this API. It’s strongly recommended installing every package it contains. Accept the terms of the license agreement and push on the “Continue” button.

intel fortran installation 6

After that, the next page is a kind of validation one. If something is missing, it warns you.

For example, in this case, we got a warning about the GPU driver, but let’s just skip it and continue with the process, because, as we can see, the product can still be used with CPU.

So just click on the right arrow button.

intel fortran installation 7

In this part, if you have installed Eclipse IDE and want to integrate the libraries into it, select the first, otherwise, just skip the integration and click on the right arrow button. Once done, you’ll be able to see the last part before the complete installation.

intel fortran installation 8

Read the Intel Software Improvement Program and enter your choice on the collection of your information, and push the “Install” button. Finally, the installation will be starting.

intel fortran installation 9

The duration of the installation will depend on how fast your internet connection is, be patient and let Intel finish the task.

Once the task finishes, you’ll see something like this:

intel fortran installation 10

It means the installation of Intel oneAPI Base Toolkit has finished; now, let’s start with the next one.

Installing Intel oneAPI HPC toolkit

To be honest, it’s almost the same process, so it’s going to be a little bit faster.

Let’s start by using this command:

wget https://registrationcenter-download.intel.com/akdlm/irc_nas/17912/l_HPCKit_p_2021.3.0.3230.sh
intel fortran installation 11

Once the above process finishes, use the next command:

sudo bash l_HPCKit_p_2021.3.0.3230.sh
intel fortran installation 12

After that, the installation process will start like the one you saw before.

intel fortran installation 13

Click on the continue and it starts downloading:

intel fortran installation 14

Once finished (this download is really fast), the next window will appear on your desk. Accept the terms and conditions and click Continue.

intel fortran installation 15

As it was done before, let’s skip the integration of the libraries with any IDE.

intel fortran installation 16

And finally, enter your choice for the collection of your information and click on the “Install” button.

intel fortran installation 17

The libraries will start to be downloaded and installed into your system, just wait until this process finishes. Remember, the speed of the download depends on your internet connection, so be patient.

intel fortran installation 18

When the process finishes, click the Finish button.

intel fortran installation 19.png
Intel Fortran Installation step 19

And that is practically the key to the complete Elk-code installation and functionality. These two libraries are essential for the correct execution.

Configure the compilers

Finally, let’s run the next command line to start these two libraries inside the terminal:

source /opt/intel/oneapi/setvars.sh
intel fortran installation 20.png

Now go to this directory:

cd /opt/intel/oneapi/mkl/2021.3.0/interfaces

Inside this folder, you’ll find others, but the important ones are:

  • fftw2xc
  • fftw2x_cdft
  • fftw2xf
  • fftw3xc
  • fftw3x_cdft
  • fftw3xf
  • mklmpi

Inside every folder shown above, you will have to run the next command:

make libintel64

One important thing is that from now, every time you use Elk-code, you have to run the next line on your terminal to habilitate these two libraries.

source /opt/intel/oneapi/setvars.sh

With these steps before, you’re ready for the most important step, the installation of Elk-code on your Linux distribution.

Installing Elk code on Ubuntu

Let’s start downloading, of course, the Elk code, which latest version is located on the SourceForge page.

starting installation 00

Extract the downloaded folder.

starting installation 01

Now, let’s download the Wannier90 latest stable version library, which will help you to compute advanced electronic properties of materials with high efficiency and accuracy,  from its official website.

starting installation 03

Once downloaded the .tar.gz file, let’s located it on the Files app and do double click on it to extract its content.

starting installation 04

Navigate into the extracted folder and open it in the terminal.

starting installation 06

Type these commands one by one:

source /opt/intel/oneapi/setvars.sh
cp ./config/make.inc.ifort ./make.inc
make
make lib
cp libwannier.a ../elk-7.2.42/src/
cd ../
starting installation 07

We’re about to finish. Continue typing the next command on your terminal, one by one.

wget http://www.tddft.org/programs/libxc/down.php?file=5.1.4/libxc-5.1.4.tar.gz
starting installation 08

Now run these command one by one:

mv down.php?file=5.1.4%2Flibxc-5.1.4.tar.gz libxc-5.1.4.tar.gz
tar -zxvf libxc-5.1.4.tar.gz
cd libxc-5.1.4
./configure CC=icc FC=ifort
make
make check
sudo make install
cp /opt/etsf/lib/libxc.a ../elk-7.2.42/src/
cp /opt/etsf/lib/libxcf90.a ../elk-7.2.42/src/
starting installation 09

At the end of the process, you’ll have something like this on your terminal:

starting installation 10

Please, close the terminal and, finally, it’s time to do the last part, let’s go direct to the previous Elk code folder extracted. Once there, open the folder into the terminal.

starting installation 11

And type the next two commands:

source /opt/intel/oneapi/setvars.sh
cp /opt/intel/oneapi/mkl/2021.3.0/include/mkl_dfti.f90 src/

Almost there. Start the setup:

./setup

Your terminal should look like this:

starting installation 15

You write number 1 because you have installed the Intel Fortran compiler.

Don’t close the terminal; let’s return to the Elk code folder on the Files app and open the file called “make.inc”:

starting installation 16

Erase every word it contains, and enter this instead:

MAKE = make
F90 = mpiifort
F90_OPTS = -O3 -ip -xHost -qopenmp
F77 = mpiifort
F77_OPTS = -O3 -ip -xHost -qopenmp
AR = xiar
LIB_SYS =
SRC_OMP =
SRC_MPI =

LIB_LPK = -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread
#LIB_LPK = -L/opt/intel/oneapi/mkl/2021.3.0/lib/intel64 -lmkl_cdft_core -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -lmkl_blacs_intelmpi_ilp64 -liomp5 -lpthread -lm -ldl
SRC_MKL =

LIB_libxc = libxcf90.a libxc.a
SRC_libxc = libxcf90.f90 libxcifc.f90

SRC_FFT = mkl_dfti.f90 zfftifc_mkl.f90

LIB_W90 = libwannier.a
SRC_W90S =

SRC_OBLAS = oblas_stub.f90
SRC_BLIS = blis_stub.f90

Save the file and return to the terminal. Finally, just type:

make
starting installation 18

And all right! After this last step finishes, you’ll have installed Elk code on your Linux system.

Great! This last step is a little bit dilatory, but relax, it was all you have you do. You have finally finished all the processes. Congratulations!

Personal conclusion

This process could be a little bit exhaustive, but every step is very important for the correct functionality of the software. I really hope that if you are a scientist or you just want to be curious about this topic, this post results very helpful for you.

On the other hand, if you want to know more about how Elk code can help you on calculations, there is a great video about obtaining an equation of state using Elk code. Good luck!

Leave a Comment