【发布时间】:2016-02-09 12:55:26
【问题描述】:
我正在尝试在 OS X (10.11) 上编译使用 OpenMPI 的 Fortran 程序。我首先从Mac HPC 安装 gcc (5.2)、gfortran (5.2) 等。然后我从the official site 下载了 Open MPI 源版本 1.10.1。然后我构建并安装了 Open MPI(配置、制作、制作安装),一切似乎都可以正常工作。我没有收到任何错误,并且库和二进制文件在我期望的位置。
然后我开始使用 mpif90 编译一个非常简单的 Open MPI fortran 应用程序,这时我收到了来自 ld 的以下链接错误。
Undefined symbols for architecture x86_64:
"_f_", referenced from:
_MAIN__ in ccm61Nim.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
有人见过这个吗?我怀疑这与我没有使用标准的 Apple 构建链有关,但我不确定。
正在编译的代码:
program main
use mpi
double precision PI25DT
parameter (PI25DT = 3.141592653689793238462643d0)
double precision mypi, pi, h, sum, x, f, a
integer n, myid, numprocs, i, ierr
! function to integrate f(a) = 4.d0 / (1.d0 + a*a)
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, numprocs, ierr)
do
if (myid .eq. 0) then
print *, 'Enter the number of intervals: (0 quits)'
read(*,*) n
endif
! broadcast n
call MPI_BCAST(n, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
! check for quit signal
if (n .le. 0) exit
! calculate the interval size
h = 1.0d0 / n
sum = 0.0d0
do i = myid + 1, n, numprocs
x = h * (dble(i) - 0.5d0)
sum = sum + f(x)
enddo
mypi = h * sum
! collect all the partial sums
call MPI_REDUCE(mypi, pi, 1, MPI_DOUBLE_PRECISION, MPI_SUM, 0, MPI_COMM_WORLD, ierr)
! node 0 prints the answer
if (myid .eq. 0) then
print *, 'pi is ', pi, ' Error is', abs(pi - PI25DT)
endif
enddo
call MPI_FINALIZE(ierr)
end
【问题讨论】:
标签: macos fortran fortran90 openmpi