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

Is StopPoint a reserved keyword?

cean
New Contributor II
789 Views

Hi,

 

This is talked at here Trying to rebuild application with .bat files - Intel Community

To make it simple, I made this small program:

 

 

      !e5082.for
      INTEGER STOPPOINT
      DIMENSION STOPPOINT(:,:,:)
      ALLOCATABLE :: STOPPOINT
      integer ALLOERR
      integer I
      ALLOCATE (STOPPOINT(1:4,1:3,0:5),STAT=ALLOERR)
      I=1
      STOPPOINT(1:4,1:3,0:I)=0
      
      end

 

 

Compile it gives an error:

 

 

D:\r>ifort -c e5082.for
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.1 Build 20201112_000000
Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.

e5082.for(8): error #5082: Syntax error, found '=' when expecting one of: :: ) , : * <END-OF-STATEMENT> ; . % (/ + - ] /) . ' ** / // > ...
      STOPPOINT(1:4,1:3,0:I)=0
----------------------------^
e5082.for(8): error #6911: The syntax of this substring is invalid.   [POINT]
      STOPPOINT(1:4,1:3,0:I)=0
----------^
compilation aborted for e5082.for (code 1)

 

 

But if I change the variable name from StopPoint to STONT, the compiler then has no complaint.

 

 

      INTEGER STONT
      DIMENSION STONT(:,:,:)
      ALLOCATABLE :: STONT
      integer ALLOERR
      integer I
      ALLOCATE (STONT(1:4,1:3,0:5),STAT=ALLOERR)
      I=1
      STONT(1:4,1:3,0:I)=0
      
      end

 

The problem seems that you can not use STOP to start a variable name. STOPa has the same error.

Cheers,

Cean

0 Kudos
4 Replies
GVautier
New Contributor II
761 Views

Hi

STOP is a statement so the compiler complains from POINT

Syntax of STOP statement

STOP [string]

In Fortran there is no reserved word but the syntax implies the meaning so a line beginning by STOP is a STOP statement.

Another exemple

DO I=1.2

is legal (affecting 1.2 to DOI variable because spaces are ignored)

DO I=1,2

is a loop statement

 

0 Kudos
Steve_Lionel
Honored Contributor III
735 Views

I do not agree that this is a fixed vs. free form issue. Indeed, I wrote about this topic in Doctor Fortran in "No Reserve" - Doctor Fortran (stevelionel.com)

The compiler has ways of disambiguating statements that start with a statement keyword but aren't those statements. In this case, the appearance of the equal sign or parenthesis is a clue that this is NOT a STOP statement. (I spent a lot of time in the VAX FORTRAN statement classifier code.)

My guess is that when Intel implemented the Fortran 2018 enhancements to STOP to add the optional ", QUIET=expression", the programmer was not careful enough. This is a compiler bug.

That said, fixed form should be avoided on general principles in new code.

0 Kudos
andrew_4619
Honored Contributor II
723 Views

To be clear the error only occurs in fixed form is compiles OK in freeform. It seems the Fortran parser is getting confused.

0 Kudos
Arjen_Markus
Honored Contributor I
754 Views

To emphasize: This is the case with fixed form! In fixed form spaces (except in strings) are irrelevant. So, as GVautier indicates, the compiler recognizes the word STOPPOINT as a statement "STOP POINT".

One solution: use free form

 

 

0 Kudos
Reply