I have a question regarding utilization of allocatable array of allocatable characters.
character(:), allocatable :: lines(:)
wrapped inside a class: like:
type, public :: t_c
character(:), allocatable :: line
character(:), allocatable :: lines(:)
end type t_c
type(t_c) :: t
Basically t%lines(:) does not work. I tried with pgf90. v.19+
The test code is shown below:
The sample code shown bellow does not work for
wrapped within t_c character(:), allocatable :: lines(:)
Is this a bug?
module m_c
type, public :: t_c
character(:), allocatable :: line
character(:), allocatable :: lines(:)
end type t_c
end module m_c
program main
use m_c
implicit none
type(t_c) t
character(:),allocatable :: line, lines(:)
integer i
t%line = 'a test for t%line ’
line=’ 1: line 1 ; this is the line number 1 ; and so on ’
allocate(character(len=len(line))::lines(3))
lines(1) = line
lines(2) = ’ intra-group overwrite’
lines(3) = ’ modify gauss ’
!t%lines = lines ! try 1 : not working
!allocate(t%lines , source = lines) ! try 2 ; not working
allocate(character(len(line))::t%lines(3))
! note printing len(t%lines(1)) gives 2
do i =1,3; t%lines(i)=lines(i); enddo ! stiill not workin
t%line = ’ a single line may be ok 111111111111111222222333’
do i = 1,3
print*,len(lines(i)),len(t%lines(i)),‘t_c ="’,t%lines(i),‘"’
enddo
print*,len(line), ‘t%line=’,t%line
end program main