使用 coarray 标志(并启用运行时检查)编译的应用程序在尝试将非连续数组写入屏幕时中止

Application compiled with coarray flag (and runtime check enabled) aborting when trying to write non-contiguous array to screen

我有一个 Fortran 程序,我在其中定义了一个二维数组。接下来,我希望使用循环编写数组的所有元素。为此,我使用以下代码:

program main
    use, intrinsic:: iso_fortran_env, only: output_unit, input_unit, error_unit
    implicit none

    integer :: NY = 5, NX = 4
    integer, allocatable, dimension(:, :) :: a_global
    integer, allocatable, dimension(:) :: a_temp
    integer :: i, j, me

    allocate( a_global(NY, NX), source=0 )

    do i = 1, NX
        do j = 1, NY
            a_global(j, i) = j + ( i - 1 ) * NY
        end do
    end do

    write( output_unit, * ) "a_global in image 1 (printed column-wise) = "
    do i = 1, NX
        write( output_unit, * ) a_global(:, i)
    end do
    write( output_unit, * ) ""

    write( output_unit, * ) "a_global in image 1 (printed row-wise) = "
    do i = 1, NY
        ! a_temp = a_global(i, :)
        ! write( output_unit, * ) a_temp
        write( output_unit, * ) a_global(i, :)
    end do
end program main

我正在使用 intel 编译器编译程序,并使用以下语法进行编译:

ifort -check all program.f90

当可执行文件为运行时,第一组写入命令按预期打印数组,即,它在新行中打印数组的所有列。但是,尽管第二组写入命令在每行打印一行数组之前抛出以下警告,但它 运行 成功了。

forrtl: warning (406): fort: (1): In call to I/O Write routine, an array temporary was created for argument #1

Image              PC                Routine            Line        Source             
a.out              0000000000406C86  Unknown               Unknown  Unknown
a.out              0000000000403EE5  Unknown               Unknown  Unknown
a.out              00000000004029DE  Unknown               Unknown  Unknown
libc-2.17.so       00007F83EA940495  __libc_start_main     Unknown  Unknown
a.out              00000000004028E9  Unknown               Unknown  Unknown

现在,我希望并行编写同一个程序,并让图像 1 定义和写入上述数组。为此,我在代码中做了以下修改:

program main
    use, intrinsic:: iso_fortran_env, only: output_unit, input_unit, error_unit
    implicit none

    integer :: NY = 5, NX = 4
    integer, allocatable, dimension(:, :) :: a_global
    integer, allocatable, dimension(:) :: a_temp
    integer :: i, j, me

    sync all

    me = this_image()

    allocate( a_global(NY, NX), source=0 )

    if ( me == 1 ) then
        do i = 1, NX
            do j = 1, NY
                a_global(j, i) = j + ( i - 1 ) * NY
            end do
        end do

        write( output_unit, * ) "a_global in image 1 (printed column-wise) = "
        do i = 1, NX
            write( output_unit, * ) a_global(:, i)
        end do
        write( output_unit, * ) ""

        write( output_unit, * ) "a_global in image 1 (printed row-wise) = "
        do i = 1, NY
            ! a_temp = a_global(i, :)
            ! write( output_unit, * ) a_temp
            write( output_unit, * ) a_global(i, :)
        end do
    end if
end program main

这次我编译上面的代码使用:

ifort -coarray -check all program.f90

现在,当我尝试 运行 该程序时,它会抛出相同的警告。但这次它因以下附加错误而停止:

application called MPI_Abort(comm=0x84000004, 3) - process 0

我知道显示警告是因为 fortran 试图打印一组不连续的数组值。但我不明白的是,当我尝试 运行 它与 运行 时间检查并行时,为什么应用程序会中止。它不应该只是抛出相同的警告并优雅地结束吗?我在这里错过了什么?

P.S。我正在使用 CentOS 7 和 Intel parallel studio 2017 学生版。

我认为这是 Intel 实现中的错误。你应该向英特尔报告。即使没有警告消息,我也会中止。可以通过不启用 -check(特别是 -check arg_temp_created)

来禁用警告

由于您拥有学生许可,因此您需要在位于 https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x 的英特尔用户论坛上执行此操作。这种问题真的比这里更适合。