program test2
implicit none
integer :: me
me = this_image() ! 需要先声明me再赋值,如果直接在声明初始化,会保存到常量区,变成大家共有的变量
if(me > 1) sync images(me-1)!编号高的image需要等待前一个image彻底运行完到程序结束?
write(*,*) "Image from ", this_image(), "out of", num_images()
if(me < num_images()) sync images(me+1)!image1 这里不需要等待image2?
write(*,*) "Image from ", this_image(), "out of", num_images()
end program test2
风平老涡 发表于 2023-10-4 22:10
因为对于 image1 和 image2 俩个if语句产生竟速,结果不可预测。
program test2
implicit none
integer :: me
me = this_image() ! 需要先声明me再赋值,如果直接在声明初始化,会保存到常量区,变成大家共有的变量
if(me > 1) sync images(me-1)
write(*,*) "Image from ", this_image(), "out of", num_images()
if(me < num_images()) sync images(me+1)
if(me < num_images()) sync images(me+1)
write(*,*) "Image from ", this_image(), "out of", num_images()
if(me > 1) sync images(me-1)
end program test2
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |