Type specification and initialization expressions



Hello,

Is the following code valid or not?

implicit none
REAL(kind(0.0d0)), dimension(kind(xyz)) :: xyz
REAL, PARAMETER :: xxx(kind(xxx)) = 1.0

This is accepted by NAG f95 and gfortran (and both have then size(xyz)
== kind(0d0)), but it is unclear for me whether this is valid.

For the following I am rather sure that it is valid:
REAL, DIMENSION(2,2), PARAMETER :: xyz2 = RESHAPE((/ 1,2,3,4 /),
SHAPE(xyz2))
REAL, PARAMETER :: yyy = kind(yyy)

while the following should be invalid:
REAL(8), PARAMETER :: zzz(size(zzz)) = 1 ! Obviously - which
dimension one should get?
real, parameter :: z = transfer(1234, z)

My starting point was "7.1.7 Initialization expression" (esp. last
paragraph).

Tobias
.



Relevant Pages

  • automatic arrays with negative size in g95 and gfortran
    ... implicit none ... For iiequaling -1, gfortran crashes. ... If g95 does, I would prefer that gfortran emulate it in this case. ... which works for both compilers. ...
    (comp.lang.fortran)
  • Re: warn about implicit SAVE?
    ... example demonstrates the implicit SAVE feature. ... end subroutine print_range ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: Trying to use a logical as an array index
    ... implicit none ... To work around gfortran bug ... readgarbage ... echo Binary Output Input Result Test ...
    (comp.lang.fortran)
  • fortran 90/95 standart
    ... IMPLICIT REAL ... COMMON /use1/ mx,my,nd ... This occur with gfortran but not with intel compiler nor IBM xlf compiler. ...
    (comp.lang.fortran)
  • Re: Examples of FORALL and nested FORALL
    ... My a bit older gfortran 4.1 and today's gfortran 4.2 gives the same ... reference to non-PURE function 'i' at inside a FORALL block ... NAG f95 rejects it with: ...
    (comp.lang.fortran)