huazhongguo的个人博客分享 http://blog.sciencenet.cn/u/huazhongguo

博文

用pgi10.0编译vasp5.2

已有 6462 次阅读 2010-5-3 21:45 |个人分类:生活点滴|系统分类:科研笔记

用pgi10.0编译vasp5.2

五一这两天闲着没事,摆弄了一下vasp5.2编译,经测试,并行编译获得成功,现把我的编译过程与大家分享。
1.安装linux系统,我现在用的系统是fedora 12。

2.配置并行环境
a.配置ssh环境
   修改/etc/hosts文件
   在127.0.0.1 local..........
      下面加入
   127.0.0.1  node0!左边一串数字是机子的ip,右边是取的hostname,由于我是单机多核环境,所以ip地址都是一样的。
   127.0.0.1  node2
可以通过ping hostname 或ssh hostname测试设置是否成功
b.实现无密码远程访问
打开一个终端
#ssh-keygen -d
回车
回车
在~/.ssh下生成id_dsa (存放私人密匙)和id_dsa_pub(存放公用密匙)
#cp id_dsa_pub authorized_keys
#ssh hostname(无需输入密码)
安装好后,可以庸ping命令和ssh查看node0,node1等等。

3.安装pgi10.0,
按照提示安装即可,只不过在安装过程中要选择mpich,选用ssh,这样就把mpich安装到默认目录/opt/pgi/linux86/2010/mpi/mpich了,其中编译过程中要用到的数学库被安装到/opt/pgi/linux86/2010/mpi/mpich/lib中,比如并行编译中经常用到的libscalapack.a ,blacsF77init_MPI-LINUX-0.a,blacs_MPI-LINUX-0.a,blacsF77init_MPI-LINUX-0.a等等。 安装完毕后,配置环境变量。
如: gedit ~/.bashrc,在这个文件中加入如下内容:
   PGI=/opt/pgi; export PGI
     MANPATH=$MANPATH:$PGI/linux86/10.0/man
     export MANPATH
     LM_LICENSE_FILE=$PGI/license.dat
    export LM_LICENSE_FILE
     PATH=$PGI/linux86/10.0/bin:$PATH
      source /opt/pgi/linux86/10.0/mpi.sh
    export PATH
其中,      source /opt/pgi/linux86/10.0/mpi.sh配置mpi环境。

4. 编译vasp5.2
a.编译程序自带的数学库。进入数学库所在的目录 ~/vasp.5.lib。在终端中敲如命令
  cp makefile.linux_pgi_opt makefile
   make
我的makefile文件如下:

.SUFFIXES: .inc .f .F
#-----------------------------------------------------------------------
# Makefile for Portland Group F90/HPF compiler
# the makefile was tested only under Linux on Intel platforms
# however it might work on other platforms as well
#
# this release of vasp.4.lib contains lapack v2.0
# this can be compiled with pgf90 compiler if the option -O1 is used
#
# Mind: one user reported that he had to copy preclib.F diolib.F
#  dlexlib.F and drdatab.F to the directory vasp.4.4, compile the files
#  there and link them directly  into vasp
#  for no obvious reason these files could not be linked from the library
#
#-----------------------------------------------------------------------

# C-preprocessor
CPP     = mpicc -E -P -C $*.F >$*.f
FC=mpif90 -Mx,119,0x200000

CFLAGS = -O
FFLAGS = -O0
FREE   = -Mfree

DOBJ =  preclib.o timing_.o derrf_.o dclock_.o  diolib.o dlexlib.o drdatab.o


#-----------------------------------------------------------------------
# general rules
#-----------------------------------------------------------------------

libdmy.a: $(DOBJ) lapack_double.o linpack_double.o lapack_atlas.o
    -rm libdmy.a
    ar vq libdmy.a $(DOBJ)

# files which do not require autodouble
lapack_double.o: lapack_double.f
    $(FC) $(FFLAGS) $(NOFREE) -c lapack_double.f
lapack_single.o: lapack_single.f
    $(FC) $(FFLAGS) $(NOFREE) -c lapack_single.f
lapack_atlas.o: lapack_atlas.f
    $(FC) $(FFLAGS) $(NOFREE) -c lapack_atlas.f
linpack_double.o: linpack_double.f
    $(FC) $(FFLAGS) $(NOFREE) -c linpack_double.f
linpack_single.o: linpack_single.f
    $(FC) $(FFLAGS) $(NOFREE) -c linpack_single.f

.c.o:
    $(CC) $(CFLAGS) -c $*.c
.F.o:
    $(CPP)
    $(FC) $(FFLAGS) $(FREE) $(INCS) -c $*.f
.F.f:
    $(CPP)
.f.o:
    $(FC) $(FFLAGS) $(FREE) $(INCS) -c $*.f

b. 编译主程序vasp5.2
这一步是整个编译成功的关键,主要的问题是库文件的调用,CPP参数的选择......
下面贴出我的makefile文件:

.SUFFIXES: .inc .f .f90 .F
#-----------------------------------------------------------------------

