module array_constructor
implicit none
character(len=14), dimension(5), parameter :: &
var_names = [character(len=14) :: &
'YEAR', 'COMPCODE', 'RECEPTYPE', 'NCOLS', 'NROWS']
end module array_constructor
If the syntax is right, I would like to know if there are other
compilers available for x86 under Linux that accept this Fortran 2003
array constructor, since I don't like to be dependent on just one
compiler.
Thanks,
Cornelis
module array_constructor
implicit none
character(len=14), dimension(5), parameter :: var_names &
& = ['YEAR', 'COMPCODE', 'RECEPTYPE', 'NCOLS', 'NROWS']
end module
works on Intel 10.1 and gfortran 4.2.1
You need gfortran 4.4.0. See the wiki.
> On Sep 1, 3:42 pm, Cornelis <cwdeg...@gmail.com> wrote:
> > Since the following code is only accepted by g95 and not by
> > gfortran-4.2.3 or the intel compiler 10.1, I was wondering if I got
...
> > character(len=14), dimension(5), parameter :: &
> > var_names = [character(len=14) :: &
> > 'YEAR', 'COMPCODE', 'RECEPTYPE', 'NCOLS', 'NROWS']
Yes, that looks fine. As you correctly note, it is an f2003 form. I'm
sure the other compilers wil get there eventually, but I can't give you
a timeline.
> character(len=14), dimension(5), parameter :: var_names &
> & = ['YEAR', 'COMPCODE', 'RECEPTYPE', 'NCOLS', 'NROWS']
>
> works on Intel 10.1 and gfortran 4.2.1
That, on the other hand, is *NOT* valid in any version of the standard.
Just because some compilers accept it doesn't mean it is valid.
Might I ask whether those compilers at least give a warning for the
nonstandard form when you ask for warnings about standard violation? If
they don't, I'd suggest filing a bug report. While it isn't one of the
particular warnings required by the standard, and thus not strictly a
"bug" in terms of standard compliance, I'd consider it a "bug" in
quality of implementation to fail to give such a warning.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
Both gfortran-4.2 and ifort 10.1 accept rusi's code by default, but
they don't accept it when issued with an option to confirm to the
f2003 standard, -std=f2003 and -e03 respectively.
Steven, thanks: gfortran-4.4 accepts the orginal code and rejects
rusi's code by default.
Cornelis
On Sep 1, 11:27 pm, nos...@see.signature (Richard Maine) wrote: