Installation of NWChem on RHEL & CentOS

Installation of NWChem on RHEL & CentOS

NWChem is one of the most powerful quantum chemistry and molecular dynamics program packages. It is robust, flexible, and fast, especially running on high performance computer cluster (HPC). In this post, I would like to share how to install NWChem on RHEL-based Linux distribution including RHEL and CentOS. However, I wish the step can be applied to other Linux distro as well.

Herein, there are three strategies which are not too difficult for the beginners. For the first two ways, you have to deal with source code directly. You can install NWChem either by compiling source code manually or using my program to compile NWChem automatically. The last one is the use of RHEL's package managers: yum and rpm. They can install you a ready-to-use NWChem executable (compiled binary) file. Although the last way is easier and more convenient than the first two ways, but a pre-built NWChem binary was compiled with a default setting in which some modules or special computational methods were not included.

Which way should I walk through ?

  • Choose the first way if you are familiar with Linux commands or/and have experienced with program compilation. Note that root or sudo permission is required for prerequisite installation.
  • Choose the second way if you want to use my program, "Automatic NWChem Compilation". This program will help you to set up compilation configuration and detect the optimal computational environments of your system.
  • Choose the third way if you want just a compact pre-build NWChem. Note that root/sudo permission is also required.

NWChem official website

If you have any problems, go to NWChem forum, and post your question there.

Installations

1. Compile NWChem from Source Code

To manually install NWChem, you need to set all necessary environment variables before building a NWChem binary file. You may write a bash or simple scripts to set up configuration compilations.

Step 1. Install prerequisites packages (for RHEL & CentOS):

yum install python-devel gcc-gfortran openblas-devel openblas-serial64 openmpi-devel scalapack-openmpi-devel elpa-openmpi-devel tcsh openssh-clients which

Step 2. Download program source code.

Change to directory where you want to download the NWChem tarball to and use the following command to download file:

wget https://github.com/nwchemgit/nwchem/releases/download/6.8.1-release/nwchem-6.8.1-release.revision-v6.8-133-ge032219-src.2018-06-14.tar.bz2

Wait until download completes.

Step 3. Uncompress the tarball:

tar -xvf nwchem*.tar.bz2

Step 4. Create script that contains all necessary environment variable settings.

The following website is a good place to learn how to create the script: https://github.com/nwchemgit/nwchem/wiki.

Additionally, I posted a tons of example of bash script on my GitHub repository: https://github.com/rangsimanketkaew/NWChem.

Those scripts should work for your RHEL-based 64 bit machine. You can adjust the code as you need.

Step 5. My install script looks like this:

#!/bin/bash

##############################################################################################
# Program for NWChem compilation on CentOS with OpenMPI compiled by GNU Fortran              #
# Written by Rangsiman Ketkaew (MSc student in Chemistry), Thammasat University, Thailand.   #
##############################################################################################

export NWCHEM_TOP=/builddir/build/BUILD/nwchem-6.8
export NWCHEM_TARGET=LINUX64
export CC=gcc
export FC=gfortran
export USE_ARUR=TRUE
export USE_NOFSCHECK=TRUE
export NWCHEM_FSCHECK=N
export LARGE_FILES=TRUE
export MRCC_THEORY=Y
export EACCSD=Y
export IPCCSD=Y
export CCSDTQ=Y
export CCSDTLR=Y
export NWCHEM_LONG_PATHS=Y
export PYTHONHOME=/usr
export PYTHONVERSION=2.7
export PYTHONLIBTYPE=so
export USE_PYTHON64=y
export HAS_BLAS=yes
export BLASOPT="-L/usr/lib64 -lopenblas"
export BLAS_SIZE=4
export MAKE=/usr/bin/make
export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib
export USE_MPI=y
export USE_MPIF=y
export USE_MPIF4=y
export MPIEXEC=/usr/lib64/openmpi/bin/mpiexec
export MPI_LIB=/usr/lib64/openmpi/lib
export MPI_INCLUDE=/usr/include/openmpi-x86_64
export LIBMPI="-lmpi -lmpi_f90 -lmpi_f77"