# all CPP processed fortran files have the extension .f
SUFFIX=.f

#-----------------------------------------------------------------------
# fortran compiler and linker
#-----------------------------------------------------------------------
FC=mpif90
# fortran linker
FCL=$(FC)
CPP_ =  ./preprocess <$*.F | /usr/bin/cpp -P -C -traditional >$*$(SUFFIX)
#-----------------------------------------------------------------------
CPP    = $(CPP_) -DMPI  -DHOST=\"LinuxIFC\" -DIFC \
     -Dkind8  -DCACHE_SIZE=12000 -DPGF90 -Davoidalloc \
     -DMPI_BLOCK=500 -DPROC_GROUP=8 \
     -DRPROMU_DGEMV  -DRACCMU_DGEMV \
#       -DNGZhalf
 #-DwNGZhalf \
#-----------------------------------------------------------------------
FFLAGS = -O0 -Mfree -g #-Mx,119,0x200000

#-----------------------------------------------------------------------
OFLAG  = -O0 

OFLAG_HIGH = $(OFLAG)
OBJ_HIGH =
OBJ_NOOPT =
DEBUG  = -g -O0
INLINE = $(OFLAG)
#-----------------------------------------------------------------------
LAPACK= ../vasp.5.lib/lapack_double.o
BLAS=-L/opt/pgi/linux86/10.0/lib -lblas
#-----------------------------------------------------------------------
LIB  = -L../vasp.5.lib -ldmy \
     ../vasp.5.lib/linpack_double.o $(LAPACK) \
     $(BLAS)

# options for linking (none required)
LINK    =
#-----------------------------------------------------------------------
BLACS=/opt/pgi/linux86/2010/mpi/mpich/lib
SCA_=/opt/pgi/linux86/2010/mpi/mpich/lib

SCA= $(SCA_)/libscalapack.a  \
 $(BLACS)/blacsF77init_MPI-LINUX-0.a $(BLACS)/blacs_MPI-LINUX-0.a $(BLACS)/blacsF77init_MPI-LINUX-0.a

#-----------------------------------------------------------------------
# libraries for mpi
#-----------------------------------------------------------------------
FFT3D   = fftmpi.o fftmpi_map.o fft3dfurth.o fft3dlib.o

#-----------------------------------------------------------------------
# general rules and compile lines
#-----------------------------------------------------------------------
BASIC=   symmetry.o symlib.o   lattlib.o  random.o  

SOURCE=  base.o     mpi.o      smart_allocate.o      xml.o  \
         constant.o jacobi.o   main_mpi.o  scala.o   \
         asa.o      lattice.o  poscar.o   ini.o       xclib.o     xclib_grad.o \
         radial.o   pseudo.o   mgrid.o    gridq.o     ebs.o  \
         mkpoints.o wave.o     wave_mpi.o  wave_high.o  \
         $(BASIC)   nonl.o     nonlr.o    nonl_high.o dfast.o    choleski2.o \
         mix.o      hamil.o    xcgrad.o   xcspin.o    potex1.o   potex2.o  \
         metagga.o constrmag.o cl_shift.o relativistic.o LDApU.o \
         paw_base.o egrad.o    pawsym.o   pawfock.o  pawlhf.o    paw.o   \
         mkpoints_full.o       charge.o   dipol.o    pot.o  \
         dos.o      elf.o      tet.o      tetweight.o hamil_rot.o \
         steep.o    chain.o    dyna.o     sphpro.o    us.o  core_rel.o \
         aedens.o   wavpre.o   wavpre_noio.o broyden.o \
         dynbr.o    rmm-diis.o reader.o   writer.o   tutor.o xml_writer.o \
         brent.o    stufak.o   fileio.o   opergrid.o stepver.o  \
         chgloc.o   fast_aug.o fock.o     mkpoints_change.o sym_grad.o \
         mymath.o   internals.o dimer_heyden.o dvvtrajectory.o vdwforcefield.o \
         hamil_high.o nmr.o    force.o \
         pead.o     subrot.o   subrot_scf.o pwlhf.o  gw_model.o optreal.o   davidson.o \
         electron.o rot.o  electron_all.o shm.o    pardens.o  paircorrection.o \
         optics.o   constr_cell_relax.o   stm.o    finite_diff.o elpol.o    \
         hamil_lr.o rmm-diis_lr.o  subrot_cluster.o subrot_lr.o \
         lr_helper.o hamil_lrf.o   elinear_response.o ilinear_response.o \
         linear_optics.o linear_response.o   \
         setlocalpp.o  wannier.o electron_OEP.o electron_lhf.o twoelectron4o.o \
         ratpol.o screened_2e.o wave_cacher.o chi_base.o wpot.o local_field.o \
         ump2.o bse.o acfdt.o chi.o sydmat.o

INC=

vasp: $(SOURCE) $(FFT3D) $(INC) main.o
    rm -f vasp
    $(FCL) -o vasp main.o  $(SOURCE)   $(FFT3D) $(LIB) $(LINK)
