我有一个派生类型:
module foo
type bar
integer, allocatable, dimension(:) :: data
end type bar
end module foo
现在我想bar
在没有显式接口的子例程中分配数据:
program main
use foo
type(bar) :: mybar
call alloc_my_bar(10,mybar)
print*, mybar
end program
subroutine alloc_my_bar(n,mybar)
use foo
type(bar) :: mybar
integer :: n
allocate(mybar%data(n))
mybar%data = 42
end subroutine alloc_my_bar
这似乎与 . 一起工作得很好ifort
,但我知道如果 mybar 不是用户定义类型的一部分,我将需要一个显式接口...... ? 此代码与(F90、F95、F2003 ...)兼容的 fortran 标准的哪个版本(如果有)?