array constructor syntax

This is a discussion on array constructor syntax within the Fortran forums in Programming Languages category; 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 the syntax right. 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...

Go Back   Application Development Forum > Programming Languages > Fortran

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-01-2008, 03:42 PM
Cornelis
Guest
 
Default array constructor syntax

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
the syntax right.

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
Reply With Quote
  #2  
Old 09-01-2008, 03:53 PM
rusi_pathan
Guest
 
Default Re: array constructor syntax

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
> the syntax right.
>
> 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
Reply With Quote
  #3  
Old 09-01-2008, 04:30 PM
Steven G. Kargl
Guest
 
Default Re: array constructor syntax

In article <d542448a-2ace-49cd-a408-b52a1e91910f@e39g2000hsf.googlegroups.com>,
Cornelis <cwdegier@gmail.com> writes:
> 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
> the syntax right.
>
> 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.


You need gfortran 4.4.0. See the wiki.

--
Steve
http://troutmask.apl.washington.edu/~kargl/
Reply With Quote
  #4  
Old 09-01-2008, 05:27 PM
Richard Maine
Guest
 
Default Re: array constructor syntax

rusi_pathan <tabrezali@gmail.com> wrote:

> 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
Reply With Quote
  #5  
Old 09-02-2008, 02:35 AM
Cornelis
Guest
 
Default Re: array constructor syntax

Thanks, Richard, for your elaborate answer.

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:
> rusi_pathan <tabrez...@gmail.com> wrote:
> > 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


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 03:18 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.