免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5342 | 回复: 3
打印 上一主题 下一主题

使用g77/gfortran编译mvapich的相关问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-02-27 21:40 |只看该作者 |倒序浏览
  1. 1.安装
  2. 在混和使用g77与gfortran编译mvapich时,官方文档<MVAPICH 1.0 User and Tuning Guide>中提到了要设置如下的相关的参数,这里我以make.mvapich.smp为例.
  3. #vi make.mvapich.smp
  4. 18 PREFIX=${PREFIX:-/usr/local/mvapich}
  5. 19 export CC=${CC:-gcc}
  6. 20 export CXX=${CXX:-g++}
  7. 21 export F77=${F77:-g77}
  8. 22 export F90=${F90:-gfortran}
  9. 23 export F77_GETARGDECL=" "
  10. 24 export F90FLAGS="-ff2c"

  11. 修改完成后进行编译安装:
  12. #./make.mvapich.smp
  13. 通过查看目录下config-mine.log可以查看相关信息.

  14. 完成安装后,可以看到存在/usr/local/mvapich/examples/pi3f90.f90,说明mpif90己经配置安装,可以使用了.

  15. 2.测试
  16. 开始测试mpif90是否能正常编译f90程序.
  17. #cd /usr/local/mvapich/examples
  18. #/usr/local/mvapich/bin/mpif90   pi3f90.f90
  19. pi3f90.o: In function `MAIN__':
  20. pi3f90.f90:(.text+0x2c): undefined reference to `mpi_init_'
  21. pi3f90.f90:(.text+0x46): undefined reference to `mpi_comm_rank_'
  22. pi3f90.f90:(.text+0x60): undefined reference to `mpi_comm_size_'
  23. pi3f90.f90:(.text+0x254): undefined reference to `mpi_bcast_'
  24. pi3f90.f90:(.text+0x338): undefined reference to `mpi_reduce_'
  25. pi3f90.f90:(.text+0x3f5): undefined reference to `mpi_finalize_'
  26. collect2: ld returned 1 exit status

  27. 3.如何解决上面的问题呢?
  28. 1)首先在mpif90中加入F90FLAGS的信息
  29. #vi /usr/local/mvapich/bin/mpif90
  30. 30 F90BASE="gfortran"
  31. 31 F90LINKERBASE="gfortran"
  32. 32 F90FLAGS="-ff2c"

  33. #/usr/local/mvapich/bin/mpif90   pi3f90.f90
  34. /usr/local/mvapich/lib/libmpich.a(farg.o): In function `mpir_iargc__':
  35. farg.f:(.text+0x7): undefined reference to `f__xargc'
  36. /usr/local/mvapich/lib/libmpich.a(farg.o): In function `mpir_getarg__':
  37. farg.f:(.text+0x27): undefined reference to `G77_getarg_0'
  38. collect2: ld returned 1 exit status
  39. make: *** [pi3f90] Error 1

  40. 2)接下来生成一个farg.f的文件,生成farg.o文件.
  41. #vi farg.f
  42.   1       integer function mpir_iargc()
  43.   2
  44.   3       mpir_iargc = IARGC()
  45.   4       return
  46.   5       end
  47.   6 c     
  48.   7       subroutine mpir_getarg( i, s )
  49.   8
  50.   9       integer       i
  51. 10       character (LEN=*) s
  52. 11
  53. 12       call GETARG(i,s)
  54. 13       return
  55. 14       end

  56. #gfortran -fsecond-underscore -c farg.f

  57. 3)使用下面的命令生成pi3f90文件.
  58. #/usr/local/mvapich/bin/mpif90  -c pi3f90.f90
  59. #/usr/local/mvapich/bin/mpif90  -o pi3f90 pi3f90.o farg.o

  60. (补充:若又出现了

  61. /usr/local/mvapich/bin/mpif90  -o pi3f90 pi3f90.o farg.o

  62. farg.o(.text+0x34): In function `mpir_getarg__':

  63. : undefined reference to `getarg_'

  64. collect2: ld returned 1 exit status )



  65. 修改mpif90下面两行类似以下

  66. USER_FFLAGS="-L/usr/lib/gcc/x86_64-redhat-linux/3.4.6 -L/usr/lib64" ( 我的g77是3.4.6版的)

  67. BASE_LIB_LIST=" -L/usr/lib64 -Wl,-rpath=/usr/lib64 -libverbs -libumad -lpthread  -lpthread  -lrt -lg2c")


  68. 4)最终测试
  69. #mpirun_rsh -np 2 n1 n2 GFORTRAN_UNBUFFERED_ALL=y ./pi3f90
  70. Process            0  of            2  is alive
  71. Enter the number of intervals: (0 quits)
  72. Process            1  of            2  is alive
  73. 10000000
  74.   pi is approximately: 3.1415926535899814  Error is: 0.0000000000001883
  75. Enter the number of intervals: (0 quits)

  76. 写这篇文档的原由是由于在解决这个问题的过程中,google后很失望,通过对[url]http://www.pgroup.com/support/link.htm[/url] 这篇文档的反复琢磨,有了上面的文档,希望对后来者有用.
复制代码

[ 本帖最后由 wysilly 于 2008-2-28 17:15 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-02-28 04:15 |只看该作者
great job!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP