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

Reals in array constructors in initialization expressions

IanH
Honored Contributor III
880 Views
This little snippet:

[fortran]PROGRAM RealParametersLeftOutInTheCold
  IMPLICIT NONE
  REAL, PARAMETER :: my_list_of_useful_numbers(1) = [ 4 * ATAN(1.0) ]
  !****
  PRINT *, my_list_of_useful_numbers
END PROGRAM RealParametersLeftOutInTheCold
[/fortran]
causes 12.0.4 with relevant options to whine:

[plain]>ifort /check:all /warn:all /stand:f03 RealParametersLeftOutInTheCold.f90
Intel Visual Fortran Compiler XE for applications running on IA-32, Version 12.0.4.196 Build 20110427
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

RealParametersLeftOutInTheCold.f90(3): warning #6009: Fortran 2003 specifies th
at an elemental intrinsic function here be of type integer or character and each
 argument must be an initialization expr of type integer or character .   [ATAN]

  REAL, PARAMETER :: my_list_of_useful_numbers(1) = [ 4 * ATAN(1.0) ]
----------------------------------------------------------^
...[/plain]
but I don't think Fortran 2003 specifies any such thing.
0 Kudos
5 Replies
mecej4
Honored Contributor III
880 Views
This appears to be a Fortran 2003 feature that is only partially implemented.

The IFort-12 documentation (search for "constant expression" and choose the first find, "initialization expressions") lists the restriction that terms in the initialization expression be integers, characters, and intrinsic functions returning these types of constants.
0 Kudos
Steven_L_Intel1
Employee
880 Views
I had thought that ATAN was already supported there, but I will check.

The standards errors can sometimes be misleading - there is a check for non-standard features, and then it uses the "level" you specified in the option in the message. If the check has not been updated to reflect the current standard, it can give results such as this.
0 Kudos
IanH
Honored Contributor III
880 Views
The compiler support for real's in constant-expressions seems ok - it is just the warning that is faulty.
0 Kudos
jimdempseyatthecove
Honored Contributor III
880 Views

Sorry I cannot try this here (yet)

PROGRAM
RealParametersLeftOutInTheCold
USE IFPORT

IMPLICITNONE

REAL,PARAMETER::my_list_of_useful_numbers(1)=[4.0*ATAN(1.0)]

Or
PROGRAMRealParametersLeftOutInTheCold
USE IFPORT

IMPLICITNONE

REAL,PARAMETER::atan_one=ATAN(1.0)

REAL,PARAMETER::my_list_of_useful_numbers(1)=[4.0*atan_one]


Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
880 Views
The only problem here is the faulty standards warning. The compiler still accepts the expression.
0 Kudos
Reply