• Gromacs 4.0.3、4.5.5版安裝方法

    注:本文已經過時,最新版本GROMACS安裝方法參見《GROMACS的安裝方法》(http://www.shanxitv.org/457)。

    Gromacs 4.0.3、4.5.5版安裝方法

    文/Sobereva @北京科音    Last update: 2012-Jan-6


    下面是gromacs4.0.3安裝方法。4.5.5版安裝方法見本文后半。


    gmx4.0.3安裝方法

    平臺:F7-64bit、Q6600、gcc4.1.2、mpich2-1.0.7、root、ifort 10.1.015,軟件版本gromacs4.0.3,安裝在/sob/gromacs
    安裝的是并行版本、單精度版本。

    指定編譯器和編譯選項:
    export CC=gcc
    export CXX=g++
    export CFLAGS="-O3 -msse -msse2 -msse3 -mssse3 -march=core2"
    export CXXFLAGS="-O3 -msse -msse2 -msse3 -mssse3 -march=core2"
    export FFLAGS="-O3 -axT" //用C編譯器編譯內核的話不用這步

    復制mpich2-1.0.7.tar.gz到/sob,解壓到/sob/mpich2-1.0.7,進入此目錄,運行:
    ./configure
    make
    make install

    運行
    touch /etc/mpd.conf
    chmod 700 /etc/mpd.conf
    將下面加入mpd.conf:
    secretword=<secretword> (比如secretword=ltwd)


    解壓fftw3.1.2壓縮包到/sob下,進入fftw-3.1.2目錄
    ./configure --enable-float --with-gcc-arch=core2
    make
    make install
    默認安在了/usr/local/include(lib)下。


    解壓gromacs-4.0壓縮包到/sob下,進入gromacs-4.0目錄,
    ./configure --prefix=/sob/gromacs --enable-mpi -enable-fortran
    make
    make install

    在/root/.bashrc中添加PATH=$PATH:/sob/gromacs/bin,MANPATH=$MANPATH:/sob/gromacs/share/man。輸入bash使環境變量生效

    此時可刪掉/sob下的fftw3.1.2目錄、gromacs-4.0目錄和mpich2-1.0.7目錄。留下安好的gromacs目錄。

    *******
    如果我們要進行QMMM計算,需要編譯時設定,目前gromacs支持gamess-UK、mopac7、gaussian98/03,這里介紹把mopac7編進gromacs的方法。
    下載http://wwwuser.gwdg.de/~ggroenh/qmmm/mopac/dcart.f
    下載http://wwwuser.gwdg.de/~ggroenh/qmmm/mopac/SGI/mopac7.tar.gz
    把mopac7.tar.gz解壓,把剛下載的dcart.f放進去替換原文件,把目錄下的mopac.f、moldat.f、deriv.f刪掉。運行:
    ifort -O2 -c *.f
    ar rcv libmopac.a *.o
    ranlib libmopac.a然后把libmopac.a放到/lib下
    export CPPFLAGS=-DUSE_MOPAC
    export LIBS=-lmopac
    之后同樣進行configure步驟,但多加一個參數--with-qmmm-mopac,即運行:
    ./configure --prefix=/sob/gromacs --enable-mpi -enable-fortran --with-qmmm-mopac
    之后make、make install即可。
    ********


    PS:

    用mkl的話,先修改./configure
    把兩處LIBS="-lmkl $LIBS"改成LIBS="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core $LIBS"
    然后運行./configure --prefix=/sob/gromacs4mkl --enable-mpi -enable-fortran --with-fft=mkl CPPFLAGS=-I/opt/intel/mkl/10.0.4.023/include LDFLAGS=-L/opt/intel/mkl/10.0.4.023/lib/em64t,串行版本比fftw有提升,但是并行版本相對fftw卻沒有提升。如果是32bit平臺,-lmkl_intel_lp64改為lmkl_intel,把.../lib/em64t改為.../lib/32

    如果硬盤空間緊張,可以在./configure時加入--enable-shared來使用共享庫,最終得到的bin非常小,gmx4.0中只有2.3MB,遠小于使用靜態庫的172.65MB,只不過gromacs/lib文件夾里面會多出4約20MB。另外需要再添加環境變量LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/sob/gromacs/lib。使用靜態庫或者動態庫對運行速度基本沒有影響。

    gmx的內核有C語言和fortran兩套版本,默認是C語言編譯,如果用了-enable-fortran就是用fortran編譯器編譯,此時建議用ifort。用這個選項對gmx3.3.x來說并不會使性能有所多少提升,但對gmx 4.0.x來說性能提升明顯。./configure的時候可以在后面加F77=xxx來指定fortran編譯器。用gfortran可能會報錯。

    沒必要用icc,性能相比用gcc不會有絲毫提升。

    如果已經make過了,之后想./configure接新的選項重新編譯,應當先執行make distclean

    --program-suffix=[suffix]給出來的程序名加個后綴,可以區分單雙精度版本、串行并行版本。比如先不加--enable-mpi編譯一遍,然后make distclean,再加上--enable-mpi和--program-suffix=_mpi編譯一遍,這樣mdrun和mdrun_mpi串并行版本互不干擾。實際上沒有必要單獨編譯串行版本,如果只是1個CPU用,就當成-np 1即可。

    --disable-float或--enable-double可以編譯成雙精度版本(默認采用的是單精度),雙精度版本速度約為單精度60%,對常規分子動力學來說單精度就夠了,除了簡正振動分析等情況。


    老gmx版本有一些問題,在gmx4.0.3皆已修正,寫在這里作為參考。
    gmx4.0.0開-enable-fortran編譯出錯:把src/gmxlib/libxdrf.c的第1156行#define XDR_INT_SIZE 4挪到第68行,即在#ifdef GMX_FORTRAN之前。
    編譯得到的g_spatial和g_cluster完全一樣:把src/tools/g_spatial.c里面的gmx_cluster改成gmx_spatial(gmx4.0.3已修正)


    在configure文件中可以看到:

    CC C compiler command 一般這個環境變量就是gcc
    CFLAGS C compiler flags 編譯時的參數,一般是-O3
    LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
    nonstandard directory <lib dir> 庫文件目錄
    LIBS libraries to pass to the linker, e.g. -l<library> 設的時候不用“-l xxx”,無需引號
    CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
    you have headers in a nonstandard directory <include dir>
    F77 Fortran 77 compiler command 一般這個環境變量就是gfortran或ifort
    FFLAGS Fortran 77 compiler flags 編譯時的參數,一般是-O3
    CCAS assembler compiler command (defaults to CC)
    CCASFLAGS assembler compiler flags (defaults to CFLAGS)
    CPP C preprocessor
    CXX C++ compiler command 一般是g++
    CXXFLAGS C++ compiler flags
    CXXCPP C++ preprocessor
    XMKMF Path to xmkmf, Makefile generator for X Window System


    Optional Features:
    --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
    --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
    --enable-shared[=PKGS] build shared libraries [default=no]
    --disable-float use double instead of single precision
    --enable-double same effect as --disable-float
    --enable-fortran use fortran (default on sgi,ibm,sun,axp)
    --enable-mpi compile for parallel runs using MPI
    --disable-threads don't try to use multithreading
    --enable-mpi-environment=VAR only start parallel runs when VAR is set
    --disable-ia32-3dnow don't build 3DNow! assembly loops on ia32
    --disable-ia32-sse don't build SSE/SSE2 assembly loops on ia32
    --disable-x86-64-sse don't build SSE assembly loops on X86_64
    --disable-ppc-altivec don't build Altivec loops on PowerPC
    --disable-ia64-asm don't build assembly loops on ia64
    --disable-cpu-optimization no detection or tuning flags for cpu version
    --disable-software-sqrt no software 1/sqrt (disabled on sgi,ibm,ia64)
    --enable-prefetch-forces prefetch forces in innerloops
    --enable-all-static make completely static binaries
    --disable-dependency-tracking speeds up one-time build
    --enable-dependency-tracking do not reject slow dependency extractors
    --enable-static[=PKGS] build static libraries [default=yes]
    --enable-fast-install[=PKGS]
    optimize for fast installation [default=yes]
    --disable-libtool-lock avoid locking (might break parallel builds)
    --disable-largefile omit support for large files

    Optional Packages:
    --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
    --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
    --with-fft=[fftw3/fftw2/mkl(>=6.0)/fftpack]
    FFT library to use. fftw3 is default, fftpack built
    in.
    --with-external-blas Use system BLAS library (add to LIBS). Automatic on
    OS X.
    --with-external-lapack Use system LAPACK library (add to LIBS). Automatic
    on OS X.
    --without-qmmm-gaussian Interface to mod. Gaussian0x for QM-MM (see website)
    --with-qmmm-gamess use modified Gamess-UK for QM-MM (see website)
    --with-qmmm-mopac use modified Mopac 7 for QM-MM (see website)
    --with-gnu-ld assume the C compiler uses GNU ld [default=no]
    --with-pic try to use only PIC/non-PIC objects [default=use
    both]
    --with-tags[=TAGS] include additional configurations [automatic]
    --with-dmalloc use dmalloc, as in
    http://www.dmalloc.com/dmalloc.tar.gz
    --with-x use the X Window System
    --with-motif-includes=DIR Motif include files are in DIR
    --with-motif-libraries=DIR Motif libraries are in DIR
    --without-gsl do not link to the GNU scientific library, prevents certain analysis tools from being built
    --with-xml Link to the xml2 library, experimental




    gmx4.5.5安裝方法

    RHEL6-U1 64bit, 2630QM, root

    #Install Intel Fortran Composer XE(Linux) 2011.1.107 to default folder (/opt/intel)

    #This step can be skipped if you want to use threats parallelization
    #In mpich2 1.4.1 folder:
    ./configure
    make
    make install
    #Now mpich2 1.4.1 folder can be deleted

    #In fftw-3.3:
    ./configure --enable-threads --enable-single --enable-sse2 --enable-avx F77=ifort --prefix=/sob/fftw3.3
    make -j 4
    make install
    #Now fftw-3.3 folder can be deleted

    #In gromacs-4.5.5 folder
    #If you prefer to use MPI parallelization, add --enable-mpi to below command
    ./configure --with-fft=fftw3 --prefix=/sob/gromacs455 LDFLAGS="-L/sob/fftw3.3/lib" CPPFLAGS="-I/sob/fftw3.3/include" -enable-shared=no
    make -j 4
    make install
    #Now gromacs-4.5.5 folder can be deleted
    #Add "export PATH=$PATH:/sob/gromacs455/bin" to /root/.bashrc

    注:如果想用fortran編譯內核,先export F77=ifort,并在./configure中加上--enable-fortran。然而性能并不會有絲毫提升,甚至還略微下降。threads并行和MPI并行在單機上效率差不多,前者并沒體現出額外優勢,只是方便了。

    久久精品国产99久久香蕉