|
Prev: TRANSFER on LOGICALs (was: Several questions about character C binding)
Next: Is there a way to construct a generic "list" by Fortran 95?
From: Al Greynolds on 21 Jan 2008 15:06 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
From: Craig Dedo on 21 Jan 2008 16:13 "Al Greynolds" <awgreynolds(a)earthlink.net> wrote in message news:96886cf3-94c3-40d8-b1b3-09b6221ed781(a)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(a)wi.rr.com> or <craig(a)ctdedo.com>
From: Steven G. Kargl on 21 Jan 2008 16:38 In article <47950ae4$0$2161$4c368faf(a)roadrunner.com>, "Craig Dedo" <cdedo(a)wi.rr.com> writes: > "Al Greynolds" <awgreynolds(a)earthlink.net> wrote in message > news:96886cf3-94c3-40d8-b1b3-09b6221ed781(a)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? >> > 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/
From: Al Greynolds on 21 Jan 2008 18:29 On Jan 21, 2:38 pm, ka...(a)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=f95. Al 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
From: Daniel Franke on 25 Jan 2008 04:31
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 |