Friday, October 29, 2010

using compiler wrappers to compile nwchem

See this discussion for reference.

It is difficult but possible to build nwchem with MKL. However, You may not be going down the same path as I. First building mpich2 with ifort using FC=ifort.
Then using ifort indirectly by using the compiler wrappers with FC=mpif90 .

In my case mpich2 is installed at /usr/local/mpich2-ifort so I created a local file: /etc/ld.so.conf.d/mpich2-local.conf containing:
[code]
/usr/local/mpich2-ifort/lib
/usr/local/mpich2-ifort/lib/trace_rlog
[/code]

Remember to run ldconfig before trying to compile nwchem.

Here is my script for building on a RedHat 5 system:

#!/bin/bash
##
# By Anna Jonna Ármannsdóttir
## INTEL Fortran
## NWCHEM 6.0
# PATH=/usr/local/mpich2-ifort/bin:${PATH}
export CHEM="nwchem-6.0"
export LIBMPI="-L/usr/local/mpich2-ifort/lib -lmpich "
export PYTHONHOME=/usr
export PYTHONVERSION="2.4"
export USE_PYTHON64="y"
export PYTHONPATH=/usr
export NWCHEM_TOP="/scratch/$CHEM"
export SKRA="$NWCHEM_TOP"
export NWCHEM_MODULES="all python"
export NWCHEM_TARGET=LINUX64
export F77=mpif77
export FC=mpif90
export USE_MPI=y
export USE_MPIF=n
export MSG_COMMS=MPI
export LARGE_FILES=TRUE
export LIB_DEFINES=-DDFLT_TOT_MEM=16777216
export BLASOPT="-L/opt/intel/Compiler/11.1/073/mkl/lib/em64t -lguide -lmkl_lapack -lmkl_core -lmkl_sequential -lsvml -lirc"

cd /tmp && rm -rf ${SKRA} /nonexist && cd /scratch && \
( gzip -dc | tar xf - ) <$CHEM.tar.gz echo $NWCHEM_TOP echo $NWCHEM_MODULES echo $LIBMPI cd $NWCHEM_TOP/src/ && make nwchem_config 2>&1 | tee configure.log && make -j 4 2>&1 | tee make.log
# the commands call a program named smallversion.pl but the location of the program is not in the path. dot slash is the local path.
PATH="./:$PATH"
cd $NWCHEM_TOP/src/util && make smallversion && make
cd $NWCHEM_TOP/src && make link
# cd $NWCHEM_TOP/contrib getmem.nwchem
# cp /scratch/nwchem-6.0/bin/LINUX64/* /usr/local/mpich2-ifort/bin/

Bash script for bulk renaming files

In Linux, logs should be compressed with bzip2 at highest compression.

Usually they are compressed with gzip and filenames end in .gz . To achieve bzip2 compression, I put this in the logrotate configuration file:

compresscmd /bin/bzip2
compressoptions "-9"

That operation was a success but the patient almost died. The files did not get the correct file suffix that should have been .bz2 . So I wrote a script to do that automatically once and for all.

for SKRA in *.gz ; do
[ "$(file --mime-type --brief $SKRA)" == 'application/x-bzip2' ] && ( mv $SKRA ${SKRA/.gz/.bz2} );
done



In order to ensure that the files would get the right filename, I put this into the logrotate configuration:

compresscmd /bin/bzip2
uncompresscmd /bin/bunzip2
compressoptions "-9"
compressext .bz2