Difference between revisions of "Code:libnwchem"
(→Help) |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
# push_inp_string and pop_inp_string (nw_inp_from_file.F) to fake string input as input from an nwchem parameter file |
# push_inp_string and pop_inp_string (nw_inp_from_file.F) to fake string input as input from an nwchem parameter file |
||
#* push_inp_cstring (push_inp_cstring.c) to provide a 0-terminated c-string interface to same |
#* push_inp_cstring (push_inp_cstring.c) to provide a 0-terminated c-string interface to same |
||
− | # an nwchem_init function (libnwchem.F) to perform the start-up tasks of nwchem and return its runtime database |
+ | # an nwchem_init function (libnwchem.F) to perform just the start-up tasks of nwchem.F and return its runtime database handle |
#* a libnwchem target to the GNUMakefile (sorry, no cygwin right now) |
#* a libnwchem target to the GNUMakefile (sorry, no cygwin right now) |
||
# nwchem.py, rtdb.py and related python wrappers to call nwchem's top-level functions and handle io from the rtdb |
# nwchem.py, rtdb.py and related python wrappers to call nwchem's top-level functions and handle io from the rtdb |
||
#* various fixes to error handling in rtdb |
#* various fixes to error handling in rtdb |
||
− | #* the test for a "movecs" file as proof of convergence was removed in the scf module, since the python script may change the geometry, requiring a new run of SCF despite a valid movecs file. |
||
+ | |||
+ | Warning: I've observed some strangeness with the test for a "movecs" file during SCF. If the python script changes the geometry, but the movecs file from a previous SCF calc. is left unchanged, SCF may be skipped. This results in similar property output for (actually) different structures. |
||
== Obtaining == |
== Obtaining == |
||
− | You can download the patch [ |
+ | You can download the patch [[File:libnwchem-6.5.patch.gz|here]]. Next, get the nwchem sources from the link at the top of the page. To unpack and patch them, use |
<source lang="bash"> |
<source lang="bash"> |
||
tar xjf Nwchem-6.5.revision26243-src.2014-09-10.tar.bz2 |
tar xjf Nwchem-6.5.revision26243-src.2014-09-10.tar.bz2 |
||
mv Nwchem-6.5.revision26243-src nwchem-6.5 |
mv Nwchem-6.5.revision26243-src nwchem-6.5 |
||
− | cd nwchem-6.5 |
+ | cd nwchem-6.5/src |
− | + | for i in Util_md_sockets Hbar Tcenxtask Parallelmpi Makefile_gcc4x Bcast_ccsd Elpa_syncs; do |
|
+ | wget http://www.nwchem-sw.org/images/$i.patch.gz |
||
+ | zcat $i.patch.gz | patch -p0 |
||
+ | rm -f $i.patch.gz |
||
+ | done |
||
+ | i=Hnd_giaxyz_noinline # there's always that one. |
||
+ | wget http://www.nwchem-sw.org/images/$i.patch.gz |
||
+ | zcat $i.patch.gz | (cd NWints/hondo && patch -p0) |
||
+ | rm -f $i.patch.gz |
||
+ | |||
+ | # Finally, apply the libnwchem patch. |
||
+ | zcat ../../libnwchem-6.5.patch.gz | patch -p1 |
||
+ | cd .. |
||
bash ../build-6.5.sh # the build-6.5.sh script is at the bottom of this page. |
bash ../build-6.5.sh # the build-6.5.sh script is at the bottom of this page. |
||
</source> |
</source> |
||
− | The mv line is really required, since nwchem's build can fail if the path to the source directory is too long! |
+ | The mv line is really required, since nwchem's build can fail if the path to the path to the source directory is too long! |
== Compilation == |
== Compilation == |
||
Line 56: | Line 57: | ||
export MPI_LIB=/apps/openmpi/1.4.5/lib |
export MPI_LIB=/apps/openmpi/1.4.5/lib |
||
export MPI_INCLUDE=/apps/openmpi/1.4.5/include |
export MPI_INCLUDE=/apps/openmpi/1.4.5/include |
||
− | export LIBMPI="-lpthread -lmpi_f90 -lmpi_f77 -lmpi -lopen-rte -lopen-pal -lrdmacm -libverbs |
+ | export LIBMPI="-lpthread -lmpi_f90 -lmpi_f77 -lmpi -lopen-rte -lopen-pal -lrdmacm -libverbs |
+ | -lpsm_infinipath -lnuma -ldl -Wl,--export-dynamic -lnsl -lutil -lm -ldl" |
||
export ARMCI_NETWORK=OPENIB |
export ARMCI_NETWORK=OPENIB |
||
Line 67: | Line 68: | ||
export CFLAGS="-O2 -fPIC" |
export CFLAGS="-O2 -fPIC" |
||
export MKLROOT=/apps/intel/mkl |
export MKLROOT=/apps/intel/mkl |
||
− | # see intel's link-line advisor for generating the next line. Use the options for single dynamic library. |
+ | # see intel's link-line advisor for generating the next line. Use the options for single dynamic library. |
− | + | # (the following is for MKL 10.3.6 with icc 11.1) |
|
+ | export BLASOPT="-i8 -I$MKLROOT/include/intel64/ilp64 -I$MKLROOT/include $MKLROOT/lib/intel64/libmkl_blas95_ilp64.a |
||
+ | $MKLROOT/lib/intel64/libmkl_lapack95_ilp64.a -Wl,--start-group $MKLROOT/lib/intel64/libmkl_intel_ilp64.a |
||
+ | $MKLROOT/lib/intel64/libmkl_core.a $MKLROOT/lib/intel64/libmkl_sequential.a -Wl,--end-group -lpthread -lm" |
||
# These may be helpful for compiling with CUDA, but beware - the resulting program no longer loads without cuda libraries! |
# These may be helpful for compiling with CUDA, but beware - the resulting program no longer loads without cuda libraries! |
||
Line 86: | Line 87: | ||
make nwchem |
make nwchem |
||
#make -B -C ddscf # in case you just changed something in the ddscf directory |
#make -B -C ddscf # in case you just changed something in the ddscf directory |
||
+ | cp util/cfileprefix.fh include/ |
||
make libnwchem |
make libnwchem |
||
</source> |
</source> |
||
+ | The line: '''cp util/cfileprefix.fh include/''' is required since nwchem has a really strange way of finding dependencies that works when compiling $(MAKE) stubs.o inside nwchem's target, but doesn't work when compiling $(MAKE) stubs.o inside libnwchem's target in the ''same makefile''! |
||
(on 64/32 OSX with gcc) |
(on 64/32 OSX with gcc) |
||
Line 99: | Line 102: | ||
# export PYTHONPATH=$PWD:$PYTHONPATH |
# export PYTHONPATH=$PWD:$PYTHONPATH |
||
# edit nwchem.py to make sure the CDLL() command has the right path to libnwchem.so (in a pinch, just move libnwchem.so to the current dir, and change the CDLL line to CDLL("libnwchem.so")) |
# edit nwchem.py to make sure the CDLL() command has the right path to libnwchem.so (in a pinch, just move libnwchem.so to the current dir, and change the CDLL line to CDLL("libnwchem.so")) |
||
+ | # run: mkdir scratch; mkdir perm |
||
+ | #* these two dirs are the nwchem.py default scratch and perm directories |
||
# run: python test.py |
# run: python test.py |
||
# if all goes well, you should see normal nwchem output (listing basis functions, showing geometry convergence, and ending with a citation note) |
# if all goes well, you should see normal nwchem output (listing basis functions, showing geometry convergence, and ending with a citation note) |
Latest revision as of 08:39, 22 October 2014
Libnwchem is a patch to the 6.5 Revision of NWChem that adds three useful features.
- push_inp_string and pop_inp_string (nw_inp_from_file.F) to fake string input as input from an nwchem parameter file
- push_inp_cstring (push_inp_cstring.c) to provide a 0-terminated c-string interface to same
- an nwchem_init function (libnwchem.F) to perform just the start-up tasks of nwchem.F and return its runtime database handle
- a libnwchem target to the GNUMakefile (sorry, no cygwin right now)
- nwchem.py, rtdb.py and related python wrappers to call nwchem's top-level functions and handle io from the rtdb
- various fixes to error handling in rtdb
Warning: I've observed some strangeness with the test for a "movecs" file during SCF. If the python script changes the geometry, but the movecs file from a previous SCF calc. is left unchanged, SCF may be skipped. This results in similar property output for (actually) different structures.
Contents
Obtaining
You can download the patch File:Libnwchem-6.5.patch.gz. Next, get the nwchem sources from the link at the top of the page. To unpack and patch them, use
<source lang="bash"> tar xjf Nwchem-6.5.revision26243-src.2014-09-10.tar.bz2 mv Nwchem-6.5.revision26243-src nwchem-6.5 cd nwchem-6.5/src for i in Util_md_sockets Hbar Tcenxtask Parallelmpi Makefile_gcc4x Bcast_ccsd Elpa_syncs; do
wget http://www.nwchem-sw.org/images/$i.patch.gz zcat $i.patch.gz | patch -p0 rm -f $i.patch.gz
done i=Hnd_giaxyz_noinline # there's always that one. wget http://www.nwchem-sw.org/images/$i.patch.gz zcat $i.patch.gz | (cd NWints/hondo && patch -p0) rm -f $i.patch.gz
- Finally, apply the libnwchem patch.
zcat ../../libnwchem-6.5.patch.gz | patch -p1 cd .. bash ../build-6.5.sh # the build-6.5.sh script is at the bottom of this page. </source> The mv line is really required, since nwchem's build can fail if the path to the path to the source directory is too long!
Compilation
For most Linux systems (but not BSD-based OSX), the -fPIC flag is required. This is such a PITA to add to nwchem's compilation that my solution is an ugly hack. Replace the real compiler with a shell script in your $HOME/bin directory, and make sure your path has $HOME/bin in front of all other directories.
(for icc) <source lang="bash">
- !/bin/sh
- file $HOME/bin/icc
/opt/intel/bin/icc -fPIC $@ </source>
(or gcc) <source lang="bash">
- !/bin/sh
- file $HOME/bin/gcc
/usr/bin/gcc -fPIC $@ </source>
I use the following script for compiling NWChem:
(on 64-bit Linux with icc) <source lang="bash">
- !/bin/bash
- file build-6.5.sh
export NWCHEM_TOP=$HOME/build/nwchem-6.5 export NWCHEM_TARGET=LINUX64
export NWCHEM_MODULES=all
export USE_MPI=y export USE_MPIF=y export USE_MPIF4=y export MPI_LIB=/apps/openmpi/1.4.5/lib export MPI_INCLUDE=/apps/openmpi/1.4.5/include export LIBMPI="-lpthread -lmpi_f90 -lmpi_f77 -lmpi -lopen-rte -lopen-pal -lrdmacm -libverbs -lpsm_infinipath -lnuma -ldl -Wl,--export-dynamic -lnsl -lutil -lm -ldl"
export ARMCI_NETWORK=OPENIB
- export IB_INCLUDE <Location of Infiniband libraries>/include
export MSG_COMMS=MPI export CC=icc export FCC=ifort export FOPTIMIZE="-O2 -fPIC" export FFLAGS="-O2 -fPIC" export CFLAGS="-O2 -fPIC" export MKLROOT=/apps/intel/mkl
- see intel's link-line advisor for generating the next line. Use the options for single dynamic library.
- (the following is for MKL 10.3.6 with icc 11.1)
export BLASOPT="-i8 -I$MKLROOT/include/intel64/ilp64 -I$MKLROOT/include $MKLROOT/lib/intel64/libmkl_blas95_ilp64.a $MKLROOT/lib/intel64/libmkl_lapack95_ilp64.a -Wl,--start-group $MKLROOT/lib/intel64/libmkl_intel_ilp64.a $MKLROOT/lib/intel64/libmkl_core.a $MKLROOT/lib/intel64/libmkl_sequential.a -Wl,--end-group -lpthread -lm"
- These may be helpful for compiling with CUDA, but beware - the resulting program no longer loads without cuda libraries!
- export TCE_CUDA=n
- export CUDA=$CUDA_HOME/bin/nvcc
- export CUDA_FLAGS="-arch=sm_35"
- export CUDA_INCLUDE="-I$CUDA_HOME/include"
- export CUDA_LIBS="-L$CUDA_HOME/lib64 -lcudart -lcufft"
- -L/usr/X11R6/lib -lGL -lGLU -lX11 -lXi -lXmu -lglut -lGLEW
cd $NWCHEM_TOP/src
- make realclean # These two lines let you start again (theoretically).
- find . -name dependencies -exec rm {} \; -print
make nwchem_config make nwchem
- make -B -C ddscf # in case you just changed something in the ddscf directory
cp util/cfileprefix.fh include/ make libnwchem </source> The line: cp util/cfileprefix.fh include/ is required since nwchem has a really strange way of finding dependencies that works when compiling $(MAKE) stubs.o inside nwchem's target, but doesn't work when compiling $(MAKE) stubs.o inside libnwchem's target in the same makefile!
(on 64/32 OSX with gcc)
to appear!
Testing
Inspecting the patch file, you will notice that the python wrapper was added into the src/python directory. It also includes a simple test (test.py), which opens libnwchem.so from its compiled location and does geometry optimization on a water molecule. To use it yourself,
- cd to nwchem-6.5/src/python
- export PYTHONPATH=$PWD:$PYTHONPATH
- edit nwchem.py to make sure the CDLL() command has the right path to libnwchem.so (in a pinch, just move libnwchem.so to the current dir, and change the CDLL line to CDLL("libnwchem.so"))
- run: mkdir scratch; mkdir perm
- these two dirs are the nwchem.py default scratch and perm directories
- run: python test.py
- if all goes well, you should see normal nwchem output (listing basis functions, showing geometry convergence, and ending with a citation note)
Help
The patch is released without any warranty or indeed any guarantee of working at all. If you have lots of ($$$) around, shoot me an email.