HOWTO: compiling nwchem-6.5 beta on Ubuntu 14.04 x86-64


Click here for full thread
Gets Around
I'm assuming that you have used NWChem before but have not necessarily ever built it from source. These instructions basically work for Debian Wheezy also, though you will have to tweak the Python-related paths for Debian.

I am assuming that you already have an optimized BLAS that provides a 64 bit integer interface for use by NWChem. If that is not true, skip ahead to the next post about building OpenBLAS.

All following instructions assume that you are downloading code and compiling starting in the directory /opt/science/nwchem/. Adjust paths accordingly if you are working somewhere else, like $HOME/nwchem/.

You will need a few non-standard packages to obtain the 6.5 beta source code and build it with all bells and whistles enabled. I think this covers the packages you need that aren't installed by default:

sudo apt-get install subversion openmpi-bin libopenmpi-dev libopenmpi1.6 gfortran python-dev


You will need to get the beta code from the Subversion repository:
svn checkout https://svn.pnl.gov/svn/nwchem/branches/release-6-5-patches nwchem-6.5

You will also need to get the latest NWChem development snapshot: http://nwchemgit.github.io/download.php?f=Nwchem-dev.revision26027-src.2014-08-28.tar.gz

You need both because the src/tools/ directory is not populated in the code you check out from subversion, and you will need to replace it from the corresponding subdirectory in the snapshot. If you have nwchem-6.5 and Nwchem-dev.revision26027-src.2014-08-28.tar.gz in the same directory, do it like this:

tar xzvf Nwchem-dev.revision26027-src.2014-08-28.tar.gz
cd nwchem-6.5
rm -rf src/tools
cp -r ../Nwchem-dev.revision26027-src.2014-08-28/src/tools src


Now set a bunch of environment variables to enable all optional features and prepare for building. We're even enabling so-new-they're-undocumented features like EA-CCSD and IP-CCSD. Note that contrary to the wiki build documentation, if you want multi-reference coupled cluster capabilites you set MRCC_METHODS, not MRCC_THEORY.

export USE_NOFSCHECK=TRUE
export TCGRSH=/usr/bin/ssh
export NWCHEM_TOP=`pwd`
export NWCHEM_TARGET=LINUX64
export NWCHEM_MODULES="all python"
export LARGE_FILES=TRUE
export ENABLE_COMPONENT=yes
export PYTHONHOME=/usr
export PYTHONVERSION=2.7
export PYTHONLIBTYPE=so
export PYTHONCONFIGDIR=config-x86_64-linux-gnu
export CC=gcc
export FC=gfortran
export FOPTIMIZE="-O3 -march=native -mtune=native -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -funroll-loops -fprefetch-loop-arrays -fvariable-expansion-in-unroller -ffast-math -mfpmath=sse"
export COPTIMIZE="-O3 -march=native -mtune=native -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -funroll-loops -ffast-math -mfpmath=sse"
export HAS_BLAS=yes
export BLASOPT="-L/opt/science/openblas/64/lib -lopenblas"
export USE_MPI=y
export USE_MPIF=y
export USE_MPIF4=y
export ARMCI_NETWORK=SOCKETS
export MPI_LOC=/usr/lib/openmpi/
export MPI_LIB=/usr/lib/openmpi/lib
export MPI_INCLUDE=/usr/lib/openmpi/include
export LIBMPI="-lpthread -L$MPI_LIB -lmpi_f90 -lmpi_f77 -lmpi"
export MRCC_METHODS=y
export CCSDTQ=y
export CCSDTLR=y
export IPCCSD=y
export EACCSD=y
cd $NWCHEM_TOP/src
make clean
make nwchem_config 2>&1 | tee make.nwchem_config.log
make
cd ../contrib
./getmem.nwchem


The compiler flags are those suggested by Jeff Hammond: https://github.com/jeffhammond/HPCInfo/wiki/NWChem

This takes a while when it all goes successfully. Note especially the BLASOPT setting: if you haven't already installed OpenBLAS, and in the exact same way I did (unlikely), you will probably need to change that line.

If all builds successfully, you will find a 120 MB binary file in nwchem-6.5/bin/LINUX64. If you already have a version of NWChem installed, and you want the new version you've just built to be found when you type nwchem in a shell, adjust your PATH to put it first.