科学网

 找回密码
  注册

tag 标签: 编译

相关帖子

版块 作者 回复/查看 最后发表

没有相关内容

相关日志

[转载]Fortran 90编译: 注意模块中的“常量”
zhoufcumt 2013-9-19 14:33
转载自: http://goodluck1982.blog.sohu.com/130049902.html 遇到这样一个问题,假设有两个 f90 文件 m.f90 和 a.f90 --------m.f90------- module mm implicit none integer, parameter ::i=3 integer::j=3 endmodule --------End--------- ---------a.f90------- program main use mm print *,'i=',i print *,'j=',j end --------End---------- 执行命令 ifort a.f90 m.f90 a.out #(0) 输出 i= 3 j= 3 这个很正常,现在我把 m.f90 中的 i=3 改为 i=4,j=3 改为 j=4 再执行 ifort a.f90 m.f90 a.out #(1) 结果输出依然是 i= 3 j= 4 这个很奇怪,只有再一次执行编译命令 ifort a.f90 m.f90 a.out #(2) 时,才输出正确的值 i= 4 j= 4 由于j的输出是正确的,可见 mm.mod 文件应该是更新了的,但是 i 的值却没有更新 很是诡异!是不是 parameter 很不一样! 更有趣的是,如果把 m.f90 放在 a.f90 之前,即 ifort m.f90 a.f90 a.out 这样的话即使该命令出现在(1)处,依然给出正确的结果(i,j都等于4) 最好先将模块编译出来 ifort -c b.f90 ifort b.o a.f90 Makefile 可以这样写: all: a.out mm.mod: m.f90 ifort -c m.f90 a.out: m.f90 a.f90 mm.mod ifort a.f90 m.f90
个人分类: Fortran|3119 次阅读|0 个评论
科苑轶闻-12:在与大师一起编审科技词典的日子里
热度 10 sqdai 2013-6-27 06:08
把几十位名闻遐迩的科学大师“圈”起来,在一起就琢磨一件事儿:将放在案头的科技词典初稿弄得像模像样一些,尽可能无懈可击。年青学子听到此事,一定觉得有点不可思议。然而,这件事情的确发生过,本人不仅目击过,而且亲历过。谓予不信,有钱三强先生 1978 年 12 月 22 日 为《英德法俄汉物理学词典》所写的《写在前面》为证,现摘录其中的第二段(共三段): “ 一九七八年初,我刚从国外访问回来,欣闻《物理学词典》的翻译工作已经完成,并且正在召开审定会,我被邀去了一次,看到两个会议室像是临时图书馆,书架上摆满了参考用的各类词典,桌上放着一叠叠稿件。几十位老年和中年科学家和教师,其中不少是我的老朋友,正在认真地工作,辛勤地劳动。这种热气腾腾的场面多年少见了,真叫人感动。我衷心地祝贺他们为促进我国科学技术繁荣做了一件好事。 ” 衷心感谢钱三强先生!他用朴素的寥寥数语勾画了当年的真实场景,也勾起了我对历历往事的回忆。 那是一个春寒料峭的日子,时任中国科协主席的钱三强先生一进门,大家就从堆着词典的桌子旁站了起来。握手、寒暄的环节就耗时十分钟。五十几个人中,就黄瑞新、姚蜀平和我那么三五个人钱先生不认识,其余各位都是他的老相识,特别是这项“工程”的发起人楮圣麟、龚祖同、钱伟长、庄祈泰、鲍国宝、汪德熙、胡济民等老先生,有些人还是“文革”后第一次重逢。所有的人都有点激动。 这是一项什么样的“工程”呢?简言之,是编译、审订、出版《英德法俄汉物理学词典》和《现代科学技术词典》。 关于《英德法俄汉物理学词典》,王竹溪先生在 1978 年 7 月 19 日 写的该词典的序言中介绍:“ 这部物理学词典,有五种文字对照,收词较多,比目前国内已出版的《物理名词》多一倍以上,在国外也是收词最多的一种。它的出版,会对我国翻译工作者有很大帮助。在编译过程中,曾请全国各研究机关和高等院校的许多同志参加,写出初译稿。把这些译稿经过审校整理后,于一九七七年十二月邀请物理学界的许多专家,会同一部分数学、力学、气象学、化学、生物学、地球物理学、医学等方面的专家,开会作最后审定。会后还留有少数名词未译出来,继续函请全国各地专家提出意见。 ” 关于《现代科学技术词典》,钱三强先生在 1980 年 3 月 6 日 写的该词典的序中介绍:“ 《现代科学技术词典》出版了!这是我国科技界和出版界的一件大好事。一本收词达十万六千余条,包括一百零九个学科,二千六百余幅插图,七百五十余万字的科学技术词典,能在短短的三年时间里出版发行,是值得庆贺的。在向四个现代化全面进军的今天,人们越来越需要科学技术的武装,如果有一本能适用于各方面读者参考的有关科学技术的综合性的工具书,是会受到欢迎的。《现代科学技术词典》综合了十几本最新科学技术词典的内容,收词新而广,并有简明的释文。它的出版发行,将对我国四个现代化建设起到一定的作用。 ” 我不想对这两本词典进行全面评价。只是说:《英德法俄汉物理学词典》对科技工作者和翻译工作者有很大的参考价值;而《现代科学技术词典》至今仍有一定的查阅、参考价值,但是它需要进行与时俱进的修订和更新。这里只想谈谈我在参与它们的编译、审定工作中的感受和收获。 1977 年,经钱伟长先生推荐,我作为流体力学学科的代表,参加了《英德法俄汉物理学词典》的审定和《现代科学技术词典》的编译工作; 1978 年又参加了后者的审定工作。 前一工作跨越了 1977 、 1978 年,历时半个月;后一本词典的编译用了半年,审定工作又耗时半个月。那时正值科学的春天,百废待兴,科技界龙腾虎跃,我自己也觉得浑身有使不完的劲儿。在此期间,为了不辱使命,发愤读书,努力查阅资料,感到所做的事一定要经得起推敲,对得起读者。 更大的收获是:在两次审定会中,耳濡目染了前辈学者的大师风范,留下了一辈子难忘的印象。 记得参加审定会的头一天,我陪着钱伟长先生走进会场,经会议主持者介绍,并环顾了一下:大多是鼎鼎有名的大学者(名单见链接 1 ),我对很多人只知其名,这回把名字与真人联系起来了。他们中的一大半的年龄在 65~75 岁的范围里,最年长的鲍国宝先生(著名钢琴家鲍蕙乔的父亲)那年 78 岁,词典问世之时,他已仙逝。 与这些大学者朝夕相处,我非常留意观察他们的言行,收获良多。回想起来,印象深刻的有如下几点: —— 孜孜不倦 探索学问 。当时囿于条件,从住宿地到会场有一段距离,有的老先生还住在家里,但他们“上班”比小学生上学还准时。一到会场,就一头扎进译稿和辞书堆里,目不旁视,细心阅读和思考,彼此说话都是轻声细语。《英德法俄汉物理学词典》审定会的会程过半时,十万多个词条绝大多数已经各得其所,但是还有几百个词条没有着落,大多数情形是:英语德语法语俄语的词形相似,却不知道对应的汉语释义,尽管与会者来自自然科学的各个学科分支,而且老先生个个满腹经纶,就是找不到答案。于是,钱伟长、王竹溪先生商量之后提议:休会一天,大家各自到图书馆、资料室去找答案,或者找朋友商量,非把答案找到不可。几百个疑难词条摆在桌上,与会者自愿“认领”,当然,学问根底好的认领得最多。第三天会议继续。会前闲谈,大家讲了各自求索的艰苦经历。接下来“会战”的结果是 80% 的问题有了答案。我留心观察,善于根据外语构词法“拆字”的钱伟长先生和文字功夫好的王竹溪先生收获最丰。 —— 一丝不苟 求真务实 。别看这些老先生读书、想问题时很安静,待人接物彬彬有礼,争论起来却脸红耳赤、寸步不让。会场上经常爆发舌战,一个词,搞光学的这么解,搞声学的那么解,各执一见,纷争顿起。于是乎,各自搜索枯肠,引经据典,唇枪舌战,几经周折,方有定论。 —— 日积月累 知识渊博 。那些老学者人人学富五车,才高八斗,令人羡煞!我做研究生时到北大听过王竹溪先生的“热力学”课,对他的学问人品非常钦佩。这次有机会与他近距离接触,我就常找他切磋,聆听他的教诲。就是在会上,他告诉我,他是怎样写成《特殊函数概论》的。他说,勤学苦练是积累知识的关键,他留学时,就把《现代分析》一书所有的习题做了一遍,为写《特殊函数概论》打好了基础。我曾做过那里的习题,有些很难,而他却全做了,这是何等的功力!他精通国学,年轻时读过《说文解字》,对以后做学问极有帮助。他说,人们常分不清“声”“音”二字的区别,其实,“声”的涵义广,涵盖“好声音”、“坏声音”,而“音”一般只指“好声音”,所以把“ noise ”译成“噪音”是不对的,应该译成“噪声”;同理,不该说成“超音速”、“亚音速”,应该说成“超声速”、“亚声速”;如今,两种说法兼用,但用错的更多(例如,报上常见“噪音”字样)。我还请教他,外国人名汉译,碰到“er”(汉语拼音)音的时候,为何有时译成“尔”,有时译成“耳”?他回答道,这是他立的规矩,若此音来自字母“r”,就译成“尔”,如物理学家玻尔;若来自字母“l”,则译成“耳”,如物理学家波耳兹曼。(现在此规矩似乎慢慢地给破掉了)。有一次饭后,王先生讲了一个好玩的掌故。上个世纪头三十年,西风东渐,外国的自然科学著作纷纷译介到中国,其中,术语的译法及其统一是困扰人们的问题。例如, “ vector ”一词,原先,数学界将其译成“矢量”,物理学界则译成“向量”。 1930 年代数学界和物理学界各自审定《数学名词》和《物理名词》。数学家说,他们搞物理的把“ vector ”译成“向量”,好像比“矢量”好一点,我们就定成“向量”吧!物理学家说,他们搞数学的把“ vector ”译成“矢量”,好像比“向量”好一点,我们就定成“矢量”吧!这样一来,情形就逆转了,数学界开始惯用“向量”,物理学界开始惯用“矢量”,这一态势一直沿袭至今。我想了一想,情况果然如此(回家后进一步查实了)。这可苦了我们搞力学的,一头是“亲家”,一头是“娘家”,一样亲近,听谁的呢?“矢量”“向量”该用哪一个呢?干脆混用吧!跟数学走得近的用“向量”,跟物理学走得近的用“矢量”。要是不信,去查查中文的力学文献吧!也正因为这个历史原因,“ vector ”的中文译法的统一成了怎么也搞不定“积案”。 岁月匆匆,弹指一挥间。事情已过去了 35 年,却好像发生在昨天。链接 1 中名单上的老先生大部分已去了天国。我由衷地为他们祈福。 写于 2013 年 6 月 27 日晨 【链接 1 】 《英德法俄汉物理学词典》审词会名词审定者(按姓氏笔画为序) 马大猷,马星垣,王子昌,王竹溪,王祝翔,刘元芳,朱岗昆,沈同,沈良照,阮祖启,陈传康,陈厚珩,李玉文,李正武,李国栋,李宪之,李德平,吴治华,吴忠葵,张三慧,张至善,汪容,汪德熙,庄祈泰,林海,孟昭英,杨锦刚,周光地,郑林生,郑华炽,金星南,施士元,柯俊,胡济民,席光康,姚蜀平,徐凤早,徐锡申,钱伟长,钱临照,曾泽培,龚祖同,黄瑞新,梅镇岳,梅良模,鲍国宝,葛庭燧,虞福春,楮圣麟,薛鸣球,戴世强,魏履新 【链接 2 】同类博文 1 科苑轶闻 -1 : “ 自杀俱乐部 ” 的故事 http://blog.sciencenet.cn/home.php?mod=spaceuid=330732do=blogid=379512 2 科苑轶闻 -2 :大理石先生、钱学森手稿及其它 http://blog.sciencenet.cn/home.php?mod=spaceuid=330732do=blogid=379827 3 科苑轶闻 -3 :没有牺牲 哪有成功 —— 记航空事业的先驱者利林塔尔 http://blog.sciencenet.cn/home.php?mod=spaceuid=330372do=blogid=380206 4 科苑轶闻 -4 :苏步青 “ 背榜 ” 记 http://blog.sciencenet.cn/home.php?mod=spaceuid=330732do=blogid=380546 5 科苑轶闻 -5 : 冯 · 卡门访华历险记 http://blog.sciencenet.cn/home.php?mod=spaceuid=330732do=blogid=381061 6 科苑轶闻 -6 :呆头呆脑的科学家 http://blog.sciencenet.cn/home.php?mod=spaceuid=330732do=blogid=381156 7 科苑轶闻 -7 :语不惊人死不休 —— 记赖特希尔的一件感人轶事 http://blog.sciencenet.cn/home.php?mod=spaceuid=330732do=blogid=381546 8 科苑轶闻 -8 :钱令希恭录《家训》育后人 http://blog.sciencenet.cn/home.php?mod=spaceuid=330732do=blogid=381965 9 科苑轶闻 -9 :呆头呆脑的科学家(续) http://blog.sciencenet.cn/blog-330732-443618.html 10 科苑轶闻 -10 :华罗庚险遭活埋 http://blog.sciencenet.cn/blog-330732-567869.html 11 科苑轶闻 -11 :科学家感情生活小故事 http://blog.sciencenet.cn/blog-330732-667604.html
个人分类: 名人纪实|9021 次阅读|25 个评论
fpp编译vasp5.3+vtst
热度 1 ywmucn 2013-1-24 10:43
Redhat上采用Ifc编译器,MKL数据库 VASP5.3编译的过程 过去曾发表过一篇 编译带VTST代码(NEB)的vasp 5.2 ----------------------------------------------------- 创建用户: adduser -g root mu passwd mu rocks sync users rocks sync config 一 . 软件准备 VASP源代码(vasp.5.3.3.tar.gz和vasp.5.lib.tar.gz),ifc编译器(l_cprof_p_11.1.064.tgz)icc编译器(l_cproc_p_11.1.064.tgz ),openmpi 软件 #su root 进入root用户, 二.ICC编译器安装 先解压l_cproc_p_11.1.064.tgz 得到l_cproc_p_11.1.064文件夹 进入l_cproc_p_11.1.064文件夹找到install.sh文件 执行./install.sh开始安装icc, ------------------------------------- 注意选择: 2. Custom Install (For Advanced Users) 2. Custom Install - specify individual product components to install 在后面的安装选项中选择安装Intel(R) 64的,不安装IA-32 。安装过程中自带 Math Kernel Library 数学库。 并指定安装目录/share/apps/intel/icc ------------------------------------- 安装完毕 ,ICC安装完成 (卸载时 在目录外执行 安装目录/bin/intel64/uninstall_cproc.sh 进行卸载) 此时,mkl位置 /share/apps/intel/icc/mkl 三. Ifc编译器安装 先解压l_cprof_p_11.1.064.tgz 得到l_cprof_p_11.1.064文件夹 进入l_cprof_p_11.1.064文件夹找到install.sh文件 执行./install.sh开始安装ifc, ------------------------------------- 注意选择 2. Custom Install (For Advanced Users) 2. Custom Install - specify individual product components to install 在后面的安装选项中选择安装Intel(R) 64的,不安装IA-32 。不安装 Math Kernel Library 数学库。 并指定安装目录/share/apps/intel/ifc ------------------------------------- 安装完毕 ,ifc安装完成 (卸载时 在目录外执行 安装目录/bin/intel64/uninstall_cprof.sh 进行卸载,uninstall_debugger.sh也可以) 四.将icc和ifort命令加入环境变量 新建一个文件user.sh,加入 INTELROOT=/share/apps/intel/intel2 . \$INTELROOT/ifc/bin/ifortvars.sh intel64 . \$INTELROOT/icc/bin/iccvars.sh intel64 然后 source user.sh which icc 和which ifort 看看能否找到 验证ifort是否可以使用, #which ifort 写一个简单的a.f90 program test write(*,*) iello pause end 然后#ifort a.f90 -o test #./test 五. mkl和fftw安装 1)mkl在安装icc时已安装,位置 /share/apps/intel/icc/mkl 2)fftw安装 (推荐) http://www.fftw.org/ cd /share/apps/fftw-3.2.2 env CC=gcc F77=ifort ./configure --prefix=/share/apps/fftw --enable-mpi make make install 六、openmpi的安装 下载openmpi,并解压。进入openmpi目录执行: ./configure --prefix=/share/apps/openmpi/ CC=icc CXX=icpc F77=ifort FC=ifort make make install 加入环境变量,在user.sh中加入 . \$INTELROOT/icc/mkl/tools/environment/mklvarsem64t.sh export LD_LIBRARY_PATH=/share/apps/openmpi/lib:\$LD_LIBRARY_PATH export PATH=/share/apps/openmpi/bin:\$PATH 然后 source user.sh 七.vasp 安装 1)su root ,将 vasp.5.3.3.tar.gz,vasp.5.lib.tar.gz,vtstcode.tar.gz (其中 vtstcode.tar.gz 来自:http://theory.cm.utexas.edu/vtsttools/index.php ) 拷贝到 /share/apps/vasp 目录下,并将分别解压 2)进入vasp.5.lib所在目录 根据自己机子的情况选择合适的makefile 一般选择 makefile.linux_ifc_P4 (即 ifort编译器和intel的cpu) 编辑makfile 18行 CPP = gcc -E -P -C $*.F $*.f 改为 CPP = icc -E -P -C $*.F $*.f 19行的 FC=ifc 修改为 FC=ifort(也可以是绝对路径) 并添加 CC = icc make 如果编译通过,说明前面安装的数学库和编译器等都是正确的 3)进入vasp.5.3所在目录 然后将 cp makefile.linux_ifc_P4 makefile.mpi ,打开 makefile.mpi 在98行和99行CPP前加上#注释掉(即将前面的串行配置去掉) 第108行 FFLAGS = -FR -lowercase -assume byterecl 改为 FFLAGS = -FR -names lowercase -assume byterecl -mssse3 -heap-arrays 64 (针对 ifort 10 以上) 第123行 OFLAG=-O2 -ip 改为 OFLAG=-O2 -ip -ftz 第138行 #MKL_PATH 的#去掉. 第141行 MKL_PATH 前加上#注释掉 第144行(空行)增加 IFC_LIB_PATH=/export/apps/intel/intel2/ifc/lib/intel64 第147行 # BLAS= -Wl,--start-group \$(MKL_PATH)/libmkl_intel_lp64.a \$(MKL_PATH)/libmkl_intel_thread.a \$(MKL_PATH)/libmkl_core.a -Wl,--end-group -lguide 改为 BLAS= -Wl,--start-group \$(MKL_PATH)/libmkl_intel_lp64.a \$(MKL_PATH)/libmkl_sequential.a \$(MKL_PATH)/libmkl_core.a \$(MKL_PATH)/libmkl_lapack95_lp64.a \$(IFC_LIB_PATH)/libiomp5.a \$(IFC_LIB_PATH)/libimf.a -Wl,--end-group -lpthread -lm 第149行BLAS 前加上#注释掉 (注意不换行) 第149行BLAS 前加上#注释掉 第158行 LAPACK 前加上#注释掉 第169行到171行 LIB 三行前加上#注释掉 将182行前FFT3D = fft3dfurth.o fft3dlib.o 前加# 将205行前#去掉,并改成 FC=/share/apps/intel/intel2/openmpi/bin/mpif90 将206行前#去掉,变为 FCL=$(FC) 将223行到226行 CPP = 前的#去掉,改成 CPP = \$(CPP_) -DMPI -DHOST=\LinuxIFC\ -DIFC \ -DCACHE_SIZE=5000 -DPGF90 -Davoidalloc -DNGZhalf \ -DMPI_BLOCK=262144 -Duse_collective -DscaLAPACK \ -DRPROMU_DGEMV -DRACCMU_DGEMV 第234和235行BLACS和SCA前加# 将241-243行LIB 前#去掉 将253行 #FFT3D = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o /opt/libs/fftw-3.1.2/lib/libfftw3.a 改为 FFT3D = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o /data1/software/vasp/fftw-3.1.2/lib/libfftw3.a 第258行 #INCS 去掉#,改成 INCS = -I/data1/software/vasp/fftw-3.1.2/include 然后 make -f vasp.mpi 得到 vasp ,并 mv vasp vasp.mpi make clean -f vasp.mpi make makeparam -f vasp.mpi ,得到 makeparam make clean -f vasp.mpi 八.vasp+vtst安装 cd vtstcode sed -i s/^..*#ifdef/#ifdef/g * sed -i s/^..*#endif/#endif/g * 将所有的文件中#if 和#endif前的空格去掉,因为fpp预编译要求#在第一个字符位. 然后并将vtstcode的内容复制到/share/apps/vasp/vasp.5.3下. 执行 perl mkbdrpro.pl bdr_changes,产生 bdrpro.F cp makefile.mpi makefile.neb 后面加上Bader电荷计算和VTST代码等配置: 打开 makefile.neb 1) 找到有 sphpro.o的行(大约在240行)将 steep.o chain.o dyna.o sphpro.o us.o core_rel.o \ 改为 steep.o chain.o dyna.o sphpro.o bdrpro.o us.o core_rel.o \ 2) 大约仍在240行,在chain.o之前加入 bfgs.o dynmat.o instanton.o lbfgs.o sd.o cg.o dimer.o bbm.o \ fire.o lanczos.o neb.o qm.o opt.o\ 注意: bbm.o 是vtst3.0新加的,vtst2.4没有. 3) 在main.F 中 将 CALL CHAIN_FORCE(T_INFO%NIONS,DYN%POSION,TOTEN,TIFOR, LATT_CUR%A,LATT_CUR%B,IO%IU6) 替换为: CALL CHAIN_FORCE(T_INFO%NIONS,DYN%POSION,TOTEN,TIFOR, TSIF,LATT_CUR%A,LATT_CUR%B,IO%IU6) 保存退出。 然后 make -f makefile.neb 得到 vasp ,并 mv vasp vasp.mpi.neb make clean -f makefile.neb 九. 其它版本VASP的编译: 1)Gamma点版本: cp makefile.mpi makefile.gamma 在makefile.gamma修改 CPP = \$(CPP_) -DMPI -DHOST=\LinuxIFC\ -DIFC \ -DCACHE_SIZE=5000 -DPGF90 -Davoidalloc -DNGZhalf \ -DMPI_BLOCK=262144 -Duse_collective -DscaLAPACK \ -DRPROMU_DGEMV -DRACCMU_DGEMV 中 -DNGZhalf的后面加上 -DwNGZhalf 然后 make -f makefile.gamma 得到 vasp ,并 mv vasp vasp.mpi.gamma.neb 2)SOC版本: cp makefile.mpi makefile.soc 在makefile.soc修改 CPP = \$(CPP_) -DMPI -DHOST=\LinuxIFC\ -DIFC \ -DCACHE_SIZE=5000 -DPGF90 -Davoidalloc -DNGZhalf \ -DMPI_BLOCK=262144 -Duse_collective -DscaLAPACK \ -DRPROMU_DGEMV -DRACCMU_DGEMV 中去掉-DNGZhalf 然后 make -f makefile.soc 得到 vasp ,并 mv vasp vasp.mpi.soc .neb 注意:1)执行任务前先 source user.sh 2)基本sge提交脚本见另一篇博文《Vasp sge提交的基本脚本》。 搞定收工!!!! =============== 后记: 1)LAPACK 与BLAS库也可以使用其它的,如在Rocks集群上quantum-espresso(pwscf)安装中使用的LAPACK 与BLAS库,相应设置: BLAS= -L/share/apps/lapack-3.3.0 -lblas LAPACK= -llapack 或者 BLAS采用Kazushige Goto's BLAS,LAPACK采用lapack_double.o 的编译得到vasp,据说计算速度最快。 2)fftw库也可以使用VASP自带的或MKL自带的 cd /share/apps/intel/icc/mkl/interfaces/fftw3xf make libem64t compiler=intel 得到 libfftw3xf_intel.a 注意: vasp5.2.x和vasp5.3.x 不推荐使用intel的fftw,有一个奇怪的问题,做并行时,若不设NPAR参数计算结果会有问题. 3)另一种并行库 :impi的安装及使用 1、 进入源文件所在的目录, ./install.sh 进行安装, 注意选择 1. Install cluster node software on an automounted shared file system 安装时注意选择安装目录 /share/apps/intel/impi (卸载时目录外执行 相应目录下uninstall.sh 进行卸载) 2、增加环境变量 在user.sh 中加入 . /share/apps/intel/impi/bin64/mpivars.sh 注意:impi的的并行编译器为mpiifort。 2)mkl的直接安装: 在intel网站下载 l_mkl_p_10.2.3.029.tar.gz tar –zxvf l_mkl_p_10.2.3.029.tar.gz 进入解压得到的目录 l_mkl_p_10.2.3.029 执行 ./install.sh,安装和卸载与icc等类似。
个人分类: VASP|11979 次阅读|5 个评论
VC6.0静态编译注意事项
caobiao 2012-12-7 11:48
选择静态编译(工程-常规-Microsoft基础类-使用MFC作为静态链接库)的时候,会报错:MSVCRTD.lib(MSVCRTD.dll) : error LNK2005: _sprintf already defined in LIBCMTD.lib(sprintf.obj)报错的意思及原因是使用的某些外部静态库编译时使用的标准库和当前工程使用的标准库冲突。 所以需要设置标准库并忽略一些库: 首先需要设置run-time library 工程-设置-C++-Code Generation-Use run-time library 可供选择的Use run-time library有6项:Single-threaded、Multithreaded、Multithreaded using DLL、Debug Single-threaded、Debug Multithreaded、Debug Multithreaded using DLL。 不同的Use run-time library对应地忽略不同的库文件。对应关系如下: Single-threaded (libc.lib)单线程静态链接库(release版本) libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib Multithreaded (libcmt.lib)多线程静态链接库(release版本) libc.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib Multithreaded using DLL (msvcrt.lib)多线程动态链接库(release版本) libc.lib, libcmt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib Debug Single-threaded (libcd.lib)单线程静态链接库(debug版本) libc.lib, libcmt.lib, msvcrt.lib, libcmtd.lib, msvcrtd.lib Debug Multithreaded (libcmtd.lib)多线程静态链接库(debug版本) libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, msvcrtd.lib Debug Multithreaded using DLL (msvcrtd.lib)多线程动态链接库(debug版本) libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib 如何忽略呢? 工程-设置-连接-输入-忽略库-即可。 不同的编译方式有什么差异呢? 单线程: 不需要多线程调用时, 多用在DOS环境下 多线程: 可以并发运行 静态库: 直接将库与程序Link, 可以脱离MFC库运行 动态库: 需要相应的DLL动态库, 程序才能运行 release版本: 正式发布时使用 debug版本: 调试阶段使用 对应地忽略这些库之后,会产生一个新的问题: nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc nafxcwd.lib(timecore.obj) : error LNK2001: unresolved external symbol __mbctype nafxcwd.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype nafxcwd.lib(filelist.obj) : error LNK2001: unresolved external symbol __mbctype 这个问题如何解决呢? 工程-设置-C/C++-预处理器-预处理器定义 _AFXDLL。 问题就解决了。
个人分类: 技术达人|6524 次阅读|0 个评论
BerkeleyGW的安装编译
热度 1 DonarF1 2012-10-17 17:34
版本:BGW-1.0.3.tar 系统:fortran mpi: parallel_studio_xe_2011_sp1_update2_intel64 The code can be installed via the following steps: 1, cp flavor.mk 2, cp ./config/ .mk arch.mk。 我这借用的是mako.berkeley.edu.mk.mk文件。 3, make all 4, make check 修改后的arch.mk文件如下: arch.mk 如下: # arch.mk for BerkeleyGW codes # # suitable for SCRS North cluster mako.berkeley.edu # # D. Strubbe # February 2010, UC Berkeley # # module load openmpi/1.4.1-intel # module load fftw/2.1.5-intel # module load mkl/11.1.064 # Precompiler options # COMPFLAG = -DINTEL PARAFLAG = -DMPI MATHFLAG = -DUSESCALAPACK DEBUGFLAG = -DDEBUG -DVERBOSE FCPP = cpp -ansi F90free = mpif90 -free LINK = mpif90 -i-static -openmp FOPTS = -O3 -no-prec-div FNOOPTS = -O2 -no-prec-div MOD_OPT = -module INCFLAG = -I C_PARAFLAG = -DPARA CC_COMP = mpiCC C_COMP = mpicc C_LINK = mpiCC C_OPTS = -O3 REMOVE = /bin/rm -f # Math Libraries FFTWPATH = /home/ljzhou86/app/fftw FFTWLIB = /home/ljzhou86/app/fftw/lib/libfftw.a FFTWINCLUDE = /home/ljzhou86/app/fftw/include MKLPATH = /home/ljzhou86/intel/composer_xe_2011_sp1.9.293/mkl/lib/intel64 LAPACKLIB = -Wl,--start-group /home/ljzhou86/intel/composer_xe_2011_sp1.9.293/mkl/lib/intel64/libmkl_intel_lp64.a /home/ljzhou86/intel/composer_xe_2011_sp1.9.293/mkl/lib/intel64/libmkl_sequential.a /home/ljzhou86/intel/composer_xe_2011_sp1.9.293/mkl/lib/intel64/libmkl_core.a /home/ljzhou86/intel/composer_xe_2011_sp1.9.293/mkl/lib/intel64/libmkl_blacs_openmpi_lp64.a -Wl,--end-group -lpthread -limf -lm # LAPACKLIB = -Wl,--start-group $(MKLPATH)/libmkl_intel_lp64.a $(MKLPATH)/libmkl_sequential.a $(MKLPATH)/libmkl_core.a $(MKLPATH)/libmkl_blacs_openmpi_lp64.a -Wl,--e#nd-group -lpthread SCALAPACKLIB = /home/ljzhou86/intel/composer_xe_2011_sp1.9.293/mkl/lib/intel64/libmkl_scalapack_lp64.a #SCALAPACKLIB = -L$(MKLPATH)/ -lmkl_scalapack_lp64.a (如使用如此书写方式,编译时会说找不到,很奇怪,不知道为什么) TESTSCRIPT = make check-parallel mako.scr 注明,FFTWPATH LAPACKLIB SCALAPACKLIB等路径必须用绝对路径,不然说找不到相应的库文件。 后面在cluster上安装, FCPP = cpp -ansi F90free = /cluster/node5/temp/software/openmpi1.6/bin/mpif90 -free LINK = /cluster/node5/temp/software/openmpi1.6/bin/mpif90 -i-static -openmp FOPTS = -O3 -no-prec-div FNOOPTS = -O2 -no-prec-div MOD_OPT = -module INCFLAG = -I C_PARAFLAG = -DPARA CC_COMP = /cluster/node5/temp/software/openmpi1.6/bin/mpiCC  (先前已经安装了mpich2,与BGW不兼容,后重新安装openmpi,设置绝对路径才通过,否则显示错误:if90 -i-static -openmp -O3 -no-prec-div -o kgrid.x ../../Common/misc.o ../../Common/sort.o ../../Common/blas.o ../../Common/lapack.o ../../Common/symmetries.o ../../Common/global.o ../../Common/typedefs.o ../../Common/nrtype.o ../../Common/push_pop.o ../../Common/message.o ../../Common/peinfo.o ../../Common/timing.o ../../Common/system.o kgrid.o kgrid_routines.o ../../MeanField/spglib-1.0.9/libsymspg.a -Wl,--start-group /cluster/node5/temp/software/intel-2011/mkl/lib/intel64/libmkl_intel_lp64.a /cluster/node5/temp/software/intel-2011/mkl/lib/intel64/libmkl_sequential.a /cluster/node5/temp/software/intel-2011/mkl/lib/intel64/libmkl_core.a /cluster/node5/temp/software/intel-2011/mkl/lib/intel64/libmkl_blacs_intelmpi_lp64.a -Wl,--end-group -lpthread -limf -lm ln -sf /cluster/node5/temp/BGW/BerkeleyGW-1.0.4/MeanField/ESPRESSO/kgrid.x ../../bin make : Leaving directory `/cluster/node5/temp/BGW/BerkeleyGW-1.0.4/MeanField/ESPRESSO' cd ICM make make : Entering directory `/cluster/node5/temp/BGW/BerkeleyGW-1.0.4/MeanField/ICM' mpiCC -I../../Common -DCPLX -DINTEL -DPARA -DDEBUG -DVERBOSE -c -O3 icm.cpp -o icm.o make : execvp: mpiCC: Permission denied make : *** Error 127 make : Leaving directory `/cluster/node5/tlemp/BGW/BerkeleyGW-1.0.4/MeanField/ICM' make : *** Error 2 make : Leaving directory `/cluster/node5/temp/BGW/BerkeleyGW-1.0.4/MeanField' make: *** Error 2) C_COMP =/cluster/node5/temp/software/openmpi1.6/bin/mpicc C_LINK = /cluster/node5/temp/software/openmpi1.6/bin/mpiCC C_OPTS = -O3 REMOVE = /bin/rm -f # Math Libraries FFTWPATH = /cluster/node5/temp/fftw2.1.5 FFTWLIB = /cluster/node5/temp/fftw2.1.5/lib/libfftw.a #FFTWINCLUDE =$(FFTWPATH)/include FFTWINCLUDE = /cluster/node5/temp/fftw2.1.5/include MKLPATH = /cluster/node5/temp/software/intel-2011/mkl/lib/intel64 LAPACKLIB = -Wl,--start-group /cluster/node5/temp/software/intel-2011/mkl/lib/intel64/libmkl_intel_lp64.a /cluster/node5/temp/software/intel-2011/mkl/lib/intel64/libmkl_sequential.a /cluster/node5/temp/software/intel-2011/mkl/lib/intel64/libmkl_core.a /cluster/node5/temp/software/intel-2011/mkl/lib/intel64/libmkl_blacs_openmpi_lp64.a -Wl,--end-group -lpthread -limf -lm SCALAPACKLIB = /cluster/node5/temp/software/intel-2011/mkl/lib/intel64/libmkl_scalapack_lp64.a #SCALAPACKLIB = -L$(MKLPATH)/ -lmkl_scalapack_lp64.a 这里面如用先前的mkl库,会显示: _sys2blacs_handle_.c:(.text+0x24): undefined reference to `ompi_mpi_comm_null' _sys2blacs_handle_.c:(.text+0x9e): undefined reference to `ompi_mpi_comm_null' _sys2blacs_handle_.c:(.text+0x13e): undefined reference to `ompi_mpi_comm_null' _sys2blacs_handle_.c:(.text+0x160): undefined reference to `ompi_mpi_comm_world' _sys2blacs_handle_.c:(.text+0x1d2): undefined reference to `ompi_mpi_comm_world' /cluster/node5/program/intel/mkl/10.1.3.027/lib/em64t/libmkl_blacs_openmpi_lp64.a(BI_MPI_F77_to_c_trans_comm.o): In function `BI_MPI_F77_to_c_trans_comm': _BI_MPI_F77_to_c_trans_comm.c:(.text+0x6): undefined reference to `MPI_Comm_f2c' make : *** Error 1 make : Leaving directory `/cluster/node5/temp/qe/espresso-5.0.1/PW/src' make : *** Error 2 make : Leaving directory `/cluster/node5/temp/qe/espresso-5.0.1/PW' make: *** Error 2 Openmpi编译时: Q1: Catastrophic error: could not set locale to allow processing of multibyte characters R1: vi ~/.bashrc LANG=en_US.utf8 LC_ALL=en_US.utf8 BGW install Question2 ../Common/fftw.o: In function `fftw_m_mp_do_fft_': Common/fftw.p.f:(.text+0x5ea): undefined reference to `fftwnd_f77_create_plan_' Common/fftw.p.f:(.text+0x60d): undefined reference to `fftwnd_f77_create_plan_' Common/fftw.p.f:(.text+0xb0a): undefined reference to `fftwnd_f77_one_' Common/fftw.p.f:(.text+0x1419): undefined reference to `fftwnd_f77_one_' Common/fftw.p.f:(.text+0x18f7): undefined reference to `fftwnd_f77_destroy_plan_' Common/fftw.p.f:(.text+0x1903): undefined reference to `fftwnd_f77_destroy_plan_' ../Common/fftw.o: In function `fftw_m_mp_destroy_fftw_plans_': Common/fftw.p.f:(.text+0x1d4d): undefined reference to `fftwnd_f77_destroy_plan_' Common/fftw.p.f:(.text+0x1d59): undefined reference to `fftwnd_f77_destroy_plan_' make : *** Error 1 make : Leaving directory `/lustre/jhome15/hhb17/hhb172/source/BGW-1.1.beta/Epsilon' make : *** Error 2 make : Leaving directory `/lustre/jhome15/hhb17/hhb172/source/BGW-1.1.beta' make: *** Error 2 Resolution2: fftw-2.1.5编译时:F77=ifort ./configure --prefix=/***/fftw-2.1.5 -enable-float Q3: icm.cpp:(.text+0x17cf): undefined reference to `operator new (unsigned long)' icm.cpp:(.text+0x1955): undefined reference to `operator new (void*)' icm.cpp:(.text+0x1bd4): undefined reference to `operator delete (void*)' icm.cpp:(.text+0x235a): undefined reference to `operator new (void*)' icm.cpp:(.text+0x2b30): undefined reference to `operator delete (void*)' icm.cpp:(.text+0x2bbb): undefined reference to `operator delete (void*)' icm.o:icm.cpp:(.text+0x2be5): more undefined references to `operator delete (unsigned long)' icm.cpp:(.text+0x541b): undefined reference to `operator new (unsigned long)' icm.cpp:(.text+0x5647): undefined reference to `operator delete (void*)' icm.cpp:(.text+0x56ca): undefined reference to `operator delete (unsigned long)' icm.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0' ../../Common/wfn_utils.o: In function `cub_read(char*, int*, int*, int*, int*, CARTESIAN*, CARTESIAN*, CARTESIAN*)': Common/wfn_utils.cpp:(.text+0xdd5): undefined reference to `operator new (unsigned long)' Common/wfn_utils.cpp:(.text+0xed1): undefined reference to `operator new (unsigned long)' Common/wfn_utils.cpp:(.text+0xf4a): undefined reference to `operator new (unsigned long)' follow ../../Common/wfn_utils.o: In function `scalar_clone(int*, int*, int*, CARTESIAN*, CARTESIAN*, CARTESIAN, CARTESIAN*, CARTESIAN, CARTESIAN*)': Common/wfn_utils.cpp:(.text+0x4458): undefined reference to `operator delete (void*)' Common/wfn_utils.cpp:(.text+0x4551): undefined reference to `operator delete : *** Error 1 make : Leaving directory `/lustre/jhome15/hhb17/hhb172/source/BGW-1.1.beta/MeanField/ICM' make : *** Error 2 make : Leaving directory `/lustre/jhome15/hhb17/hhb172/source/BGW-1.1.beta/MeanField' make : *** Error 2 make : Leaving directory `/lustre/jhome15/hhb17/hhb172/source/BGW-1.1.beta/MeanField' make : *** Error 2 make : Leaving directory `/lustre/jhome15/hhb17/hhb172/source/BGW-1.1.beta' make: *** Error 2 R3: CC_COMP = mpicxx C_COMP = mpicc C_LINK = mpicxx 4: iop-0826上的编译 ,采用hodduk.mit.edu.mk * 编译 c++ 程序需要添加 -lstdc++ sample: gcc -lstdc++ -o test test.c,否则会报 undefined reference to ' __gxx_personality_v0 ' 等错误 2. 唉,用gcc命令编译C程序,用g++命令编译C++程序。 g++和gcc本质一样的,本质上还是gcc,我们实验室所有的c++程序都是用gcc编译的,一般的程序用gcc足够了。 对于 C++ 程序,编译的时候用 gcc 或者 g++ 都可以。但是在进行连接的时候最好用 g++,因为用 g++ 会自动进行 C++ 标准库的连接;用 gcc 连接 C++ 程序也可以,但是需要人为指定连接 C++ 标准库,否则就会出现 undefined reference to `__gxx_personality_v/0' 之类的错误。 可见-lstdc++ 所对应的是标准C++库 C_PARAFLAG = -DPARA -DMPICH_IGNORE_CXX_SEEK  
个人分类: QE|16154 次阅读|1 个评论
[转载]也谈QT4.7静态编译
chuangma2006 2012-4-15 14:39
网上有很多教程了,这里讲一下我的过程.什么东西试一试才知道是否正确,只有自己做过以后才记忆深刻. 我安装的是这个版本,在此之前,VS2008 已经安装好了. 安装好了后,直接在开始菜单中运行Qt 4.7.0 Command Prompt 命令行,启动控制台窗口 这个命令行实际上是一个批处理文件启动的,这个批处理文件的内容如下: //============ @echo off rem rem This file is generated by the Qt installer rem echo Setting up a Qt environment... set QTDIR=e:\Qt\4.7.0 echo -- QTDIR set to e:\Qt\4.7.0 set PATH=e:\Qt\4.7.0\bin;%PATH% echo -- Added e:\Qt\4.7.0\bin to PATH set QMAKESPEC=win32-msvc2008 echo -- QMAKESPEC set to "win32-msvc2008" if not "%1"=="vsvars" goto ENDVSVARS call "C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat" :ENDVSVARS if not "%1"=="vsstart" goto ENDVSSTART call "C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat" devenv /useenv :ENDVSSTART //============== 内容很简单,但比较方便,QT之前的版本,好像需要自己写一个这样的批处理.   在命令行下输入 configure –h 可以看configure程序的帮助 输入 configure -release -static -fast –no-qmake -no-webkit -no-qt3support -no-plugin-manifests 开始配置要编译的项目.我对configure程序的理解是,它遍历当前的*.pro文件,根据这些文件生成对应的Makefike. 而Makefile 文件是告诉编译器如何编译项目文件 静态的QT 框架,有两个“静态”级别: 一是不依赖QtCore4.dll 等动态链接库,但这种级别的静态库还是要依赖 Msvcp90.dll Msvcrt90.dll,这些Runtime库并没有一起静态进去。 二是完全静态,连Msvcp90.dll Msvcrt90.dll,这些Runtime库一并静态包含,这样在没有QT运行库,也没有VC9.0文件库的用户机器上也能很好的运行。 第一种,我已经试过了,跳过下面的步骤,不修改qmake.conf 即可,这里我们要编译第二种,因为想静态,就彻底点,毕竟编译一次不容易。 在qt的安装目录下找到mkspecs目录,这个目录下安装的是各种开发环境的环境变量。这里我们修改 win32-msvc2008 ,打开qmake.conf 文件,这是一个文本文件,把下面红圈中的 QMAKE_CFLAGS_RELEASE 和 QMAKE_CFLAGS_DEBUG 中的 -MD -MDd 分别修改为 -MT 和 -MTd 即可,MT是把vc的Runtime也包含进来。 设置好了,运行configure程序,必须在这之前设置qmake.conf文件,否则改动不会在configure配置之后的Makefile文件中体现。 这个项目我先后编译过两次,第一使用的参数是: Configure –static –fast –no-qmake –no-webkit 在正式编译之前,我还试过 Configure –static –no-webkit 这样的参数组合,配置过程非常的漫长,但后来用Configure –static –fast –no-qmake –no-webkit 则非常的快,没有细究–fast –no-qmake 参数到底做了那些事。 配置完成以后,在命令行输入 nmake 开始编译,编译过程非常的漫长,估计只少有5个小时。难以想象,如果把 qtwebkit 一起编译有多么可怕。编译完成以后,目录增大了23G。 后来分析,很多demo ,example 是没有必要编译的。 第一次编译时是没有修改qmake.conf的,编译完毕,能生成静态库,用DEPEND查看,需要msvcrt90.dll 和 msvcp90.dll。 第二次编译使用的configure参数是: Configure –static –fast –no-qmake –no-webkit –no-qt3support –no-plugin-manifests QT3 我是没有用过,我们公司也没有在QT3上的遗留产品,因此这个肯定不要了。最后一个参数我不是太明白,但网上推荐这么做,也就加上了。 回车以后会出现下面的界面,网上都没有人介绍,第一步是选择QT的版本,是LGPL版还是商业版,我这里用的是LGPL版本,因此选o 回车。 接下来会提示是否接受LGPL协议,输入y确认。   配置过程中会显示一些开关的默认选项,以及一些目录的地址。 简单警告提示后几秒钟开始自动生成Makefile文件。 如果之前用过不同的参数配置,那么需要先运行 nmake confclean , 但这个命令我没有成功过。似乎网上也有人说没有成功。 直接这么nmake 会非常的耗时,因为它会把当前目录下所有的Makefile都编译生成一遍 当然也包含Demos 和Example 目录 因为我们只会用到Src目录下的东西,因此,在命令行下输入 cd src 回车,然后在运行nmake。只编译src目录下的相关文件 经过一个多小时的时间就编译完了,很快。 看看 cl的参数 –O2 –MT ,说明它是静态编译的。 接下来在这个目录下运行 nmake clean 删除编译过程中的临时文件。 OK 任务完成了。 用QtCreator 创建了一个最简单的UI程序,编译后,Release版本有5.4M大小,用Depend看,以及不依赖QtCore4.dll 和 其他dll 了,当然Msvcp90.dll 和Msvcrt90.dll也不用依赖了。 我还发现了一件有趣的事,静态编译后的lib文件还是放在lib目录下,同样QtCore项目编译的动态库是 QtCore4.lib 和 QtCore4d.lib ,而而静态库是 QtCore.lib 和 QtCored.lib ,那么编译器又是如何找到它们的呢? 这个我还没有细细的研究。 当我编译静态库以后,创建的新项目会自动使用静态链接,也就是说,我在.pro文件中没有写 CONFIG += static 它也会自动去链接静态Lib。 接下来我又做了一个实验,把qmake.conf 中的MT,MTd 该为 MD ,MDd。 重新生成这个项目,链接的时候报错了, @C:\DOCUME~1\tase\LOCALS~1\Temp\TestStatic.exe.26166109.jom LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson 已经在 MSVCRT.lib(MSVCR90.dll) 中定义 LIBCMT.lib(invarg.obj) : error LNK2005: __invalid_parameter_noinfo 已经在 MSVCRT.lib(MSVCR90.dll) 中定义 LINK : warning LNK4098: 默认库 “LIBCMT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library release\TestStatic.exe : fatal error LNK1169: 找到一个或多个多重定义的符号 看来是库不兼容啊! 正式使用的时候,把静态编译的 QT 目录单独使用,动态库在这里是用不着了! 个人感觉用QT是不适合静态编译的,QT的静态编译EXE文件太大了,一个什么都不做的exe就有5M之多。相比之下还是VC6静态编译效果好! 但我们用QT,又有几个人在乎它的静态编译呢? 转自:http://www.51hei.com/mcu/1186.html
个人分类: QT|4770 次阅读|0 个评论
lmtart7.04编译
shengxianlei06 2012-4-11 11:11
编译lmtart7.04时遇到如下问题: ################################################################################3 mod_cls_l_lib.o: In function `mod_cls_l_lib_mp_bessi_': mod_cls_l_lib.f90:(.text+0x113d): undefined reference to `bessi0_' mod_cls_l_lib.f90:(.text+0x116d): undefined reference to `bessi1_' mod_cls_l_lib.f90:(.text+0x12f3): undefined reference to `bessi0_' mod_cls_l.o: In function `mod_cls_l_mp_cls_l_main_': mod_cls_l.f90:(.text+0x5933): undefined reference to `max_mu_number_' mod_cls_l.o: In function `mod_cls_l_mp_hamiltonian_': mod_cls_l.f90:(.text+0x11e3c): undefined reference to `inv_' mod_cls_l.f90:(.text+0x12346): undefined reference to `inv_' mod_cls_l.f90:(.text+0x1293a): undefined reference to `inv_' mod_cls_l.f90:(.text+0x12c2c): undefined reference to `inv_' mod_cls_l.f90:(.text+0x12f15): undefined reference to `inv_' mod_cls_l.o:mod_cls_l.f90:(.text+0x135ce): more undefined references to `inv_' follow make: *** Error 1 ##########################################################################################3 解决办法:把调用某函数(如bessi0,bessi1)的子程序(或函数)中对该函数的声明注释掉即可。 这个办法是物理所的ZR博士找到的。
个人分类: lmtart|83 次阅读|0 个评论
编译带VTST代码(NEB)的vasp 5.2
ywmucn 2011-10-12 17:19
采用 Ifc 编译器, MKL 数据库 VASP 编译的过程 vasp5.3的编译见 fpp编译vasp5.3+vtst 创建用户: adduser -g root mu passwd mu rocks sync users rocks sync config 一 . 软件准备 VASP 源代码( vasp.5.2.tar.gz 和 vasp.5.lib.tar.gz ), ifc 编译器( l_cpro f _p_11.1.064.tgz )icc编译器( l_cpro c _p_11.1.064.tgz ) , openmpi 软件 #su root 进入 root 用户, 二.ICC 编译器安装 先解压 l_cproc_p_11.1.064.tgz 得到 l_cproc_p_11.1.064 文件夹 进入 l_cproc_p_11.1.064 文件夹找到 install.sh 文件 执行 ./install.sh 开始安装 icc , ------------------------------------- 注意选择: 2. Custom Install (For Advanced Users) 2. Custom Install - specify individual product components to install 在后面的安装选项中选择安装Intel(R) 64的,不安装IA-32 。安装过程中自带 Math Kernel Library 数学库。 并指定安装目录 /share/apps/intel/icc ------------------------------------- 安装完毕 , ICC 安装完成 ( 卸载时 在目录外执行 安装目录 /bin/intel64/uninstall_cproc.sh 进行卸载) 此时,mkl位置 /share/apps/intel/icc/mkl 三 . Ifc 编译器安装 先解压 l_cprof_p_11.1.064.tgz 得到 l_cprof_p_11.1.064 文件夹 进入 l_cprof_p_11.1.064 文件夹找到 install.sh 文件 执行 ./install.sh 开始安装 ifc , ------------------------------------- 注意选择 2. Custom Install (For Advanced Users) 2. Custom Install - specify individual product components to install 在后面的安装选项中选择安装Intel(R) 64的,不安装IA-32 。不安装 Math Kernel Library 数学库。 并指定安装目录 /share/apps/intel/ifc ------------------------------------- 安装完毕 , ifc 安装完成 ( 卸载时 在目录外执行 安装目录 /bin/intel64/uninstall_cprof.sh 进行卸载,uninstall_debugger.sh也可以) 四.设置环境变量 将icc和ifort命令加入环境变量,即在/root/.bashrc 和/home/mu/.bashrc 中加入 source /share/apps/intel/ifc/bin/ifortvars.sh intel64 source /share/apps/intel/icc/bin/iccvars.sh intel64 然后 在 root 用户和 mu 用户下分别执行 source ~/.bashrc 或 bash which icc 和which ifort 看看能否找到 注意: 已开bash窗口执行后新环境变量才生效 验证 ifort 是否可以使用, #which ifort 写一个简单的 a.f90 program test write(*,*) iello pause end 然后 #ifort a.f90 -o test #./test 五. mkl和fftw 安装 mkl在安装icc时已安装,位置 /share/apps/intel/icc/mkl cd /share/apps/intel/icc/mkl/interfaces/fftw3xf make libem64t compiler=intel 得到 libfftw3xf_intel.a 这样,mkl和fftw就齐全了 另一种方法: 1)在intel网站下载 l_mkl_p_10.2.3.029.tar.gz tar –zxvf l_mkl_p_10.2.3.029.tar.gz 进入解压得到的目录 l_mkl_p_10.2.3.029 执行 ./install.sh,安装和卸载与icc等类似。 fftw安装 http://www.fftw.org/ cd /share/apps/fftw-3.2.2 env CC=gcc F77=ifort ./configure --prefix= /share/apps/ fftw --enable-mpi make make install 六、openmpi的安装 1)下载openmpi,并解压。进入openmpi目录执行: ./configure --prefix=/share/apps/openmpi/ CC=icc CXX=icpc F77=ifort FC=ifort make make install 加入环境变量: 在/root/.bashrc 和/home/mu/.bashrc 中加入 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/share/apps/intel/icc/mkl/lib/em64t: /share/apps/openmpi/lib (不换行) export PATH=$PATH: /share/apps/openmpi/bin 在 root 用户和 mu 用户下分别执行: source ~/.bashrc 另一种方法 :impi 的安装及使用 1 、 进入源文件所在的目录, ./install.sh 进行安装, 注意选择 1. Install cluster node software on an automounted shared file system 安装时注意选择安装目录 /share/apps/intel/impi ( 卸载时目录外执行 相应目录下 uninstall.sh 进行卸载) 2 、增加环境变量 在/root/.bashrc 和/home/mu/.bashrc 中加入 source /share/apps/intel/impi/bin64/mpivars.sh export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/share/apps/intel/icc/mkl/lib/em64t:/share/apps/intel/impi/lib64 在 root 用户和 mu 用户下分别执行: source ~/.bashrc 注意:impi的的并行编译器为 mpiifort 。 七 .vasp 安装 1 ) su root , 将 vasp.5.2.12.tar.gz vasp.5.lib.tar.gz vtstcode.tar.gz (其中 vtstcode.tar.gz 来自: http://theory.cm.utexas.edu/vtsttools/index.php ) 拷贝到 /share/apps/vasp 目录下,并将 vasp.5.2.12.tar.gz vasp.5.lib.tar.gz vtstcode.tar.gz 分别 解压 并将 vtstcode的 内容复制到 /share/apps/vasp/vasp.5.2 下 . chown -Rv mu:root vasp.5.2 chown -Rv mu:root vasp.5.lib su mu 2 )进入 vasp.5.lib 所在目录 根据自己机子的情况选择合适的 makefile 一般选择 makefile.linux_ifc_P4 (即 ifort 编译器和 intel 的 cpu ) 编辑 makfile 18行 CPP = gcc -E -P -C $*.F $*.f 改为 CPP = icc -E -P -C $*.F $*.f 19 行的 FC = ifc 修改为 FC = ifort (也可以是绝对路径) 并添加 CC = icc make 如果编译通过,说明前面安装的数学库和编译器等都是正确的 3 )进入 vasp.5.2 所在目录 执行 perl mkbdrpro.pl bdr_changes ,产生 bdrpro.F 然后将 cp makefile.linux_ifc_P4 makefile ,打开 makefile 在 84 行和 85 行 CPP 前加上 # 注释掉(即将前面的串行配置去掉) 第94行 FFLAGS = -FR -lowercase -assume byterecl 后面加上 -heap-arrays 64 (针对 ifort 10 以上) 第109行 OFLAG=-O2 -ip -ftz 改为 OFLAG=-O3 将 130 行的 BLAS= 加上 # 注释掉 将 133 行 LAPACK= ../vasp.5.lib/lapack_double.o 前加 # 注释 将 136 行 LAPACK= -lmkl_lapack 改为 LAPACK= -L/share/apps/intel/icc/mkl/lib/em64t -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -i-static 将 140-142 行的 LIB= 四行前加 # 将 154 行前 FFT3D = fft3dfurth.o fft3dlib.o 前加 # 将 172 行前 # 去掉,并改成 FC=mpif90 将 173 行前 # 去掉, 并改成 FCL=$(FC) 将 190 行到 193行 CPP = 前的 # 去掉,并在 192 行 -DMPI_BLOCK=8000 后面加 \,并将 -DCACHE_SIZE=4000 改为 -DCACHE_SIZE=16000 (仅供参考,可以使用默认) 将 213-215 行 LIB= 前 # 去掉 将 221 行 #FFT3D = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o /opt/libs/fftw-3.1.2/lib/libfftw3.a 改为 FFT3D = fftmpi.o fftmpi_map.o fftw3d.o fft3dlib.o /share/apps/intel/icc/mkl/interfaces/fftw3xf/libfftw3xf_intel.a 前面是基本的并行编译配置 , 后面加上 Bader 电荷计算和 VTST 代码等配置: 1) 找到有 sphpro.o 的行(大约在 240 行)将 steep.o chain.o dyna.o sphpro.o us.o core_rel.o \ 改为 steep.o chain.o dyna.o sphpro.o bdrpro.o us.o core_rel.o \ 2) 大约仍在 240 行,在 steep.o 和 chain.o 之间加入 dimer.o dynmat.o neb.o lanczos.o instanton.o sd.o cg.o qm.o lbfgs.o bfgs.o fire.o opt.o (注意换行) 3) 在 main.F 中 将 CALL CHAIN_FORCE(T_INFO%NIONS,DYN%POSION,TOTEN,TIFOR, LATT_CUR%A,LATT_CUR%B,IO%IU6) 替换为: CALL CHAIN_FORCE(T_INFO%NIONS,DYN%POSION,TOTEN,TIFOR, TSIF , LATT_CUR%A,LATT_CUR%B,IO%IU6) 保存退出 。 然后 make 得到 vasp ,并 mv vasp vaspmpi make clean make makeparam ,得到 makeparam make clean 修改makefile 的190行 CPP = $(CPP_) -DMPI -DHOST=\LinuxIFC\ -DIFC \ -DCACHE_SIZE=16000 -DPGF90 -Davoidalloc -DNGZhalf \ -DMPI_BLOCK=8000 \ -DRPROMU_DGEMV -DRACCMU_DGEMV 去掉 -DNGZhalf make,并 mv vasp vaspsoc 将 vaspmpi, makeparam和vaspsoc 拷贝到 /share/apps/mybin 下,并执行 source ~/.bashrc 注意:基本sge提交脚本见另一篇博文《 Vasp sge提交的基本脚本 》, 当提交多节点任务时注意INCAR中NPAR设置,否则会报错。 八 增加其他用户 /usr/sbin/ adduser -g root han passwd han rocks sync users rocks sync config 在 /home/han/.bashrc 内添加 source /share/apps/intel/ifc/bin/ifortvars.sh intel64 source /share/apps/intel/icc/bin/iccvars.sh intel64 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/share/apps/intel/icc/mkl/lib/em64t: /share/apps/openmpi/lib (不换行) export PATH=$PATH: /share/apps/openmpi/bin 然后 source /home/han/.bashrc 搞定收工!!!! =============== 后记: 1)LAPACK 与BLAS库也可以使用其它的,如在 Rocks集群上quantum-espresso(pwscf)安装 中使用的 LAPACK 与BLAS库,相应设置: BLAS= -L/share/apps/lapack-3.3.0 -lblas LAPACK= -llapack 或者 BLAS采用Kazushige Goto's BLAS,LAPACK采用lapack_double.o 的编译得到vasp,据说计算速度最快。 2)fftw库也可以使用MKL自带的,注意 FFT3D = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o /opt/libs/fftw-3.1.2/lib/libfftw3.a 中的路径与文件名(一般为mkl安装路径/interfaces/fftw3xf/libfftw3xf_intel.a)。
个人分类: VASP|11099 次阅读|0 个评论
胡春松等编译:五位诺贝尔奖获得者诗歌(6/6)
hucs 2011-9-3 19:38
《青春诗语》(胡春松 著) 胡春松等编译:五位诺贝尔奖获得者诗歌(6/6) Blackberry-Picking by Seamus Heaney 采黑莓 Late August, given heavy rain and sun 晚秋,一场暴雨和骄阳 For a full week, the blackberries would ripen. 只需一周,黑莓就会熟透 At first, just one, a glossy purple clot 起初,只一个,接着就长出许多紫色斑点 Among others, red, green, hard as a knot. 其它里面呢,红的 、 绿的,硬如小结 You ate that first one and its flesh was sweet 你尝第一口,果肉鲜甜 Like thickened wine: summer's blood was in it 就象浓稠的葡萄酒:里面是夏天的血液 Leaving stains upon the tongue and lust for 就让它在舌头上染色,激起 Picking. Then red ones inked up and that hunger 采摘的强烈欲望。接着,红葡萄染色,饥饿者 Sent us out with milk cans, pea tins, jam-pots 给我们分发牛奶罐 、 豌豆缸和果酱罐 Where briars scratched and wet grass bleached our boots. 野蔷薇丛划破皮肤,湿草使我们的靴子腿色 Round hayfields, cornfields and potato-drills 草场周围,谷场和西红柿园 We trekked and picked until the cans were full 我们采了很长一段路,直采到罐子装满 Until the tinkling bottom had been covered 直到叮当响的罐底被 With green ones, and on top big dark blobs burned 绿葡萄盖住,上面是大的 、 黑的 、 撕破的斑点 Like a plate of eyes. Our hands were peppered 象一盘眼珠。我们的手 With thorn pricks, our palms sticky as Bluebeard's. 被棘刺得辣辣的,我们的巴掌粘粘的象蓝胡须 We hoarded the fresh berries in the byre. 我们把鲜莓贮藏在牛棚 But when the bath was filled we found a fur, 但当装满浴盆我们发现软毛 A rat-grey fungus, glutting on our cache. 鼠灰色真菌,充斥在我们的贮藏品 The juice was stinking too. Once off the bush 汁也变得难闻的气味 。 一旦离开采摘地 The fruit fermented, the sweet flesh would turn sour. 水果发酵,鲜甜的果肉就会变酸 I always felt like crying. It wasn't fair 我总是感觉象在哭泣。这是不能接受的 That all the lovely canfuls smelt of rot. 所有的可爱的罐体腐烂融化 Each year I hoped they'd keep, knew they would not. 每年我都希望它们能保存,纵然知道不能 注: 1995 年诺贝尔奖获得者, 希尼,爱尔兰诗人( 1939- ) 其作品洋溢着抒情之美 , 包容着深邃的伦理 , 揭示出日常生活和现实历史的奇迹。
个人分类: 博士研究|2627 次阅读|0 个评论
胡春松等编译:五位诺贝尔奖获得者诗歌(5/6)
hucs 2011-9-3 17:31
《青春诗语》(胡春松 著) 胡春松等编译:五位诺贝尔奖获得者诗歌(5/6) Civilian and Soldier by Wole Soyinka 平民和士兵 My apparition rose from the fall of lead, 我的灵魂随着枪林弹雨升起 Declared, 'I am a civilian.' It only served 坦白吧,“我是一个平民”那只会 To aggravate your fright. For how could I 加剧你的恐惧 。 至于我如何 Have risen, a being of this world, in that hour 升魂,在这样的世界,在于 Of impartial death! And I thought also: nor is 公平死亡的时刻。而且我也思考: Your quarrel of this world. 这个世界的争吵没什么了不起 You stood still 你还站着 For both eternities, and oh I heard the lesson 对于永恒和喔,我听过你们培训 Of your traing sessions, cautioning – 的课程,小心点 Scorch earth behind you, do not leave 奔驰的地球在身后,别让 A dubious neutral to the rear. Reiteration 多疑的争斗达到边缘。重申 Of my civilian quandary, burrowing earth 我的平民困惑,挖地 From the lead festival of your more eager friends 从你的更渴望朋友的 Lead 节 Worked the worse on your confusion, and when 专注于你的困惑的恶化,当 You brought the gun to bear on me, and death 你带着枪跟着我,死亡 Twitched me gently in the eye, your plight 在眼睛里温和地抽打我,你的困境 And all of you came clear to me. 和你们大家清晰地向我走来 I hope some day 我希望有一天 Intent upon my trade of living, to be checked 专注于我的生命交易 In stride by your apparition in a trench, 在战壕里被你的灵魂大步查到 Signalling, I am a soldier. No hesitation then 发出信号,我是一个士兵。那时没有犹豫 But I shall shoot you clean and fair 但我将清楚地、公平地向你开枪 With meat and bread, a gourd of wine 用肉和面包,一葫芦葡萄酒 A bunch of breasts from either arm, and that 双臂的一束肌肉,且有 Lone question - do you friend, even now, know 单个问题:即使此刻,你的朋友知道 What it is all about? 全都是什么? 注: 1986 年 诺贝尔奖获得者, 沃莱 · 索因卡( 1934.7.13- ),尼日利亚剧作家、诗人、小说家、评论家。 他以广博的文化视野创作了富有诗意的关于人生的戏剧。 代表作《雄狮与宝石》
个人分类: 博士研究|2550 次阅读|0 个评论
[转载]【方舟子涉嫌抄袭剽窃】公示第二号(举报人:洪荞)
jiangjinsong 2011-1-8 21:13
轉自: http://www.2250s.com/read.php?2,1679,1679 【方舟子涉嫌抄袭剽窃】公示第二号(举报人:洪荞) (238 Views) 送交者 : 亦明 【说明: 2010年12月15日下午7:02(北京时间),本人以《就〈数学史上一个大恩怨的真相〉一文涉嫌抄袭的通知》为题,给方舟子发出如下邮件: 方舟子先生台鉴: 我是中国学术评价网站方舟子系列专题抄袭剽窃专辑主持人。今收到网友洪荞的文章,《真相的真相》,其中认为您在2006年9月23日《经济观察报》上发表的《数学史上一个大恩怨的真相》一文,涉嫌抄袭英国University of St Andrews 的两位数学教授在数学史网站上发表的系列文章。 经认真核对,仔细比较,本人认为洪荞网友的指控成立。按照中国学术评价网站《抄袭剽窃案例认定程序》(见: ),本人现将洪荞网友的文章转发给您,请您务必在三天内为自己的行为作出解释或者辩护。本人将根据您的回复,决定是否将其提交本网站评议团裁决。逾期不予回复,此案将自动按照《抄袭剽窃案例认定程序》处理。 特此告知。 敬颂 著祺! 亦明 谨上 2010年12月15日 至今,三日期限已到,但方舟子仍未回信。根据本网站《抄袭剽窃案例认定程序》,现将洪荞网友的举报文章公布出来,提请版主召集评议团就此举报是否成立予以评议。同时,欢迎诸位网友对此案踊跃发表自己的意见。 亦明 《中国学术评价网方舟子系列专题抄袭剽窃专辑》主持人 2010年12月18日】 真相的真相 洪荞 2010/12/12 2006年9月23日方舟子在《经济观察报》发表了一篇题为《数学史上一个大恩怨的真相》的科普文章。后来文章改名《被冤枉的数学家》,收录在《爱因斯坦信上帝吗?方舟子解读科学史著名谜团》一书中。通过下面的比较我们可以看到这篇文章其实是十足的抄袭之作。 这次被抄袭的是 University of St Andrews 的两位数学教授。文章来自两位教授的数学史网站。在网站上两位教授说:我们非常欢迎各位使用我们准备的材料,但使用时要提到我们是原作者。我们也非常欢迎各位把我们准备的材料翻译成其它文字,但翻译时要提到我们是原作者 。 真相一文讲的是三次方程求解的争论史。上述网站对四位相关人物每人都有一份精彩的介绍 。真相所讲的故事几乎全部来自 。此外, 真相还用到了 中的几小段以及 中的各一句。在这次抄袭中,方舟子的做法是维持 的整体结构,但砍掉一些句子。在谈及到其它三位人物时,方舟子从相应的文章中抽取一到几句与现有部分混到一起。如果刨掉了那些可以被肯定是抄袭的句子外,真相剩下的部分就只是一些段落间的连接句或可有可无的评论句。这样的句子真假难辨,因此全部罗列如下,由读者自己判断。换句话说,真相一文的整体构思是从 照搬过来的,而它的原创句子不会超出下面几句。 第一段: 头尾是连接句,中间是网文《数学和数学家的故事》的复述。 第二段:这个流行版本从总体到细节都是错误的, 而且也留下了有关这一争执的著作。后人对此事的看法在很大程度上就是受塔塔利亚一面之词的影响 。 第三段:塔塔利亚与卡当之间并未进行过数学比赛,和塔塔利亚比赛的另有其人。在当时的意大利,两个数学家进行解题比赛成了风气,方式是两人各拿出赌金,给对方出若干道题,30天后提交答案,解出更多道题的人获胜,胜者赢得全部赌金。 第四段:当时经常出现的比赛题目是三次方程,因为三次方程的解法还未被发现,塔塔利亚欣喜若狂 。 第五段: 无。 第六段:卡当把武林秘笈拿到手,并没有就对塔塔利亚翻脸,但塔塔利亚却像许多泄密者一样 。 第七段:卡当与塔塔利亚不同,热衷于通过著书立说发布新发现来赢得名利。 第八段: 无。 第九段:决定要为主人讨回公道, 万一输了脸可就丢大了。 第十段:费拉里可谓占尽了天时地利人和。 第十一段:看来那个时候并没有禁止拖欠教师工资的规定 。 第十二段:只有卡当得以长寿,活到了75岁,不过他本来可以活得更长 。 第十三段: 这段应该是原创 。 需要指出的是抄一小段也是抄的原则是可以用到这个案例上的。真相的第五段完全来自 。反之, 中的下面一段完完全全被抄进了真相的第九段: So Tartaglia replied to Ferrari, trying to bring Cardan into the debate. Cardan, however, had no intention of debating with Tartaglia. Ferrari and Tartaglia wrote fruitlessly to each other for about a year, trading the most offensive personal insults but achieving little in the way of resolving the dispute. Suddenly in 1548, Tartaglia received an impressive offer of a lectureship in his home town, Brescia. To clearly establish his credentials for the post, Tartaglia was asked to journey to Milan and take part in the contest with Ferrari. 事实上,真相并不只是抄了一小段。读完下面对比的读者不难得出真相是大面积抄袭的结论。 最后让我们以真相的结尾来结尾: 不过事实的真相毕竟难以掩盖,尤其是在信息发达的今天,更是如此。 数学史上一个大恩怨的真相 方舟子 数学史上著名的一个大恩怨许多人在中学学解方程时都听老师讲过。故事说,文艺复兴时期意大利数学家塔塔利亚发现了三次方程的解法,秘而不宣。一位叫卡当的骗子把解法骗到了手,公布出来,并宣称是他自己发现的。塔塔利亚一气之下向卡当挑战比赛解方程,大获全胜,因为塔塔利亚教他时留了一招。不过至今这些公式还被称作卡当公式,而塔塔利亚连名字都没有留下来,塔塔利亚只是一个外号,意大利语意思是结巴。网上广为流传的一篇《数学和数学家的故事》长文就是这么介绍的。 这个流行版本从总体到细节都是错误的。塔塔利亚不仅留下了名字(真名尼科洛方塔纳),而且也留下了有关这一争执的著作。后人对此事的看法在很大程度上就是受塔塔利亚一面之词的影响。 塔塔利亚与卡当之间并未进行过数学比赛,和塔塔利亚比赛的另有其人。在当时的意大利,两个数学家进行解题比赛成了风气,方式是两人各拿出赌金,给对方出若干道题,30天后提交答案,解出更多道题的人获胜,胜者赢得全部赌金。 塔塔利亚很热衷于参加这种比赛,并多次获胜。Tartaglia gradually acquired a reputation as a promising mathematician by participating successfully in a large number of debates. 当时经常出现的比赛题目是三次方程,因为三次方程的解法还未被发现。意大利博洛尼亚数学家费罗发现了三次方程的一种特殊形式三次加一次的解法,临死前传给了学生费奥。费奥的数学水平其实很差,得到费罗的秘传后便吹嘘自己能够解所有的三次方程。塔塔利亚也自称能够解三次方程,于是两人在1535年进行了比赛。塔塔利亚给费奥出了30道其他形式的三次方程,把费奥给难住了。费奥则给塔塔利亚出了30道清一色的三次加一次方程题,认定塔塔利亚也都解不出来。塔塔利亚在接受费奥挑战的时候,的确还不知道如何解这类方程题。据说是在最后一天的早晨,塔塔利亚在苦思冥想了一夜之后,突然来了灵感,发现了解法,用了不到两个小时就全部解答了。塔塔利亚欣喜若狂,宽宏大量地放弃了费奥交的赌金。 The first person known to have solved cubic equations algebraically was del Ferro but he told nobody of his achievement. On his deathbed, however, del Ferro passed on the secret to his (rather poor) student Fior. ... and Fior had only been shown by del Ferro how to solve one type, namely 'unknowns and cubes equal to numbers'... Fior began to boast that he was able to solve cubics and a challenge between him and Tartaglia was arranged in 1535. In fact Tartaglia had also discovered how to solve one type of cubic equation ... Tartaglia submitted a variety of different questions, exposing Fior as an, at best, mediocre mathematician. Fior, on the other hand, offered Tartaglia thirty opportunities to solve the 'unknowns and cubes' problem since he believed that he would be unable to solve this type, as in fact had been the case when the contest was set up. However, in the early hours of 13 February 1535, inspiration came to Tartaglia and he discovered the method to solve 'squares and cubes equal to numbers'. Tartaglia was then able to solve all thirty of Fior's problems in less than two hours. ... Tartaglia did not take his prize for winning from Fior, however, the honour of winning was enough. 当时担任米兰官方数学教师的卡当听说了此事,通过他人转告塔塔利亚,希望能够知道解法,遭到塔塔利亚的拒绝。于是卡当直接给塔塔利亚写信,暗示可以向米兰总督推荐塔塔利亚。 At this point Cardan enters the story. As public lecturer of mathematics at the Piatti Foundation in Milan, ... he contacted Tartaglia, through an intermediary, ... asked to be shown the method, promising to keep it secret. Tartaglia, however, refused. An incensed Cardan now wrote to Tartaglia directly, ... hinting that he had been discussing Tartaglia's brilliance with the governor of Milan, Alfonso d'Avalos, the Marchese del Vasto, who was one of Cardan's powerful patrons. 在威尼斯当穷教师的塔塔利亚一见有高升的机会,态度大变,于1539年3月动身前往米兰,受到卡当的热情招待。在卡当苦苦哀求,并向上帝发誓绝不泄密后,塔塔利亚终于向卡当传授了用诗歌暗语写成的解法。卡当把武林秘笈拿到手,并没有就对塔塔利亚翻脸,但塔塔利亚却像许多泄密者一样,马上就后悔了,无心再在米兰求发展,匆忙赶回威尼斯。在那一年卡当出版了两本数学著作,塔塔利亚都细细研读,一方面很高兴卡当没有在著作中公布三次方程解法,一方面又觉得自己受了卡当的欺骗,在给卡当的信中把这两本书嘲笑了一番,断绝了与卡当的交情。 On receipt of this letter, Tartaglia radically revised his attitude, ... So, in March 1539, Tartaglia left Venice and travelled to Milan. ... Cardan attended to his guest's every need and soon the conversation turned to the problem of cubic equations. Tartaglia, after much persuasion, agreed to tell Cardan his method, if Cardan would swear never to reveal it, ... and Tartaglia divulged his formula in the form of a poem ... Anxious now to leave Cardan's house, he obtained from his host, a letter of introduction to the Marchese and left to seek him out. Instead though, he turned back for Venice, wondering if his decision to part with his formula had been a mistake ... Cardan published two mathematical books later that year and, as soon as he could get copies, Tartaglia checked to make sure his formula was not included. Though he felt a little happier to find that the formula was not included in the texts, when Cardan wrote to him in a friendly manner Tartaglia rebuffed his offer of continued friendship and mercilessly ridiculed his books on the merest trivialities. 卡当在获得塔塔利亚的解法后,在其基础上很快就发现所有的三次方程的解法。次年,卡当18岁的秘书费拉里在三次方程解法的基础上又发现了四次方程的解法。卡当与塔塔利亚不同,热衷于通过著书立说发布新发现来赢得名利。但是他和费拉里发现的解法都是建立在塔塔利亚的解法基础上的,根据卡当立下的誓言,塔塔利亚不公布其解法,他们的解法就不得公布。 Based on Tartaglia's formula, Cardan and Ferrari, his assistant, made remarkable progress finding proofs of all cases of the cubic and, even more impressively, solving the quartic equation. It was soon clear to Cardan that his secretary was an exceptionally gifted young man ... Ferrari ... when he was eighteen years old, he began to teach. ... Cardan and Ferrari made remarkable progress on the foundations that Tartaglia had unwillingly given them. They ... eventually were able to extend solutions discovered in these special cases. Ferrari discovered the solution of the quartic equation in 1540 ... but it relied on the solution of cubic equations so could not be published before the solution of the cubic had been published. However, there was no way to make this public without the breaking the sacred oath made by Cardan. 而塔塔利亚显然是想把其解法当成赢得比赛的秘密武器,丝毫也没有想公布出来的迹象。 Tartaglia made no move to publish his formula ... Tartaglia probably wished to keep his formula in reserve for any upcoming debates. 这让卡当很苦恼。 1543年,卡当和费拉里前往博洛尼亚,见到在那里接替费罗当数学教授的费罗的女婿,后者向他们出示了费罗的手稿,证明费罗在塔塔利亚之前就已经发现了解法。这使卡当如释重负,觉得没有必要再遵守誓言,于是在1545年出版的著作《大术》中公布了三次方程和四次方程的解法。为了避免被指控剽窃,卡当在书中特别提到了费罗和塔塔利亚的贡献。 Cardan and Ferrari travelled to Bologna in 1543 and learnt from della Nave that it had been del Ferro, not Tartaglia, who had been the first to solve the cubic equation. Cardan felt that although he had sworn not to reveal Tartaglia's method surely nothing prevented him from publishing del Ferro's formula. In 1545 Cardan published Artis magnae sive de regulis algebraicis liber unus, or Ars magna as it is more commonly known, which contained solutions to both the cubic and quartic equations and all of the additional work he had completed on Tartaglia's formula. Del Ferro and Tartaglia are credited with their discoveries, as is Ferrari, and the story written down in the text. Cardan and Ferrari satisfied della Nave ... and della Nave showed them in return the papers of the late del Ferro, proving that Tartaglia was not the first to discover the solution of the cubic. del Ferro ... kept a notebook in which he recorded his most important discoveries. This notebook passed to del Ferro's son-in-law Hannibal Nave ... Hannibal Nave took over del Ferro's lecturing duties at the University of Bologna 但是这并没有减轻塔塔利亚对他的憎恨。塔塔利亚在第二年出版了一本书,在书中揭露卡当背信弃义,淋漓尽致地对卡当进行人身攻击。卡当此时由于《大术》一书已名满天下,不想和塔塔利亚计较,但费拉里决定要为主人讨回公道,在公开信中对塔塔利亚反唇相讥,向塔塔利亚提出比赛挑战。塔塔利亚对此很不情愿,因为和无名小辈比赛即使赢了也没有什么好处,万一输了脸可就丢大了。塔塔利亚在给费拉里的回信中,要求由卡当来应战。但是卡当仍不予理会。塔塔利亚和费拉里来来回回打了一年的笔墨官司,仍然没有解决争端。到1548年事情出现转机,塔塔利亚的家乡布雷西亚向塔塔利亚提供了一份报酬不薄的教职,条件是塔塔利亚必须去和费拉里比赛解决争端。 Tartaglia was furious when he discovered that Cardan had disregarded his oath and his intense dislike of Cardan turned into a pathological hatred. The following year Tartaglia published a book, New Problems and Inventions which clearly stated his side of the story and his belief that Cardan had acted in extreme bad faith. For good measure, he added a few malicious personal insults directed against Cardan. Ars Magna had clearly established Cardan as the world's leading mathematician and he was not much damaged by Tartaglia's venomous attacks. Ferrari, however, wrote to Tartaglia, berating him mercilessly and challenged him to a public debate. Tartaglia was extremely reluctant to dispute with Ferrari, still a relatively unknown mathematician, against whom even a victory would do little material good ... So Tartaglia replied to Ferrari, trying to bring Cardan into the debate. Cardan, however, had no intention of debating with Tartaglia. Ferrari and Tartaglia wrote fruitlessly to each other for about a year, trading the most offensive personal insults but achieving little in the way of resolving the dispute. Suddenly in 1548, Tartaglia received an impressive offer of a lectureship in his home town, Brescia. To clearly establish his credentials for the post, Tartaglia was asked to journey to Milan and take part in the contest with Ferrari. 1548年8月10日,比赛在米兰总督的主持下在米兰的教堂举行,吸引了大量的看客。费拉里带了众多支持者助阵,而塔塔利亚只带了一位同胞兄弟,费拉里可谓占尽了天时地利人和,而且在开场白中就已经表现出他对三次和四次方程的理解要比塔塔利亚透彻。身经百战的塔塔利亚一见大势不妙,在当天晚上悄悄地离开了米兰。 On 10 August 1548, the contest which all Italy wanted to see, for the correspondence between the two antagonists had taken the form of open letters, took place in the Church in the Garden of the Frati Zoccolanti in Milan. A huge crowd had gathered, and the Milanese celebrities came out in force, with Don Ferrante di Gonzaga, governor of Milan, the supreme arbiter. Ferrari ... brought a large crowd of friends and supporters. Alone but for his brother, Tartaglia was a vastly experienced disputant ... By the end of the first day, it was clear that things were not going Tartaglia's way. .... Ferrari clearly understood the cubic and quartic equations more thoroughly than his opponent who decided that he would leave Milan that very night and thus leave the contest unresolved, so victory went to Ferrari. 结果塔塔利亚不仅名誉扫地,而且经济也陷入困境。布雷西亚虽然让他教了一年书,却不支付他的薪水。看来那个时候并没有禁止拖欠教师工资的规定,塔塔利亚打了几场官司也没能把欠薪讨回来,灰溜溜又回到威尼斯继续当他的穷教师。1557年,57岁的塔塔利亚带着对卡当的满腔仇恨,在贫困中死去。 Tartaglia suffered as a result of the contest. After giving his lectures for a year in Brescia, he was informed that his stipend was not going to be honoured. Even after numerous lawsuits, Tartaglia could not get any payment and returned, seriously out of pocket, to his previous job in Venice, nursing a huge resentment of Cardan ... He died in poverty in his house ... 13 Dec 1557 in Venice 费拉里在比赛后名声大震,甚至连皇帝都来请他给太子当老师。但费拉里选择了给米兰总督当估税员发财。1565年,年仅43岁的费拉里已成了富翁,提前退休回博洛尼亚,不幸当年就去世了,据说是被他的妹妹毒死的,为了继承他的财产。 On the strength of this challenge, Ferrari's fame soared and he was inundated with offers of employment, including a request from the emperor himself, who wanted a tutor for his son. Ferrari fancied a more financially rewarding position though, and took up an appointment as tax assessor to the governor of Milan, Ferrando Gonzaga. After transferring to the service of the church, he retired as a young and very rich man. He moved back to his home town of Bologna ... in 1565 but, sadly, Ferrari died later that year. It is claimed that he died of white arsenic poisoning, administered by his own sister. Certainly, according to Cardan, Maddalena refused to grieve at her brother's funeral and, having inherited Ferrari's fortune, she remarried two weeks later. 只有卡当得以长寿,活到了75岁,不过他本来可以活得更长迷信占星术的卡当预测自己将死于1575年9月21日,为了实现自己的预言,他在那一天自杀。 Cardan is reported to have correctly predicted the exact date of his own death but it has been claimed that he achieved this by committing suicide. 科学研究毕竟是人从事的事业,人性的弱点也会在其中表现出来。做为一项最为看重首创权的工作,因争名夺利结下的种种个人恩怨也就难以避免,有时也难以让人看清其中的是非曲折。虽然根据现代科研的规范和历史资料来看,卡当在这个事件中的所作所为并无过错,他并没有试图去剽窃他人成果,为了公布学术成果与众人分享所作的努力还很值得赞赏,反倒是塔塔利亚死守学术成果的偏执和对卡当的憎恨都有点变态。奇怪的是,在后人的传说中,卡当却成了欺世盗名的骗子,人们对弱者的同情有时会超过了对真相的探求。不过事实的真相毕竟难以掩盖,尤其是在信息发达的今天,更是如此。 2006.9.17. (《经济观察报》2006.9.23,链接: )