I am trying to have an allocatable character inside a common block, in Fortran 77. But the compiler always complains
Error: COMMON attribute conflicts with ALLOCATABLE attribute at (1)
The code I had is
subroutine word()
character (len = :), allocatable :: a
common /a/ a
a = 'word'
end subroutine word
program main
character (len = :), allocatable :: a
common /a/ a
call word()
print *, a
end program main
The only way that I saw to make it work is not to use allocatable
subroutine word()
character * 4 :: a
common /a/ a
a = 'word'
end subroutine word
program main
character * 4 :: a
common /a/ a
call word()
print *, a
end program main
But this would be cumbersome because I would have to know the length of a character in advance.
How could I make allocatable
to work in a common
block?