这个帖子有些时间了,不知道答主有没有后续检查。我运行了一下coarray的例子也并没有发现问题,提供一点可能的思路吧。在coarray例子下,在co_broadcast之前(11行12行之间)你可能要加一个sync call。如果有一个image先于image 1赋值之前co_broadcast了image 1的值,就有可能得不到正确的n_limit的值。我看了一个opencoarrays里的例子(https://github.com/sourceryinstitute/OpenCoarrays/blob/ef8069d94ecd3a0d93e0d4413a63c2366b894130/src/tests/unit/collectives/co_broadcast.F90),其中
[Fortran] 纯文本查看 复制代码 ! Verify broadcasting of character data from image 1
c_char_co_broadcast: block
character(kind=c_char,len=14), save :: string_received[*]
character(kind=c_char,len=*), parameter :: string_sent=c_char_"Hello, world!"! Character test message
if (me==1) string_received=string_sent
sync all
call co_broadcast(string_received,source_image=1)
if (string_received/=string_sent) then
write(error_unit,*) "Incorrect co_broadcast(",string_received,") on image",me
else
c_char_test_passes=.true.
end if
end block c_char_co_broadcast
就是在co_broadcast之前加了sync all。
一点小建议哈~ |