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

Behavior of SIZE and ALLOCATED across coarray images

OP1
New Contributor II
306 Views

The program below shows a different behavior for SIZE and ALLOCATED across coarray images. Naively, I would assume that both work (SIZE does, ALLOCATED does not) if the only thing they do is read the array descriptor data. Is there an explanation for this?

PROGRAM MAIN
IMPLICIT NONE
TYPE TT
    INTEGER,ALLOCATABLE :: VALUES(:)
END TYPE TT
TYPE(TT) :: T
  • INTEGER :: I SYNC ALL IF (THIS_IMAGE()>1) THEN ALLOCATE(T%VALUES(THIS_IMAGE())) END IF SYNC ALL IF (THIS_IMAGE()==1) THEN DO I=2,NUM_IMAGES() WRITE(*,*) ALLOCATED(T%VALUES) WRITE(*,*) SIZE(T%VALUES) END DO END IF END PROGRAM MAIN
  •  

    0 Kudos
    6 Replies
    Steven_L_Intel1
    Employee
    306 Views

    There is an explanation - the standard forbids the use of ALLOCATED here, since a coindexed object is not allocatable (you can't say ALLOCATE(T%VALUES), but the compiler fails to diagnose the error.  I will let the developers know. Issue ID is DPD200381147.

    0 Kudos
    Steven_L_Intel1
    Employee
    306 Views

    I was mistaken in saying that ALLOCATED is not allowed here - it is, because the only requirement is that it be an array or scalar with the ALLOCATABLE attribute. But we are still returning the wrong value.

    0 Kudos
    OP1
    New Contributor II
    306 Views

    Thanks Steve,

    I am glad to hear that the query function ALLOCATED() can be used across coarray images. It is very useful since I suspect many of us use the strategy of having a top-level derived-type coarray variable that contains many image-specific allocatable arrays of variable size. When an image wants to access data on an other image, a check regarding the allocation status of such arrays may be desirable or necessary, for a host of reasons.

    The work around right now is to have custom ALLOCATE/DEALLOCATE subroutines that store a logical variable representing the status of the array they are associated with. It's not a huge burden, but it seems it should not be necessary.

    I hope a fix for this can make it into the next update. 16 Update 2 is looking really good otherwise.

    0 Kudos
    Steven_L_Intel1
    Employee
    306 Views

    It looks as if the fix for this will be in the 17.0 product release.

    0 Kudos
    OP1
    New Contributor II
    306 Views

    Thanks Steve - I saw that it was fixed in the beta version already, which is great.

    As an aside, will a license for XE16 allow for upgrade to XE17 when it is released (assuming that this occurs within one year of the purchase of the original license)? I think it is the case but just want to check.

    0 Kudos
    Steven_L_Intel1
    Employee
    306 Views

    Yes, you get any new updates or versions released during your support term.

    0 Kudos
    Reply