Fortran 77 で、共通ブロック内に割り当て可能な文字を持たせようとしています。しかし、コンパイラは常に文句を言います
Error: COMMON attribute conflicts with ALLOCATABLE attribute at (1)
私が持っていたコードは
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
それを機能させるために私が見た唯一の方法は、使用しないことです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
しかし、事前に文字の長さを知る必要があるため、これは面倒です。
ブロックallocatable
内で動作させるにはどうすればよいですか?common