Here's how to compile cpmd on Wheezy. CPMD is the standard implementation of ab initio Carr-Parrinello method for molecular dynamic and would thus be useful to have at hand.
It took a fair while to hammer out the method, so this post might not read very well. Right now I'm having crashes after the binary has been running for a while -- this point towards system resources more than anything else.
WARNING:
This involves patching a file -- you never know IF that causes problems with the output. To the best of my knowledge, it should be safe.
There's no reason to think that Ubuntu and Linux mint won't work just as well (i.e. you may want to look here if you're trying to compile for Ubuntu or Mint)
Errors I encountered on the road are found at the end of the post together with solutions.
COMPILING THE BINARY
First you need to request a username and password from http://cpmd.org/. That'll take a few days.
You may have to install libopenmpi-dev libfftw3-dev libblas-dev first
Once your application is approved and you've downloaded your file (in my case cpmd-v3_15_3.tar.gz) copy it to ~/tmp, then
tar -xvf cpmd-v3_15_3.tar.gz
cd CPMD/CONFIGURE
create CONFIGURE/LINUX-x86_64-DEBIAN
IRAT=2 CFLAGS='-c -O2 -Wall' CPP='/lib/cpp -P -C -traditional' CPPFLAGS='-D__Linux -D__PGI -D__GNU -DFFT_FFTW3 -DPARALLEL -DPOINTER8' FFLAGS='-c -O2 -fcray-pointer -fno-whole-file -fsecond-underscore' LFLAGS='-lfftw3 -lfftw3f -I/usr/include -lblas -llapack -lpthread -lmpi' FFLAGS_GROMOS=' $(FFLAGS)' FC='mpif77 -fbounds-check' CC='mpicc' LD='mpif77 -fbounds-check'
cd ../
Edit the following lines in wfnio.F and change them to:
./mkconfig.sh LINUX-x86_64-DEBIAN > MakefileEdit the following lines in wfnio.F and change them to:
15 CHARACTER(len=*) TAG
63 IF(TAG(1:2).EQ.'NI') THEN
201 IF(TAG(1:2).NE.'NI') THEN
271 IF(TAG(1:2).EQ.'NI') THEN
(See below for the reasons why)
make -j5
You should now have a working binary. This was a real PITA to sort out.
sudo mkdir /opt/cpmd
sudo chown $USER /opt/cpmd
cp cpmd.x /opt/cpmd
Done! Almost...
Time to get some pseudopotential files from http://cpmd.org/download
Download the following files:
http://cpmd.org/downloadable-files/authentication/contributions/pseudo_std.tar.gzAnd some test files:
http://cpmd.org/downloadable-files/authentication/contributions/pseudo_ext.tar.gz
http://cpmd.org/downloadable-files/authentication/contributions/pseudo_vdb.tar.gz
http://cpmd.org/downloadable-files/authentication/contributions/cpmd-test.tar.gzPut them in /opt/cpmd
cd /opt/cpmd
ls *.gz|xargs -I {} tar xvf {}
echo "export PP_LIBRARY_PATH=/opt/cpmd/PP_LIBRARY" >>~/.bashrc
echo "export PATH=$PATH:/opt/cpmd" >>~/.bashrc.
source ~/.bashrc
Note:
For some reason cpmd refuses to read my pseudopotential files unless I remove the .psp ending. Doesn't matter how eagerly I'm trying to point cpmd in the right direction. You can quickly mv all the psp files like this:
cp /opt/cpmd/pseudo_extlib/*.psp /opt/cpmd/PP_LIBRARY/
cd /opt/cpmd/PP_LIBRARY/
ls *.psp|sed 's/\./\t/g'|gawk '{print $1}'|xargs -I {} mv {}.psp {}
mv Cu_MT_PBE_SEMI_2.08.psp Cu_MT_PBE_SEMI_2.08
mv Ga.1_GO_LDA.psp Ga.1_GO_LDA
Not that this will guarantee that it'll work. I often find myself putting the full relative path in the .in file:
&ATOMS
*../../PP_LIBRARY/O_MT_PBE KLEINMAN-BYLANDER
LMAX=P
Anyway
Test your binary
cd /opt/cpmd/CPMD-test/vdw
mpirun -n 4 cpmd.x ch4-ch4.inp
****************************************************************
* *
* TIMING *
* *
****************************************************************
SUBROUTINE CALLS CPU TIME ELAPSED TIME
HIP 12 19.64 21.55
FFT-G/S 734 11.94 12.02
GCENER 12 4.82 4.86
FWFFT 72 4.80 4.85
INVFFTN 100 3.93 3.93
INVFFT 61 3.82 3.86
HOCKNEY 1 3.20 3.31
FFTCOM 133 2.34 2.33
VPSI 21 2.22 2.20
FWFFTN 56 2.14 2.15
XCENER 12 1.70 1.71
RHOOFR 11 1.59 1.61
GRADEN 12 1.58 1.58
PHASE 133 1.46 1.43
LOADPA 1 1.30 1.31
ODIIS 11 0.96 0.99
N-FFTCOM 156 0.80 0.82
VOFRHOH 12 0.61 0.62
VOFRHOB 12 0.57 0.57
EICALC 12 0.43 0.43
NUMPW 1 0.31 0.31
ATRHO 1 0.26 0.29
----------------------------------------------------------------
TOTAL TIME 70.43 72.74
****************************************************************
CPU TIME : 0 HOURS 1 MINUTES 11.75 SECONDS
ELAPSED TIME : 0 HOURS 1 MINUTES 14.21 SECONDS
*** CPMD| SIZE OF THE PROGRAM IS 141512/ 484936 kBYTES ***
PROGRAM CPMD ENDED AT: Thu Jul 19 12:50:17 2012
================================================================
= COMMUNICATION TASK AVERAGE MESSAGE LENGTH NUMBER OF CALLS =
= SEND/RECEIVE 370967. BYTES 51. =
= BROADCAST 10413. BYTES 297. =
= GLOBAL SUMMATION 1153. BYTES 190. =
= GLOBAL MULTIPLICATION 0. BYTES 1. =
= ALL TO ALL COMM 8815282. BYTES 313. =
= PERFORMANCE TOTAL TIME =
= SEND/RECEIVE 3014.256 MB/S 0.006 SEC =
= BROADCAST 271.033 MB/S 0.011 SEC =
= GLOBAL SUMMATION 1.996 MB/S 0.220 SEC =
= GLOBAL MULTIPLICATION 0.000 MB/S 0.001 SEC =
= ALL TO ALL COMM 643.149 MB/S 4.290 SEC =
= SYNCHRONISATION 0.067 SEC =
================================================================
Almost completely and utterly done.
There are a few more things to do for a full install:
1. cpmd2cube
Download cpmd2xyz-scripts.xyz and cpmd2cube.tar.gz and put them in ~/tmp
cd ~/tmp
tar xvf cpmd2cube.tar.gz
cd cpmd2cube/
./Configure Linux-PC-GFORTRAN-FFTW >Makefile
Edit the Makefile
11 #--------------- Configuration
12 FC = mpif77
13 FFLAGS = -ffree-form -D__GFORTRAN -DFFT_FFTW3 -std=gnu -O2 -fno-whole-file
14 LFLAGS =
15 LIBS = -lfftw3
Then compile:
make
cp *.x /opt/cpmd/
2. cpdm2xyz-scripts
tar xvf cpmd2xyz-scripts.tar.gz
mv *xyz.pl /opt/cpmd/
ERRORS I encountered on the way to success:
Why I patched wfnio.F
(K+E1+L+N+X) TOTAL ENERGY = -15.69316800 A.U.
(K) KINETIC ENERGY = 11.26654720 A.U.
(E1=A-S+R) ELECTROSTATIC ENERGY = -14.51438081 A.U.
(S) ESELF = 15.95769122 A.U.
(R) ESR = 0.61466148 A.U.
(L) LOCAL PSEUDOPOTENTIAL ENERGY = -8.04105016 A.U.
(N) N-L PSEUDOPOTENTIAL ENERGY = 1.58864226 A.U.
(X) EXCHANGE-CORRELATION ENERGY = -5.99292649 A.U.
GRADIENT CORRECTION ENERGY = -0.34038005 A.U.
NFI GEMAX CNORM ETOT DETOT TCPU
1 2.271E-02 2.070E-03 -15.693168 0.000E+00 12.31
2 2.968E-03 6.595E-04 -16.042408 -3.492E-01 12.23
3 2.302E-03 2.795E-04 -16.073138 -3.073E-02 12.41
4 1.202E-03 1.028E-04 -16.079251 -6.113E-03 13.11
5 5.911E-04 3.645E-05 -16.080017 -7.655E-04 12.86
6 2.152E-04 1.926E-05 -16.080119 -1.020E-04 12.27
7 7.666E-05 8.749E-06 -16.080151 -3.277E-05 12.24
8 4.416E-05 4.054E-06 -16.080159 -8.141E-06 12.54
9 2.411E-05 1.531E-06 -16.080162 -2.318E-06 12.14
10 1.203E-05 5.610E-07 -16.080162 -3.935E-07 12.22
11 6.744E-06 2.833E-07 -16.080162 -3.662E-08 12.31
At line 2 of file ./wfnio.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'tag' (2/10)
Line 2 in wfnio.f is SUBROUTINE W_WFNIO(NW,IERROR,NSTATE,C,TAG)
I tried compiling with my own openblas libraries:
Used the following config file base:
IRAT=2
CFLAGS='-c -O1 -Wall'
CPP='/lib/cpp -P -C -traditional'
CPPFLAGS='-D__Linux -D__PGI -D__GNU -DFFT_FFTW -DPOINTER8 -DPARALLEL'
FFLAGS='-c -O2 -fcray-pointer -fno-whole-file -fsecond-underscore'
LFLAGS='-L/opt/fftw/fftw-2.1.5/double/lib -l:libfftw.a -I/opt/fftw/fftw-2.1.5/double/include -I/usr/include -L/opt/openblas/lib -lopenblas'
FFLAGS_GROMOS=' $(FFLAGS)'
FC='mpif90'
CC='mpicc'
LD='mpif90'
Tested with:
! Wavefunction optimization using default setting
!
&CPMD
OPTIMIZE WAVEFUNCTION
&END
&SYSTEM
SYMMETRY
1
CELL
10.2612 1.0 1.0 0.0 0.0 0.0
CUTOFF
13.
&END
&ATOMS
*SI_SGS KLEINMAN-BYLANDER
LMAX=P
8
.00000 .00000 .00000 1
.00000 5.13000 5.13000 1
5.13000 .00000 5.13000 1
5.13000 5.13000 .00000 1
2.56500 2.56500 2.56500 1
2.56500 7.69500 7.69500 1
7.69500 2.56500 7.69500 1
7.69500 7.69500 2.56500 1
&END
And here's the output (NOTE: it wouldn't have worked anyway due to missing pseudopot files. But that's unrelated):
PROGRAM CPMD STARTED AT: Wed Jul 18 20:41:51 2012SETCNST| USING: CODATA 2006 UNITS
[LOTS OF STUFF CUT OUT]EXCHANGE CORRELATION FUNCTIONALSLDA EXCHANGE: NONELDA XC THROUGH PADE APPROXIMATIONS.GOEDECKER, J.HUTTER, M.TETER PRB 54 1703 (1996)Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:#0 0x2B3D01CFA667#1 0x2B3D01CFAC34#2 0x2B3D026F64EF#3 0x2B3CFFD8CBF7Segmentation fault
Valgrind told me:
EXCHANGE CORRELATION FUNCTIONALS
LDA EXCHANGE: NONE
LDA XC THROUGH PADE APPROXIMATION
S.GOEDECKER, J.HUTTER, M.TETER PRB 54 1703 (1996)
==1406== Invalid read of size 8
==1406== at 0x59D0BF7: dcopy_k (in /opt/openblas/lib/libopenblas_barcelona-r0.1.1.so)
==1406== by 0x485152: setsc_ (in /home/me/tmp/CPMD/cpmd.x)
==1406== by 0x4264EE: cpmd_ (in /home/me/tmp/CPMD/cpmd.x)
==1406== by 0x4262EE: main (in /home/me/tmp/CPMD/cpmd.x)
==1406== Address 0x30016a9908 is not stack'd, malloc'd or (recently) free'd
==1406==
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x7737667
#1 0x7737C34
#2 0x81314EF
#3 0x59D0BF7
==1406==
==1406== HEAP SUMMARY:
==1406== in use at exit: 2,152,258 bytes in 2,802 blocks
==1406== total heap usage: 10,893 allocs, 8,091 frees, 16,699,612 bytes allocated
==1406==
==1406== LEAK SUMMARY:
==1406== definitely lost: 567 bytes in 20 blocks
==1406== indirectly lost: 2,973 bytes in 9 blocks
==1406== possibly lost: 0 bytes in 0 blocks
==1406== still reachable: 2,148,718 bytes in 2,773 blocks
==1406== suppressed: 0 bytes in 0 blocks
==1406== Rerun with --leak-check=full to see details of leaked memory
==1406==
==1406== For counts of detected and suppressed errors, rerun with: -v
==1406== Use --track-origins=yes to see where uninitialised values come from
==1406== ERROR SUMMARY: 591 errors from 4 contexts (suppressed: 4 from 4)
Segmentation fault
Ergo, it seems to be a problem with the openblas libs -- but they've work just fine with nwchem and gromacs...who knows? It might be due to mixing debian fftw3 and my own openblas.
If you're having problems with the output below it is because fftw 2 and fftw 3 are not compatible and CPDM uses the fftw 2 iface by default.
mltfft.o: In function `mltfft_fftw_': mltfft.f:(.text+0x958): undefined reference to `fftw_f77_create_plan_' mltfft.f:(.text+0x9af): undefined reference to `fftw_f77_' mltfft.f:(.text+0x9c2): undefined reference to `fftw_f77_destroy_plan_' mltfft.f:(.text+0xaee): undefined reference to `fftw_f77_create_plan_' mltfft.f:(.text+0xb4d): undefined reference to `fftw_f77_' mltfft.f:(.text+0xd03): undefined reference to `fftw_f77_' mltfft.f:(.text+0xdc4): undefined reference to `fftw_f77_' mltfft.f:(.text+0xe6e): undefined reference to `fftw_f77_create_plan_' mltfft.f:(.text+0xe8f): undefined reference to `fftw_f77_create_plan_' collect2: ld returned 1 exit status make: *** [cpmd.x] Error 1
You can either
1. Install fftw2 (sudo apt-get install fftw-dev, fftw2), and put -l:libfftw.so.2 -l:librfftw.so.2 in your LFLAGS.
or
2. Set -DFFT_FFTW3 instead of -DFFT_FFTW.
No comments:
Post a Comment