module foo
use :: iso_fortran_env
implicit none
type :: bar (p, q)
integer, kind :: p
integer, len :: q
integer(kind = p), dimension(q) :: x
end type bar
contains
subroutine barsub (this)
class(bar(*,*)), intent(in) :: this
write (*,*) this%x
end subroutine barsub
end module foo
此代码不是用gfortran 8或pgfort 18.4编译的。pgi编译器说
非法的选择器种类值必须为非负
假定类型参数(*)不能与非长度类型参数p一起使用
而格佛特兰
在(1)处的种类参数“p”不能被假定或推迟
如果我把上面的代码改成
subroutine barsub (this)
class(bar(INT32,*)), intent(in) :: this
write (*,*) this%x
end subroutine barsub