I have one question and one problem (I think they are related).
Question: Can I use in Fortran 90 array of pointer arrays defined as pointer?
type string
character, pointer :: str(:)
end type
type(string), pointer :: arr(:)
Problem: I have code (see below) for which ifort 11.1 gives segfault in the last write. Other compilers, such as gfortran 4.6.3, ifort 11.1.072, 12.0.1, ..., worked without a problem
You can think about the code as simulation of Python append function.
program test
implicit none
type string
integer, pointer :: key
character, pointer :: str(:)
end type
type(string), pointer :: arr(:), tmp(:)
allocate(arr(1))
allocate(arr(1)%str(1))
arr(1)%str(1) = 'A'
write(6,*) arr(1)%str(1)
! --------------------
tmp => arr
write(6,*) tmp(1)%str(1)
! --------------------
nullify(arr)
allocate(arr(2))
arr(1)%str => tmp(1)%str
write(6,*) arr(1)%str(1)
end program
Expected result is:
A
A
A
ifort 11.1 gives segmentation fault on the last line. Now comes the weird thing. If you comment out declaration of integer in type string you will get the expected result also with ifort 11.1.
Is this compiler problem or am I using non-standard Fortran 90 structures?
11.1.072but not with an earlier build of11.1.