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

Additional bugs with CHANGE TEAM and BLOCK constructs

OP1
New Contributor III
931 Views

The following code (built with ifx 2025.2.1 on Windows) produces two compile-time errors that I believe are incorrect:

PROGRAM P
USE ISO_FORTRAN_ENV, ONLY : TEAM_TYPE
IMPLICIT NONE (TYPE, EXTERNAL)
TYPE(TEAM_TYPE) ODDEVEN
BLOCK
    CHANGE TEAM (ODDEVEN)
    END TEAM
    EXIT
END BLOCK
B: BLOCK
    CHANGE TEAM (ODDEVEN)
    END TEAM
    EXIT B
END BLOCK B
END PROGRAM P

The error messages are:

error #7974: If no construct name is specified, the EXIT statement must only be used inside a DO construct.

and

error #8940: A branch within a CHANGE TEAM construct must not have a branch target that is outside the construct.   [LB]

Note that the last part of the second error message seems to randomly change from [LB] to [LA] depending on the code.

1 Solution
andrew_4619
Honored Contributor III
888 Views

I think error #7974 is correct the block construct must have a name to be able to use exit. That is true of all named constructs, the anomaly is do loops where no name is needed.

View solution in original post

5 Replies
andrew_4619
Honored Contributor III
889 Views

I think error #7974 is correct the block construct must have a name to be able to use exit. That is true of all named constructs, the anomaly is do loops where no name is needed.

Ron_Green
Moderator
855 Views

@andrew_4619 is correct, the exit is not allowed in this context.  2 other compilers agree:

nagfor:

nagfor -c exit_block.f90 
NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7231
Error: exit_block.f90, line 8: EXIT with no construct-name is not within any DO loop
       detected at EXIT@<end-of-statement>
[NAG Fortran Compiler pass 1 error termination, 1 error]

and gfortran

gfortran exit_block.f90 
exit_block.f90:9:8:

    9 |     EXIT
      |        1
Error: EXIT statement at (1) is not within a construct

   

0 Kudos
Ron_Green
Moderator
849 Views

Interesting.  If we remove the obvious problem with the first exit, and leave this:

$ more exit_block2.f90

PROGRAM P
USE ISO_FORTRAN_ENV, ONLY : TEAM_TYPE
IMPLICIT NONE (TYPE, EXTERNAL)
TYPE(TEAM_TYPE) ODDEVEN
B: BLOCK
    CHANGE TEAM (ODDEVEN)
    END TEAM
    EXIT B
END BLOCK B
END PROGRAM P

 

with this change, nagfor and gfortran will compile this code.  ifx will not:

ifx -c -coarray exit_block2.f90
exit_block2.f90: error #8940: A branch within a CHANGE TEAM construct must not have a branch target that is outside the construct.   [LA]
compilation aborted for exit_block2.f90 (code 1)

 I am not entirely sure on the legality of 'EXIT B' in this context.  I will have to consult the team's Standards reps to see if this is bug.  My initial read on this is that it is legal code.  but the BLOCK context does add a twist to this.  Interesting ....

0 Kudos
OP1
New Contributor III
487 Views

@andrew_4619 good catch! Mea culpa, for the first error the block construct should have a name indeed. But as @Ron_Green noted, the second scenario is definitely a bug. The error message does not make any sense since the EXIT statement is outside the CHANGE TEAM construct.

0 Kudos
Ron_Green
Moderator
32 Views

@OP1 definitely a bug.  I will open a bug report.  

0 Kudos
Reply