Fortran Coarray 无法编译

Fortran Coarray cant compile

我正在尝试编译 Coarray Fortran 文件的示例。 https://github.com/ljdursi/coarray-examples 编译命令为:

mpifort diffusion/diffusion-coarray.f90 -fcoarray=lib -o diffusion/diffusion-coarray -L ${PATH_TO_OPENCOARRAY_LIB} -lcaf_mpi

我已经使用 spack 安装了 OpenCoarrays 但是出现错误:

/usr/bin/ld: cannot find -lcaf_mpi
collect2: error: ld returned 1 exit status

没有 -lcaf_mpi 错误是:

/tmp/ccOdrmfc.o: In function `MAIN__':
diffusion-coarray.f90:(.text+0x32): undefined reference to `_gfortran_caf_num_images'
diffusion-coarray.f90:(.text+0x4c): undefined reference to `_gfortran_caf_this_image'
diffusion-coarray.f90:(.text+0x66): undefined reference to `_gfortran_caf_this_image'
diffusion-coarray.f90:(.text+0x77): undefined reference to `_gfortran_caf_num_images'
diffusion-coarray.f90:(.text+0x8a): undefined reference to `_gfortran_caf_num_images'
diffusion-coarray.f90:(.text+0xaa): undefined reference to `_gfortran_caf_this_image'
diffusion-coarray.f90:(.text+0xbd): undefined reference to `_gfortran_caf_this_image'
diffusion-coarray.f90:(.text+0xf4): undefined reference to `_gfortran_caf_num_images'

结束等 问题出在哪里?

感谢您的帮助。我已经解决了这个问题。如果有人感兴趣,这是我的解决方案: 1. 按照他们的说明安装 Linuxbrew:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

test -d ~/.linuxbrew && PATH="$HOME/.linuxbrew/bin:$HOME/.linuxbrew/sbin:$PATH"
test -d /home/linuxbrew/.linuxbrew && PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH"
test -r ~/.bash_profile && echo "export PATH='$(brew --prefix)/bin:$(brew --prefix)/sbin'":'"$PATH"' >>~/.bash_profile
echo "export PATH='$(brew --prefix)/bin:$(brew --prefix)/sbin'":'"$PATH"' >>~/.profile
  1. 安装 OpenCoarrays 库 brew install opencoarrays 现在我们可以用 cafcafrun
  2. 编译文件
  3. 编译.exe-filecaf fname.f90 -o test.exe
  4. 运行 程序 cafrun -np (numimages) test.exe

希望对大家有所帮助! P.S。我的 OS 是 Ubuntu 16.04.4 LTS, gfortran: GNU Fortran 5.4.0 20160609 所以剩下的必要的工具(例如,编译器 caf 和启动器 cafrun 是 OpenCoarrays 包的一部分)将按照说明进行安装。