Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

distribution of memory for coarray

Yuri1
Beginner
462 Views

Whether it is possible to allocate for a array of coarray on different images the different size?
I have tested a following example, but it does not work:

module moduls
real(8), allocatable:: Z(:,:)[:]
! d - for transfer of dimension of matrix Z
integer :: d


  • end module moduls
  • program main
    use moduls
    np = this_image()
    call impedance! Allocation of memory and initialization of matrix Z
    sync all

    if (np ==1) then
    m = d[4]
    print*,'check Z on image', m
    do j = 1,m
    write(*,'(f6.2)' ) (z(j,n)[4], n=1,m)!
    enddo
    sync images(*)
    else
    sync images(1)
    endif
    end program main

    subroutine impedance
    use moduls
    np = this_image()
    d = np
    allocate( Z(d,d)

  • )
    !initialization of matrix Z
    do i = 1,d
    do j = 1,d
    Z(i,j) = real(i)
    enddo
    enddo
  • if (np == 4) then
    print*,'input Z on image', d
    do j = 1,d
    write(*,'(f6.2)' ) (z(j,n), n=1,d)
    enddo
    endif
    return
    END subroutine impedance

    Result: wrong transfer of a array

    input Z on image 4
    1.00 1.00 1.00 1.00
    2.00 2.00 2.00 2.00
    3.00 3.00 3.00 3.00
    4.00 4.00 4.00 4.00
    check Z on image 4
    1.00 2.00 3.00 4.00
    2.00 3.00 4.00 1.00
    3.00 4.00 1.00 2.00
    4.00 1.00 2.00 3.00

    Where a error?

    Sincerely, Yuri

    0 Kudos
    2 Replies
    Steven_L_Intel1
    Employee
    462 Views
    No, that is not allowed.

    "The values of corresponding bounds and corresponding cobounds shall be the same on every image."

    However, the standard also says that "The processor is not required to detect violations of the rule that the bounds are the same on all images".
    0 Kudos
    Yuri1
    Beginner
    462 Views

    Thanks for the detailed answer.

    Sincerely,
    Yuri

    0 Kudos
    Reply