$MAKE nwchem_config NWCHEM_MODULES="all python" 2>&1 | tee ../make_nwchem_config_openmpi.log
$MAKE 64_to_32 2>&1 | tee ../make_64_to_32_openmpi.log
export MAKEOPTS="USE_64TO32=y"
$MAKE ${MAKEOPTS} 2>&1

Save as shell script (*.sh) and name file that "compile-nwchem68-openmpi.sh".

Step 6. Execute script, for example, in my case I use bash, so I run command like this:

./compile-nwchem68-openmpi.sh

Step 7. If installation is completed without any error, there must be nwchem binary file at $NWCHEM_TOP/bin/LINUX64/ directory. Use the following command to check is nwchem exists:

ls -lh $NWCHEM_TOP/bin/LINUX64/nwchem

Step 8. Create NWChem resource file and name it ".nwchemrc" (start with a full stop and without double quotation marks). The .nwchemrc file should look like this:

nwchem_basis_library /home/rangsiman/nwchem-6.8.1/src/basis/libraries/
ffield amber
amber_1 /home/rangsiman/nwchem-6.8.1/src/data/amber_s/
amber_2 /home/rangsiman/nwchem-6.8.1/src/data/amber_x/
amber_3 /home/rangsiman/nwchem-6.8.1/src/data/amber_q/
amber_4 /home/rangsiman/nwchem-6.8.1/src/data/amber_u/
charmm_s /home/rangsiman/src/data/charmm_s/
charmm_x /home/rangsiman/nwchem-6.8.1/src/data/charmm_x/

Step 9. Test program by a single CPU core and multiple CPU cores:

cd $NWCHEM_TOP/src

- Single run

$NWCHEM_TOP/bin/LINUX64/nwchem nwchem.nw

- Parallel run

mpirun -np 4 $NWCHEM_TOP/bin/LINUX64/nwchem nwchem.nw

Step 10. If NWChem run smoothly without any error, Congratulations!


Optional: Enable Compilation of NWChem with CUDA

The following environment variable should be set to navigate CUDA configuration:

-I<Your Path to cuda>/include"

Examples

export TCE_CUDA=Y 
export CUDA_LIBS="-L/usr/local/cuda-5.0/lib64 -L/usr/local/cuda-5.0/lib -lcudart" 
export CUDA_FLAGS="-arch sm_20 " 
export CUDA_INCLUDE="-I. -I/usr/local/cuda-5.0/include"

You may use this command for compile:

make FC=<fortran compiler> CUDA=nvcc

Credit and example of CUDA test: http://www.nwchem-sw.org/index.php/Release66:TCE#CCSD.28T.29_method_with_CUDA

2. Compile NWChem using Automatic NWChem Compilation

I wrote an automatic program to compile NWChem from source code, called "Automatic NWChem Compilation". It was written in Bourne shell, which should run on any Linux platform, especially RHEL-based and Ubuntu-based OS. This program will build you an NWChem executable binary with Message Passing Interface (MPI) protocol and Python 2.x for both single and parallel run.

Prerequisites

  • Linux distribution: RHEL, CentOS, Ubuntu
  • BLAS library
  • Python 2.6 or 2.7
  • Choose one of the following MPI libraries.
  • Choose one of the following C/C++/Fortran compilers
  • More details please consult NWChem manual

Step 1. Create working directory for NWChem installation :

mkdir nwchem-install && cd nwchem-install

Step 2. Download the tarball of Automatic NWChem Compilation from https://github.com/rangsimanketkaew/NWChem/releases to your Linux using wget command:

wget https://github.com/rangsimanketkaew/NWChem/releases/download/v2.0/Automatic-NWchem-Compilation-2.0.tar.gz

Step 3. Uncompress tarball file:

tar -xzvf Automatic-NWchem-Compilation-2.0.tar.gz

