Re: bug in g95 with character arrays?



wim wrote:


character(len=5), parameter :: test(5) =
["tan","atan2","atan","sin","asin"]
1
Error: Element in character array constructor at (1) has length 5
instead of 3

Does the standard say anything about what the compiler should do with
the elements in a character array that have a length shorter than the
one defined by its length, or should i always pad string parameters
with spaces by hand?

The F95 standard says that all of the elements in the array constructor have to be of the same length (type and type parameters). F2003 allows them to be different lengths and you can specify the target length with an optional type keyword, such as [character(5)::"tan","atan2","atan","sin","asin"]

Current ifort supports the mixed lengths, padding as needed to the longest length. The type specification is not supported in ifort 10.1.

By the way, the use of square brackets is also not standard in F95, but is in F03. If you want to be F95 standard conforming, pad the values and use (/ /) delimiters.

--

Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH

For email address, replace "invalid" with "com"

User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://support.intel.com/support/performancetools/fortran
My Fortran blog
http://www.intel.com/software/drfortran
.



Relevant Pages

  • Re: String Access
    ... > area needed, allocate a character array of that size, read the data, ... the standard does not guarantee that the string are stored ... You can use a vector of char instead of manually allocated memory. ...
    (comp.lang.cpp)
  • Re: frequency list
    ... An standard long is sizeofbytes in size, whereas an unsigned long, ... What character array? ... Richard Heathfield ... rjh at above domain ...
    (comp.lang.c)
  • Re: upgrading
    ... standard, It has been rewritten in parts to f90 standard. ... If one were to decide to rewrite to f95 standard are there any ... cases, code that is alleged to be f77 code, but has problems with f95, ...
    (comp.lang.fortran)
  • Re: gfortran read of hex values
    ... I couldn't find anything in the standard that said it was ... If the DATA statement part is standard F95, ... the actually wording in the F95 standard, ... The OP wants to initialize a REAL with a BOZ. ...
    (comp.lang.fortran)
  • Re: upgrading
    ... standard, It has been rewritten in parts to f90 standard. ... If one were to decide to rewrite to f95 standard are there any ... I am a FORTRAN n00b and am trying to get a piece of code running. ...
    (comp.lang.fortran)