fortrangfortranfortran-coarrays

fortran coarray image access not working properly?


Working with a simple gfortran coarray program.

For some reason accessing images of a variable from the root process (e.g. a[2]) doesn't work.

Am I accessing these images correctly? Is it possible I have compiled the coarray library incorrectly?

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

Output

  10           0   682453724
   1 :           10
   2 :           20

Notes

system:

Ubuntu Linux 20.04

gfortran

OpenMPI (OpenRTE) 4.0.3

Compilation:

caf coarray.f90 -o coarray.o

Execution:

cafrun -n 2 coarraytest.o

Solution

  • Ok, looks like it was a band install. I followed this link first: https://askubuntu.com/questions/1277932/cannot-install-open-coarrays-bin-for-gfortran-on-ubuntu-20-04

    Which is outdated. Had to uninstall all that junk and follow the following link:

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