Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Parallel processing 在gfortran的Fortran协同阵列中只有一个映像_Parallel Processing_Fortran_Gfortran_Fortran Coarrays - Fatal编程技术网

Parallel processing 在gfortran的Fortran协同阵列中只有一个映像

Parallel processing 在gfortran的Fortran协同阵列中只有一个映像,parallel-processing,fortran,gfortran,fortran-coarrays,Parallel Processing,Fortran,Gfortran,Fortran Coarrays,我正在使用gfortran编译器,并尝试在没有MPI的情况下进行并行编程。尽管我花了太多时间阅读Fortran、gfortran和并行编程,但我无法同时使用不同的处理器 我的目的是创建一个在不同处理器上工作的矩阵乘法,以减少时间。我有很多想法,但首先,我必须使用不同的处理器。但即使我使用书面代码,我的电脑也只有一个图像。例如: program hello_image integer::a write(*,*) "Hello from image ", this_image(), &

我正在使用gfortran编译器,并尝试在没有MPI的情况下进行并行编程。尽管我花了太多时间阅读Fortran、gfortran和并行编程,但我无法同时使用不同的处理器

我的目的是创建一个在不同处理器上工作的矩阵乘法,以减少时间。我有很多想法,但首先,我必须使用不同的处理器。但即使我使用书面代码,我的电脑也只有一个图像。例如:

program hello_image

integer::a

  write(*,*) "Hello from image ", this_image(), &
              "out of ", num_images()," total images"

    read(*,*), a

end program hello_image
这是一个非常简单的程序,取自一个pdf文件,关于Fortran中的并行编程。它应该给出以下输出:

Hello from image 1 out of 8
Hello from image 2 out of 8
Hello from image 3 out of 8
Hello from image 4 out of 8
Hello from image 5 out of 8
Hello from image 6 out of 8
Hello from image 7 out of 8
Hello from image 8 out of 8
Hello from image 1 out of 1.
但我的编译器只是给出了输出:

Hello from image 1 out of 8
Hello from image 2 out of 8
Hello from image 3 out of 8
Hello from image 4 out of 8
Hello from image 5 out of 8
Hello from image 6 out of 8
Hello from image 7 out of 8
Hello from image 8 out of 8
Hello from image 1 out of 1.
我使用gfortran作为命令的编译器

gfortran "codename" -fcoarray=single
我花了太多时间来解决这个“可能很简单的问题”,但我就是解决不了

这是我在尝试-fcoarray=lib时得到的输出。这就是为什么我使用-fcoarray=single,因为它是唯一可以执行的。我该怎么解决这个问题?谢谢你的帮助

/tmp/ccvnPvRc.o: In function `MAIN__':
hew.f08:(.text+0x62): undefined reference to `_gfortran_caf_this_image'
hew.f08:(.text+0xa8): undefined reference to `_gfortran_caf_num_images'
/tmp/ccvnPvRc.o: In function `main':
hew.f08:(.text+0x175): undefined reference to `_gfortran_caf_init'
hew.f08:(.text+0x19f): undefined reference to `_gfortran_caf_finalize'
collect2: error: ld returned 1 exit status
尽管如此,我还是从OpenCoarray的网站上安装了linuxbrew,仍然存在同样的问题。brew医生说,除了我使用这条线路之外,没有任何问题

gfortran hew.f08 -fcoarray=lib -lcaf_mpi
gfortran hew.f08 -fcoarray=lib -lcaf_mpi
出现同样的错误。我应该使用另一个包装和另一条生产线吗?我应该下载的软件包是什么?如何下载?如何使用gfortran生成可执行文件?(我正在使用Ubuntu)

我曾经

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)"
要安装的线路。然后,我使用这两行设置路径

PATH=/home/[username]/.linuxbrew/bin:$PATH
PATH=/home/linuxbrew/.linuxbrew/bin:$PATH
现在,当我使用线路时

gfortran hew.f08 -fcoarray=lib -lcaf_mpi
gfortran hew.f08 -fcoarray=lib -lcaf_mpi
输出为:

/usr/bin/ld: cannot find -lcaf_mpi
collect2: error: ld returned 1 exit status

您通过说
-fcoarray=single
来请求一个图像,这就是为什么只涉及一个图像。您需要使用
-fcoarray=lib
。有关详细信息,请参阅。(请注意,您很可能希望使用基于mpi的库来启用>1映像)。如果您查看我链接到的页面,您应该会看到,在使用
lib
version时,您可能还需要链接您打算用于提供阵列功能的库(rary),例如,将
-lcaf\u mpi
添加到compile+link命令意味着您正在使用mpi“后端”。然后,您可以使用
mpiexec
启动作业。您还可能会发现,如果您已经获取了该库并链接到该库,则会很有用。迪乌已经告诉你了。你看过他的链接了吗?获取OpenCoArray。我编辑了我的主要问题,因为有终端线。我现在正在检查你的链接。我下载了linuxbrew,但问题仍然存在。有linuxbrew for-fcoarray=lib函数就足够了吗?