The code below compiles but produces incorrect results. The output produced is:
sz = 4
Length of string: 1
Size of string: 4
sz = 4
Length of string: 1
Size of string: 0
All results should have a value of 4. So the lines that print either 1 or 0 are incorrect.
pgfortran 14.10-0 64-bit target on Apple OS/X -tp sandybridge
!===============================================================================
module m
type ctype(sz)
integer, len :: sz = 8
character(len=sz) :: label(sz)
end type
end module
!===============================================================================
program test
use m
implicit none
integer :: i
type(ctype(:)), allocatable :: c1,c2
i = 4
allocate(ctype(4)::c1)
allocate(ctype(i)::c2)
print *, "sz = ",c1%sz
print *, "Length of string: ",LEN(c1%label)
print *, "Size of string: ",SIZE(c1%label)
print *, "sz = ",c2%sz
print *, "Length of string: ",LEN(c2%label)
print *, "Size of string: ",SIZE(c2%label)
end
!===============================================================================