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

Bug with exiting CHANGE TEAM constructs

OP1
Novo colaborador III
6.203 Visualizações

The behavior of the following code (compiled with ifx 2025.2.0) is incorrect:

PROGRAM P
USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : TEAM_TYPE
IMPLICIT NONE
TYPE (TEAM_TYPE) :: T
FORM TEAM(1, T)
WRITE(*, FMT = 100) 'Before CT block:', 'n = ', NUM_IMAGES(), '; i = ', &
    THIS_IMAGE(), '; t = ', TEAM_NUMBER()
CT : CHANGE TEAM (T)
    WRITE(*, FMT = 100) 'Inside CT block:', 'n = ', NUM_IMAGES(), '; i = ', &
        THIS_IMAGE(), '; t = ', TEAM_NUMBER()
    BLOCK
        EXIT CT  ! Commenting this statement leads to the expected behavior.
    END BLOCK
END TEAM CT
WRITE(*, FMT = 100) 'After CT block:', 'n = ', NUM_IMAGES(), '; i = ', &
    THIS_IMAGE(), '; t = ', TEAM_NUMBER()
100 FORMAT(A20, 4X, 3(A, I4))
END PROGRAM P

The program was run with 4 coarray images (/Qcoarray-num-images:4) and the output is the following:

    Before CT block:    n =    4; i =    1; t =   -1
    Before CT block:    n =    4; i =    4; t =   -1
    Inside CT block:    n =    4; i =    4; t =    1
    Before CT block:    n =    4; i =    3; t =   -1
    Inside CT block:    n =    4; i =    3; t =    1
     After CT block:    n =    4; i =    3; t =    1
    Before CT block:    n =    4; i =    2; t =   -1
    Inside CT block:    n =    4; i =    2; t =    1
     After CT block:    n =    4; i =    2; t =    1
    Inside CT block:    n =    4; i =    1; t =    1
     After CT block:    n =    4; i =    1; t =    1
     After CT block:    n =    4; i =    4; t =    1

As you can see, the team number reported by each image AFTER they exit the CHANGE TEAM construct is invalid: it should be back to the default team (-1) since "The current team of each image executing an END TEAM statement becomes the team that was current prior to execution of the corresponding CHANGE TEAM statement."

Note that if you comment out the EXIT statement in the inner block (on line 12), then the code behaves as expected.

Essentially, it looks as if the END TEAM statement is not properly executed.

0 Kudos
9 Respostas
Michael_S_17
Novo colaborador I
6.027 Visualizações

Your code example is not conforming. EXIT from within a CHANGE TEAM construct is not allowed. The END TEAM statement is an image control statement and must be executed to end a team. 

OP1
Novo colaborador III
6.016 Visualizações

From the Intel documentation:


An EXIT statement in a CHANGE TEAM construct is effectively the same as a branch to the END TEAM statement of the construct. Within a CHANGE TEAM construct, a CYCLE or EXIT statement is not allowed if it belongs to an outer construct. A RETURN statement may not appear in a CHANGE TEAM construct.

https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2025-2/change-team-and-end-team.html 

JohnNichols
Colaborador valorado III
5.916 Visualizações
PROGRAM MAIN 
    USE ISO_FORTRAN_ENV
    INTEGER,PARAMETER :: top_left = 11, bot_left = 21, top_right = 12, bot_right = 22
    INTEGER,DIMENSION(16) :: quads =   [top_left, top_left, bot_left, bot_left, &
                                           top_left, top_left, bot_left, bot_left, &
                                           top_right, top_right, bot_right, bot_right, &
                                           top_right, top_right, bot_right, bot_right]
    INTEGER,DIMENSION(16)      :: images = [1, 2, 1, 2, 3, 4, 3, 4, 1, 2, 1, 2, 3, 4, 3, 4]
    TYPE (TEAM_TYPE)           :: quadrants, original_team
    REAL                       :: co_array1[4,*], co_array2 [4, *]
    INTEGER                    :: me

    original_team = GET_TEAM(INITIAL_TEAM)   ! Create variable describing initial team
    me = THIS_IMAGE()
    FORM TEAM (quads(me), quadrants, NEW_INDEX=images(me))
    CHANGE TEAM (quadrants, ca[2, *] => co_array1)
    x  = ca[3, TEAM_NUMBER=top_right]
    
    END TEAM
    
    END PROGRAM

if I attempt to compile the sample from the page I get the following error:

Severity Code Description Project File Line Suppression State Details
Error error #8366: The number of cosubscripts is incorrect. [CA] B:\Users\macne\Documents\Visual Studio 2017\Projects\Program129-Heimdallr\HeatSolve\Console1\Console1\Console1.f90 17

I do not know enough about coarrays to see the error and he #8366 does not show up on a search. 

Any ideas?

Michael_S_17
Novo colaborador I
5.897 Visualizações

My mistake, you are correct. This was really new to me. EXIT does not act as an image control statement but it does branch to the image control statement. So your code example should really work. It should be a compiler bug.

OP1
Novo colaborador III
5.363 Visualizações

Tagging @Devorah_H_Intel since it looks like it's a confirmed bug.

Steve_Lionel
Colaborador honorário III
5.332 Visualizações

I confirm that the standard says, in 11.1.12 (EXIT statement): "If the EXIT statement belongs to a CHANGE TEAM construct, the effect is the same as transferring control to the END TEAM statement"

Ron_Green
Moderador
5.291 Visualizações

I will write up a bug report. 

Ron_Green
Moderador
5.007 Visualizações

Bug ID is CMPLRLLVM-68880


Ron_Green
Moderador
1.338 Visualizações

we have a fix for this bug.  It should make the next Update release.

Responder