Wrong length of a character array component after allocation
问题 I would like to create a derived type containing allocatable character array components. However, when I try to allocate memory in subroutines, nothing happens. It may be more clear with the code example below: program test type t1 character(len=:), allocatable :: c(:) end type t1 type(t1) :: t call test_string1() call test_string2(t) contains subroutine test_string1() character(len=:), allocatable :: c(:) allocate( character(10) :: c(1) ) write(*, *) 'Size in string1: ', len(c) end