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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…