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

Coarray bug?

OP1
New Contributor III
989 Views

The following example may just reflect my poor understanding of how coarrays work... or it could be a bug. Compiled with the IVF 15.0 update 0, using VS2013 shell... any comments?

PROGRAM TEST
IMPLICIT NONE

TYPE T_A
    INTEGER :: VALUE
END TYPE T_A

TYPE T_B
    TYPE(T_A),ALLOCATABLE :: ARRAY(:)
END TYPE T_B

TYPE(T_B) :: COARRAY
  • ! This section leads to an access violation error. !IF (THIS_IMAGE()==1) THEN ! ALLOCATE(COARRAY[1]%ARRAY(10)) !END IF ! This section works. IF (THIS_IMAGE()==1) THEN ALLOCATE(COARRAY%ARRAY(10)) END IF END PROGRAM TEST
  •  

    0 Kudos
    1 Solution
    IanH
    Honored Contributor III
    989 Views

    The commented out allocate statement is not legal fortran - if you are allocating a structure component then the thing that designates the particular parent of the component cannot be coindexed.  But the compiler should diagnose this at compile time (C644).

    (If you think about it conceptually - with the [xx] coindexing you are directing the current image to go and do a local allocation on image xx (image xx and the current image happen to be the same here, but the syntax you are using implies that they could be different) of something that isn't itself a coarray (it is a component of a coarray), and that doesn't really make sense - it is remote specification of an executable action.  If you want image xx to do a local allocation, then get image xx to execute an allocate statement on a local object as part of its sequence of execution (which is exactly what you have in the not commented out bit).  Note this situation is different from all images executing a synchronised allocate statement for a coarray proper.)

    View solution in original post

    0 Kudos
    4 Replies
    IanH
    Honored Contributor III
    990 Views

    The commented out allocate statement is not legal fortran - if you are allocating a structure component then the thing that designates the particular parent of the component cannot be coindexed.  But the compiler should diagnose this at compile time (C644).

    (If you think about it conceptually - with the [xx] coindexing you are directing the current image to go and do a local allocation on image xx (image xx and the current image happen to be the same here, but the syntax you are using implies that they could be different) of something that isn't itself a coarray (it is a component of a coarray), and that doesn't really make sense - it is remote specification of an executable action.  If you want image xx to do a local allocation, then get image xx to execute an allocate statement on a local object as part of its sequence of execution (which is exactly what you have in the not commented out bit).  Note this situation is different from all images executing a synchronised allocate statement for a coarray proper.)

    0 Kudos
    OP1
    New Contributor III
    989 Views

    Thank IanH for your explanation. It seems this compiler check is not implemented yet.

    0 Kudos
    Steven_L_Intel1
    Employee
    989 Views

    I entered issue DPD200360195 about the missing constraint check.

    0 Kudos
    Steven_L_Intel1
    Employee
    989 Views

    This will be fixed in a release later this year.

    0 Kudos
    Reply