Preparing the environment for running the examples

Before running the examples in this tutorial, we need to make sure that the required programs are installed and available from the command line. The main tools used in these examples are:

Quantum ESPRESSO 
Wannier90 
pw2wannier90.x 
gnuplot

Depending on your system, these programs may already be installed. On a personal computer, they can be installed manually. On a university cluster or supercomputer, they are often available through the module system. If you cannot find them, ask your system administrator whether the required software is already installed and how to load it. In many cases, the programs are available on the cluster but are not loaded by default. If they are not installed, you can usually install and compile them yourself in your user directory.

This page gives a general guide for preparing the environment on a typical Linux cluster.

1. Check whether the programs are already available

First, check whether the required executables can be found:

which pw.x 
which bands.x 
which projwfc.x 
which wannier90.x 
which pw2wannier90.x 
which gnuplot

If the commands return valid paths, for example

/path/to/bin/pw.x 
/path/to/bin/wannier90.x

then the programs are already available in your environment.

If one or more commands return nothing, then you need either to load the appropriate modules or compile the missing programs.

2. Load the required modules on a cluster

On many clusters, software is managed through environment modules. You can see available modules using commands such as:

module avail

or search for a specific package:

module avail quantum 
module avail espresso 
module avail wannier 

The exact names of modules depend on the cluster. Therefore, students should not copy module names blindly. Instead, they should first inspect the available modules on their system.

3. Installing Wannier90 from source

If Wannier90 is not available as a module, it can be compiled from source.

First, download or clone the Wannier90 source code. Then enter the Wannier90 directory:

cd wannier90

Wannier90 uses a configuration file called:

make.inc

This file defines the compiler, compiler flags, and external libraries.

Usually, Wannier90 provides several example configuration files in the config directory. For example:

ls config/

You may find files for different compilers, such as Intel, GNU, or other systems.

Choose the file closest to your system and copy it to make.inc:

cp ./config/make.inc.ifort ./make.inc

or, for a GNU compiler setup:

cp ./config/make.inc.gfortran ./make.inc

The exact file name may differ depending on the Wannier90 version.

Edit the make.inc file

Open make.inc in a text editor:

The most important lines are the Fortran compiler and the library paths.

For an MPI build, the compiler is often set to:

F90    = mpif90 
MPIF90 = mpif90

This means that Wannier90 will be compiled using the MPI Fortran wrapper.

You also need to specify the correct BLAS/LAPACK library. On many clusters, these libraries are provided by Intel MKL or OpenBLAS.

For example, if using MKL, the library directory may look like:

LIBDIR = /path/to/mkl/lib/intel64

If using OpenBLAS, it may look like:

LIBDIR = /path/to/openblas/lib

The path must be adapted to your system.

To find the location of a loaded library module, use:

module show module_name

For example:

module show mkl 
module show openblas

This command usually prints environment variables and paths that can help you identify the correct library directory.

Compile Wannier90

After editing make.inc, compile the program:

make

If the compilation is successful, several executable files with the extension .x should appear, for example:

wannier90.x 
postw90.x 
w90chk2chk.x

Check that the executable was created:

ls *.x

Then you can either run Wannier90 directly from this directory or copy the executables to a directory included in your PATH.

For example:

mkdir -p ~/bin 
cp *.x ~/bin

Make sure that ~/bin is in your PATH:

echo $PATH

If it is not included, add the following line to ~/.bashrc:

export PATH=$HOME/bin:$PATH

Then reload the shell configuration:

source ~/.bashrc

Finally, check:

which wannier90.x

4. Installing the Quantum ESPRESSO interface pw2wannier90.x

For the examples in this tutorial, we also need the interface between Quantum ESPRESSO and Wannier90:

pw2wannier90.x

This executable is part of Quantum ESPRESSO. It is usually compiled together with Quantum ESPRESSO or can be compiled from the QE source tree.

Check whether it is available:

which pw2wannier90.x

If it is not found, you may need to compile the corresponding Quantum ESPRESSO component.

In many QE installations, the Wannier90 interface is compiled using:

make pw2wannier90

or it may be compiled together with the full QE package, depending on the version and build system.

After compilation, copy or link the executable to your ~/bin directory:

cp /path/to/pw2wannier90.x ~/bin

Then check:

which pw2wannier90.x

Test the installation

Before running the tutorial examples, it is useful to perform a simple test.

Check the main executables:

pw.x -h 
wannier90.x -h 
pw2wannier90.x -h

Some programs may print a help message. Others may simply start and stop with a short message. The important point is that the command is recognized and does not produce a “command not found” error.

You can also check the versions:

pw.x --version 
wannier90.x --version

The exact version command may depend on the program.

5. Recommended directory structure

For clarity, it is useful to organize the tutorial examples in separate folders. 

This avoids mixing files from different calculations.

Wannier90 produces many output files, such as:

d.wout 
d.mmn 
d.amn 
d.eig 
d.chk 
d_hr.dat 
d_band.dat

Keeping each example in a separate directory makes it much easier to understand which files belong to which calculation.

6. Final preparation checklist

Before starting the examples, make sure that the following commands work:

which pw.x 
which bands.x 
which projwfc.x 
which wannier90.x 
which pw2wannier90.x 
which gnuplot

Prepare the required input files. You can download them here: Example 1 and Example 2.

For the MoS2 examples, you should have files such as:

scf.in 
bands.in 
bandsx.in 
pw2wan.in 
d.win 
plot.gnu

Once these checks are complete, the system is ready for running the tutorial examples.

Next: Example 1: MoS2 Model Using 3 orbitals