- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This program:
Program testArrayCon implicit none real(8), dimension(2):: t1, t2 parameter t1 = (/1.0, 2.0/) parameter t2 = [3.0, 4.0] end program testArrayCon
produces the following syntax error associated with the assignment of t2:
error #5082: Syntax error, found '.' when expecting one of: .EQV. .NEQV. .XOR. .OR. .AND. .LT. < .LE. <= .EQ. == .NE. /= .GT. > ...
I don't see why I can't use the [ ] array constructor in the parameter statement. In a type declaration, they are fine:
Program testArrayCon implicit none real(8), dimension(2), parameter:: t1 = [1.0, 2.0] real(8), dimension(2), parameter:: t2 = [3.0, 4.0] end program testArrayCon
I'm using Update 3 of Intel Fortran 2018 cluster studio (which is the latest version).
Cheers, joe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please look up the syntax for specifying initial values in a PARAMETER statement in section 5.2.9 of the Fortran 2003 standard. You need to enclose the list of initialized variables and expressions in a pair of parentheses:
parameter (t1 = (/1.0, 2.0/), t2 = [3.0, 4.0])
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please look up the syntax for specifying initial values in a PARAMETER statement in section 5.2.9 of the Fortran 2003 standard. You need to enclose the list of initialized variables and expressions in a pair of parentheses:
parameter (t1 = (/1.0, 2.0/), t2 = [3.0, 4.0])
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! I had tried using ( ) as specified, but it generated errors (but they may have been caused by something else). I have some other code where I did not use ( ) in the PARAMETER statement, and no errors were produced. Likewise, this compiles fine,
parameter t1 = (/1.0, 2.0/)
However, you are correct, that adding the ( ) does solve the problem when using [] array specifiers. I suppose the above should also generate a syntax error, but it doesn't, which was the confusing bit.
Thanks for your help!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The PARAMETER declaration without parentheses was an extension created by DEC, and is not part of standard Fortran. Intel Fortran supports many DEC extensions by default, and you have to specify /standard-semantics to have the compiler flag non-standard extensions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm amused that (//) works and [] doesn't, but I can guess why. I'll comment that the non-standard PARAMETER syntax (it was in a draft F77 standard but then got changed) has somewhat different semantics than the standard version, and I don't recommend using it unless you need those exact semantics.
In my opinion, both constructor syntaxes should be accepted - please report this bug to Intel using https://supporttickets.intel.com/?lang=en-US
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page