首页 > 解决方案 > fortran coarray 图像访问无法正常工作?

问题描述

使用一个简单的 gfortran coarray 程序。

由于某种原因,从根进程(例如 a[2])访问变量的图像不起作用。

我是否正确访问这些图像?是否有可能我错误地编译了 coarray 库?

coarray.f90

program coarraytest
    implicit none
    integer, codimension[*]:: a
    integer:: tot
    if(this_image()==1) then
     a=10
    endif
    if(this_image()==2) then
     a=20
    endif
    sync all                    ! synchronize
    if(this_image()==1) then
    tot=a+a[2]
     print *, a, a[2], tot
    end if
sync all
print *, this_image(), ': ', a
end program

输出

  10           0   682453724
   1 :           10
   2 :           20

笔记

系统:

Ubuntu Linux 20.04

gfortran

OpenMPI (OpenRTE) 4.0.3

汇编:

caf coarray.f90 -o coarray.o

执行:

cafrun -n 2 coarraytest.o

标签: fortrangfortranfortran-coarrays

解决方案


好的,看起来这是一个乐队安装。我首先点击了这个链接: https ://askubuntu.com/questions/1277932/cannot-install-open-coarrays-bin-for-gfortran-on-ubuntu-20-04

这是过时的。必须卸载所有垃圾并点击以下链接:

https://github.com/sourceryinstitute/OpenCoarrays/blob/master/INSTALL.md#linux


推荐阅读