makeparam: $(SOURCE) $(FFT3D) makeparam.o main.F $(INC)
    $(FCL) -o makeparam  $(LINK) makeparam.o $(SOURCE) $(FFT3D) $(LIB)
zgemmtest: zgemmtest.o base.o random.o $(INC)
    $(FCL) -o zgemmtest $(LINK) zgemmtest.o random.o base.o $(LIB)
dgemmtest: dgemmtest.o base.o random.o $(INC)
    $(FCL) -o dgemmtest $(LINK) dgemmtest.o random.o base.o $(LIB)
ffttest: base.o smart_allocate.o mpi.o mgrid.o random.o ffttest.o $(FFT3D) $(INC)
    $(FCL) -o ffttest $(LINK) ffttest.o mpi.o mgrid.o random.o smart_allocate.o base.o $(FFT3D) $(LIB)
kpoints: $(SOURCE) $(FFT3D) makekpoints.o main.F $(INC)
    $(FCL) -o kpoints $(LINK) makekpoints.o $(SOURCE) $(FFT3D) $(LIB)

clean:   
    -rm -f *.g *.f *.o *.L *.mod ; touch *.F

main.o: main$(SUFFIX)
    $(FC) $(FFLAGS)$(DEBUG)  $(INCS) -c main$(SUFFIX)
xcgrad.o: xcgrad$(SUFFIX)
    $(FC) $(FFLAGS) $(INLINE)  $(INCS) -c xcgrad$(SUFFIX)
xcspin.o: xcspin$(SUFFIX)
    $(FC) $(FFLAGS) $(INLINE)  $(INCS) -c xcspin$(SUFFIX)

makeparam.o: makeparam$(SUFFIX)
    $(FC) $(FFLAGS)$(DEBUG)  $(INCS) -c makeparam$(SUFFIX)

makeparam$(SUFFIX): makeparam.F main.F
#
# MIND: I do not have a full dependency list for the include
# and MODULES: here are only the minimal basic dependencies
# if one strucuture is changed then touch_dep must be called
# with the corresponding name of the structure
#
base.o: base.inc base.F
mgrid.o: mgrid.inc mgrid.F
constant.o: constant.inc constant.F
lattice.o: lattice.inc lattice.F
setex.o: setexm.inc setex.F
pseudo.o: pseudo.inc pseudo.F
poscar.o: poscar.inc poscar.F
mkpoints.o: mkpoints.inc mkpoints.F
wave.o: wave.inc wave.F
nonl.o: nonl.inc nonl.F
nonlr.o: nonlr.inc nonlr.F

$(OBJ_HIGH):
    $(CPP)
    $(FC) $(FFLAGS) $(OFLAG_HIGH) $(INCS) -c $*$(SUFFIX)
$(OBJ_NOOPT):
    $(CPP)
    $(FC) $(FFLAGS) $(INCS) -c $*$(SUFFIX)

fft3dlib_f77.o: fft3dlib_f77.F
    $(CPP)
    $(F77) $(FFLAGS_F77) -c $*$(SUFFIX)

.F.o:
    $(CPP)
    $(FC) $(FFLAGS) $(OFLAG) $(INCS) -c $*$(SUFFIX)
.F$(SUFFIX):
    $(CPP)
$(SUFFIX).o:
    $(FC) $(FFLAGS) $(OFLAG) $(INCS) -c $*$(SUFFIX)

现说明一下makefile中参数的选择
编译中用到下列数学库:
LAPACK= ../vasp.5.lib/lapack_double.o
BLAS=-L/opt/pgi/linux86/10.0/lib -lblas

BLACS=/opt/pgi/linux86/2010/mpi/mpich/lib
SCA_=/opt/pgi/linux86/2010/mpi/mpich/lib
SCA= $(SCA_)/libscalapack.a  \
 $(BLACS)/blacsF77init_MPI-LINUX-0.a $(BLACS)/blacs_MPI-LINUX-0.a $(BLACS)/blacsF77init_MPI-LINUX-0.a
其中,lapack用到vasp自带的库,而blas用到pgi自带的库,用于并行编译的库分别是scalapack和blacs,这两个数学库是pgi自带的。
cpp参数如下:
CPP    = $(CPP_) -DMPI  -DHOST="LinuxIFC" -DIFC
     -Dkind8  -DCACHE_SIZE=12000 -DPGF90 -Davoidalloc
     -DMPI_BLOCK=500 -DPROC_GROUP=8
     -DRPROMU_DGEMV  -DRACCMU_DGEMV
#       -DNGZhalf
#-DwNGZhalf
其中-DNGZhalf 和-DwNGZhalf 在编译过程中被注释掉,原因是我发现用上这两个参数后,计算会提示内存不够,而同一计算任务不用这两个参数编译,就不出现内存不够的提示。

到此,Vasp已成功安装到fedora12系统上,经测试,并行计算时,每个核利用率可达到百分之九十以上。

https://blog.sciencenet.cn/blog-378442-319344.html

上一篇:请教非平衡格林函数的问题
下一篇:看反抄袭软件

1 黄富强

发表评论 评论 (1 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2022-1-26 19:23

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部