"kargl" wrote in message news:mmhqvd$j8u$1...@dont-email.me...
> Steve Lionel wrote:
> >One of the rules for primaries in initialization/constant expressions is:
> > (10) An ac-do-variable within an array constructor where each
> > scalar-int-expr of the corresponding ac-implied-do-control is an
> > initialization expression,
> > The (i) qualifies here. I'll file an ifort bug report.
> Yep, gfortran has the same issue.
This possibility goes back at least to f95, so I composed an example
that should be at least close to f95-compliant. It has always seemed
to me that adding generic resolution to the mix might also make
life more difficult for the compiler:
D:\gfortran\clf\test_IEEE>type test_f95.f90
module mykinds
implicit none
integer, parameter :: k1 = selected_real_kind(6)
integer, parameter :: k2 = selected_real_kind(15)
integer, parameter :: k3 = selected_real_kind(33)
integer, parameter :: rk(3) = (/k1,k2,k3/)
end module mykinds
module BCE
implicit none
interface real2string
module procedure real2string1,real2string2,real2string3
end interface
contains
function real2string1(x)
use mykinds, only: wp => k1
implicit none
real(wp), intent(in) :: x
character(len=real2stringlen1(x)) real2string1
character(len=100) temp
write(temp,*) x
real2string1 = adjustl(temp)
end function real2string1
pure function real2stringlen1(x)
use mykinds, only: wp => k1
implicit none
integer real2stringlen1
character(len=100) temp
real(wp), intent(in) :: x
write(temp,*) x
real2stringlen1 = len_trim(adjustl(temp))
end function real2stringlen1
function real2string2(x)
use mykinds, only: wp => k2
implicit none
real(wp), intent(in) :: x
character(len=real2stringlen2(x)) real2string2
character(len=100) temp
write(temp,*) x
real2string2 = adjustl(temp)
end function real2string2
pure function real2stringlen2(x)
use mykinds, only: wp => k2
implicit none
integer real2stringlen2
character(len=100) temp
real(wp), intent(in) :: x
write(temp,*) x
real2stringlen2 = len_trim(adjustl(temp))
end function real2stringlen2
function real2string3(x)
use mykinds, only: wp => k3
implicit none
real(wp), intent(in) :: x
character(len=real2stringlen3(x)) real2string3
character(len=100) temp
write(temp,*) x
real2string3 = adjustl(temp)
end function real2string3
pure function real2stringlen3(x)
use mykinds, only: wp => k3
implicit none
integer real2stringlen3
character(len=100) temp
real(wp), intent(in) :: x
write(temp,*) x
real2stringlen3 = len_trim(adjustl(temp))
end function real2stringlen3
end module BCE
program test
use mykinds
use BCE
implicit none
type t
character(len=100) string
end type t
type(t) capture(size(rk))
integer i
! capture(1) = t(real2string(4*atan(real(1,rk(1)))))
! capture(2) = t(real2string(4*atan(real(1,rk(2)))))
! capture(3) = t(real2string(4*atan(real(1,rk(3)))))
capture = (/(t(real2string(4*atan(real(1,rk(i))))),i=1,size(rk))/)
write(*,'(a)') (trim(capture(i)%string),i=1,size(rk))
end program test
D:\gfortran\clf\test_IEEE>gfortran test_f95.f90 -otest_f95
test_f95.f90:90.44:
capture = (/(t(real2string(4*atan(real(1,rk(i))))),i=1,size(rk))/)
1
Error: Invalid kind for REAL at (1)
D:\gfortran\clf\test_IEEE>ifort /nologo test_f95.f90
test_f95.f90(90): error #6683: A kind type parameter must be a compile-time
cons
tant. [RK]
capture = (/(t(real2string(4*atan(real(1,rk(i))))),i=1,size(rk))/)
--------------------------------------------^
compilation aborted for test_f95.f90 (code 1)