On 7/6/2019 2:27 PM, ygal klein wrote:
> Hi,
> Is the following way to assign values to an array using brackets as array constructors against the standard?
>
> The following code is compiled successfully using intel compiler 2019 but gfortran 9.1 results with a compilation error stating that there is a 'syntax error in array constructor'.
>
D:\Projects>ifort /stand t.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on
Intel(R) 64, Version 19.0.4.245 Build 20190417
Copyright (C) 1985-2019 Intel Corporation. All rights reserved.
t.f90(5): warning #7120: The lo:high[:stride] array constructor syntax
is not standard Fortran 2008.
a(:) = [1:length]
^
As noted, this is an extension. I don't know if it was from an earlier
standards draft or a local invention. (If the latter, my guess is that
it was done by Compass, whose F90 front-end was acquired by DEC and
adapted for DEC Fortran 90.) It is described (as an extension) in the
Intel documentation section on array constructors.
A suggestion - if in the future you are uncertain that a particular
usage is valid, even though a compiler accepts it, try turning on
standards checking and see what it says.
By the way, the code you posted wouldn't compile with Intel either as
you omitted the initializer for *length*.
--
Steve Lionel
Retired Intel Fortran developer/support
Email: firstname at firstnamelastname dot com
Twitter: @DoctorFortran
LinkedIn:
https://www.linkedin.com/in/stevelionel
Blog:
http://intel.com/software/DrFortran