REAL, implied-do-loop, and initialization expression?

Steve Kargl sgk@troutmask.apl.washington.edu
Thu Jun 25 21:12:00 GMT 2015


Anyone see anything wrong with this code

program foo
  implicit none
  integer i
  integer, parameter :: n = 4
  integer, parameter :: k(n) = [4, 8, 10, 16]
  print *, (real(1,k(i)), i=1, n)
end program foo

Shouldn't the implied-do-loop expand to

  print *, real(1,k(1)), real(1,k(2)), real(1,k(3)), real(1,k(4))

gfortran 5 and 6 give 

troutmask:sgk[265] gfc6 g.f90
g.f90:6:19:

   print *, (real(1,k(i)), i=1, n)
                   1
Error: Invalid kind (0) for REAL at (1)

-- 
Steve



More information about the Fortran mailing list