Step 3. Change permission of all files and then move then to the working directory:

chmod +x -R ./Automatic-NWchem-Compilation-2.0
cd Automatic-NWchem-Compilation-2.0

Step 4. Execute program and follow the built-in instruction of compilation step-by-step:

./Automatic-NWChem-Compile.sh

Screenshot of program interface is shown above.

Step 5. Select 1 to see if your Linux has MPI library and check the current version of MPI library that being available:

Enter Your Choice: 1
- Linux distribution version   : CentOS release 6.5 (Final)
- MPI architecture and version : mpirun (Open MPI) 2.0.2
- Fortran Compiler libraries   : -lmpi_usempif08 -lmpi_usempi_ignore_tkr -lmpi_mpifh -lmpi

Step 6. Select 2 and enter all necessary environments:

Enter Your Choice: 2
Enter absolute path of NWChem source code, e.g. /home/rangsiman/nwchem-6.8.1/: /home/rangsiman/nwchem-6.8.1/
Enter version of Python you are using, e.g. 2.6: 2.6
Enter absolute path of Python directory, e.g. /usr/: /usr/

Step 7. Configuration compilation as shown below will be saved as a shell file called "configure_nwchem_compile.sh".

# ------------------------- NWCHEM Location -------------------------
export NWCHEM_TOP=/home/rangsiman/nwchem-6.8.1/
export NWCHEM_TARGET=LINUX64
# ------------------------- NWCHEM Functionality --------------------
export USE_NOFSCHECK=TRUE
export NWCHEM_FSCHECK=N
export LARGE_FILES=TRUE
export MRCC_THEORY=Y
export EACCSD=Y
export IPCCSD=Y
export CCSDTQ=Y
export CCSDTLR=Y
export NWCHEM_LONG_PATHS=Y
# ------------------------- MPI libraries ---------------------------
export USE_MPI=y
export USE_MPIF=y
export USE_MPIF4=y
export MPI_LOC=/share/apps/mpi/mvapich2-2.2b_intel2013
export MPI_LIB=/lib
export MPI_INCLUDE=/include
export MPIEXEC=/bin/mpiexec
export LIBMPI=""
export PATH=/bin/:$PATH
export LD_LIBRARY_PATH=/lib/:$LD_LIBRARY_PATH
# ------------------------- Python Libraries ------------------------
export USE_PYTHONCONFIG=y
export PYTHONVERSION=2.6
export PYTHONHOME=/usr/
export USE_PYTHON64=y
export PYTHONLIBTYPE=so
# ------------------------- MATH libraries --------------------------
export USE_64TO32=y
export BLAS_SIZE=4
export BLASOPT="-lopenblas -lpthread -lrt"
# ------------------------- Compile ---------------------------------
make nwchem_config NWCHEM_MODULES="all python" >& compile-config.log
make -j4 64_to_32 >& compile-64_to_32.log
export MAKEOPTS="USE_64TO32=y"
make -j4  >& compile-make-nwchem.log

Step 8. Enter "YES" to start installation:

=====================================================================
Install NWChem version 6.8.1 with Message Passing Interface (MPI)

Configuration compilation has been saved.
Please check /home/rangsiman/configure_nwchem_compile.sh
=====================================================================

Enter YES to start compiling: y

Wait until installation is completed. This can take almost 30 minutes.

 Start to compile NWChem ...

 Building NWChem executable ... This will take 20-30 minutes.
 Please do not close this terminal.

Step 9. If installation is completed without any error, there must be nwchem binary file at $NWCHEM_TOP/bin/LINUX64/ directory.

 ------------------------ Compile done --------------------------

 Congratulations !  NWChem is compiled as executable successfully.

 It can be found at /home/rangsiman/nwchem-6.8.1/bin/LINUX64/nwchem
 Log file is at /home/rangsiman/nwchem-6.8.1/src/compile*.log

Step 10. Select 3 to create NWChem resource files:

Enter Your Choice: 3
Enter absolute path of NWChem top directory, e.g. /home/rangsiman/nwchem-6.8.1: /home/rangsiman/nwchem-6.8.1
NWChem resouce file has been created: /home/rangsiman/.nwchemrc

Step 11. Test program for single and parallel runs:

cd $NWCHEM_TOP/src
$NWCHEM_TOP/bin/LINUX64/nwchem nwchem.nw
mpirun -np 4 $NWCHEM_TOP/bin/LINUX64/nwchem nwchem.nw

Step 12. Congratulations !

3. Install NWChem using package manager

3.1 Install using yum

If you do not want to compile NWChem using Script, you can use do that by using yum command for install NWChem instead.

Install NWChem by this way can prevent the problem about the dependence and library.

Step 1. Use yum to show all available package of NWChem.

yum list --enablerepo=epel nwchem*

Example of output is as follows:

Available Packages
nwchem.x86_64                                     6.6.27746-22.el6                         epel
nwchem-common.noarch                              6.6.27746-22.el6                         epel
nwchem-mpich.x86_64                               6.6.27746-22.el6                         epel
nwchem-openmpi.x86_64                             6.6.27746-22.el6                         epel

Step 2. Install NWChem that was compiled with OpenMPI using command:

sudo yum install --enablerepo=epel nwchem-openmpi 

or

sudo yum install --enablerepo=epel nwchem-mpich.x86_64

Press yes or y to start installation and wait for a while.


3.2 Install using rpm

Instead of yum, you can use RPM (rpm). Binary rpm of NWChem can be found at pkgs.org --> https://pkgs.org/download/nwchem.

Choose the version of binary file carefully, it should satisfy your Linux distribution.

For example, I am using CentOS and I have successively installed ga-common (global array), ga-openmpi, nwchem-common, and nwchem-openmpi.

Step 1. Download binary rpm of all packages, for example, NWChem 6.6, using following commands:

Step 2. Change permission of binary files using command:

chmod +x *.rpm

Step 3. Install the packages using following commands (root or sudo is required):

rpm -ivh ga-common-5.3b-14.el7.noarch.rpm
rpm -ivh ga-openmpi-5.3b-14.el7.x86_64.rpm
rpm -ivh nwchem-common-6.6.27746-22.el7.noarch.rpm
rpm -ivh nwchem-openmpi-6.6.27746-22.el7.x86_64.rpm

Trick: You can install nwchem-mpich after you finished installing nwchem-common.

If installation is done without any error, check where the NWChem executable binary file is installed using command:

rpm -qi --filesbypkg nwchem-openmpi

On my cluster, NWChem is installed at /usr/lib64/openmpi/bin/nwchem-openmpi.

Post-Compilation

1. Create the NWChem resource file called .nwchemrc under the home directory:

vi $HOME/.nwchemrc

2. The resource file should look like this:

nwchem_basis_library /home/rangsiman/nwchem-6.8.1/src/basis/libraries/
ffield amber
amber_1 /home/rangsiman/nwchem-6.8.1/src/data/amber_s/
amber_2 /home/rangsiman/nwchem-6.8.1/src/data/amber_x/
amber_3 /home/rangsiman/nwchem-6.8.1/src/data/amber_q/
amber_4 /home/rangsiman/nwchem-6.8.1/src/data/amber_u/
charmm_s /home/rangsiman/src/data/charmm_s/
charmm_x /home/rangsiman/nwchem-6.8.1/src/data/charmm_x/

3. Test program:

cd $NWCHEM_TOP/src
$NWCHEM_TOP/bin/LINUX64/nwchem nwchem.nw

Error and Solution

For error during compilation and solution, please visit this page first Error and Solution.

References

If you have any technical problems regarding NWChem functionality or problematic error during compilation, please post your error & question at NWChem forum. If you have a problem about the Automatic NWChem Compilation program, please talk to me by e-mail: rangsiman1993@gmail.com.


Enjoy NWChem!
Enjoy NWChem!
Enjoy NWChem!


Rangsiman Ketkaew