我正在尝试编译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'
结束等 问题在哪里?
答案 0 :(得分:2)
感谢您的帮助。我已经解决了这个问题。如果有人有兴趣,这是我的解决方案: 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
brew install opencoarrays
现在我们可以使用caf
和cafrun
caf fname.f90 -o test.exe
cafrun -np (numimages) test.exe
希望对某人有所帮助!
附:我的操作系统是 Ubuntu 16.04.4 LTS ,gfortran: GNU Fortran 5.4.0 20160609 所以其他必要的工具(例如,编译器caf
和启动器{将按照说明安装{1}}是OpenCoarrays包的一部分。