Home > Archive > Fortran > January 2008 > gfortran -std=f95 overzealous?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
gfortran -std=f95 overzealous?
|
|
| Al Greynolds 2008-01-21, 7:29 pm |
| I use INDEX and LEN_TRIM in some initialization expressions and
gfortran complains that their use here is an extension to the
Fortran-95 standard. None of my other compilers complain (with f95
compliance ON) . The standard seems to say any intrinsic involving
only integer and/or character types is allowed. Who's right?
Al Greynolds
www.ruda.com
| |
| Craig Dedo 2008-01-21, 7:29 pm |
| "Al Greynolds" <awgreynolds@earthlink.net> wrote in message
news:96886cf3-94c3-40d8-b1b3-09b6221ed781@i7g2000prf.googlegroups.com...
>I use INDEX and LEN_TRIM in some initialization expressions and
> gfortran complains that their use here is an extension to the
> Fortran-95 standard. None of my other compilers complain (with f95
> compliance ON) . The standard seems to say any intrinsic involving
> only integer and/or character types is allowed. Who's right?
>
> Al Greynolds
> www.ruda.com
Your interpretation of what the Fortran 95 standard says is significantly
different from the actual language of that standard, so, strictly speaking,
neither is correct. That said, your position is substantially closer to the
actual language of the standard.
Constant expressions and initialization expressions are defined in section
7.1.6.1 of the Fortran 95 standard. "An initialization expression is a constant
expression in which the exponentiation operation is permitted only with an
integer power, and each primary is ... " in one of 9 categories of thingos. One
of these categories is:
"(4) An elemental intrinsic function reference of type integer or character
where each argument is an initialization expression of type integer or
character;".
The function INDEX is defined in section 13.14.47 and the function LEN_TRIM
is defined in section 13.14.55. Both of these are in the class of elemental
functions. Therefore, both should be allowed in initialization expressions.
You should file a bug report with the developers of gfortran.
--
Craig Dedo
17130 W. Burleigh Place
P. O. Box 423
Brookfield, WI 53008-0423
Voice: (262) 783-5869
Fax: (262) 783-5928
Mobile: (414) 412-5869
E-mail: <cdedo@wi.rr.com> or <craig@ctdedo.com>
| |
| Steven G. Kargl 2008-01-21, 7:29 pm |
| In article <47950ae4$0$2161$4c368faf@roadrunner.com>,
"Craig Dedo" <cdedo@wi.rr.com> writes:
> "Al Greynolds" <awgreynolds@earthlink.net> wrote in message
> news:96886cf3-94c3-40d8-b1b3-09b6221ed781@i7g2000prf.googlegroups.com...
> Your interpretation of what the Fortran 95 standard says is significantly
> different from the actual language of that standard, so, strictly speaking,
> neither is correct. That said, your position is substantially closer to the
> actual language of the standard.
>
> Constant expressions and initialization expressions are defined in section
> 7.1.6.1 of the Fortran 95 standard. "An initialization expression is a constant
> expression in which the exponentiation operation is permitted only with an
> integer power, and each primary is ... " in one of 9 categories of thingos. One
> of these categories is:
> "(4) An elemental intrinsic function reference of type integer or character
> where each argument is an initialization expression of type integer or
> character;".
>
> The function INDEX is defined in section 13.14.47 and the function LEN_TRIM
> is defined in section 13.14.55. Both of these are in the class of elemental
> functions. Therefore, both should be allowed in initialization expressions.
>
> You should file a bug report with the developers of gfortran.
Al didn't post his code, so how can you conclude that gfortran
is incorrect without seeing the arguments to these functions.
You even quote the necessary language "where each argument is an
initialization expression of type integer or character".
In fact, len_trim() at least works as advertised.
troutmask:sgk[209] gfc4x -o z a.f90
troutmask:sgk[210] ./z
16
troutmask:sgk[211] gfc4x -o z -std=f95 a.f90
troutmask:sgk[212] ./z
16
troutmask:sgk[213] cat a.f90
program z
character(len=80), parameter :: name = 'Al has a problem '
integer, parameter :: i = len_trim(name)
print *, i
end program
--
Steve
http://troutmask.apl.washington.edu/~kargl/
| |
| Al Greynolds 2008-01-21, 7:29 pm |
| On Jan 21, 2:38=A0pm, ka...@troutmask.apl.washington.edu (Steven G.
Kargl) wrote:
> In fact, len_trim() at least works as advertised.
>
I should have been more precise in my original post:
I use "index" and "len_trim" in some ARRAY initialization expressions
and
gfortran complains that their use here is an extension to the
Fortran-95 standard. None of my other compilers complain (with f95
compliance ON). The standard seems to say any ELEMENTAL intrinsic
involving
only integer and/or character types is allowed.
Its not a big deal because the code is compiled and executed correctly
by gfortran which just complains (I think we agree erroneously) with -
std=3Df95.
Al
PS. Here's a simple test case to compile with and without -std=3Df95
module bug
character(*),dimension(3),parameter :: a=3D(/'a() ','b(,) ','c(,,)'/)
integer,dimension(3),parameter :: l=3Dlen_trim(a),i=3Dindex(a,'(')
end
| |
| Daniel Franke 2008-01-25, 4:34 am |
| Al Greynolds wrote:
> PS. Here's a simple test case to compile with and without -std=f95
>
> module bug
> character(*),dimension(3),parameter :: a=(/'a() ','b(,) ','c(,,)'/)
> integer,dimension(3),parameter :: l=len_trim(a),i=index(a,'(')
> end
Al, thanks for the report.
This was PR34915 and should now be fixed :)
Regards
Daniel
|
|
|
|
|