我正在尝试在子程序中使用带参数派生类型,使用无限多态指针。
是否可以使用“select type”子句来处理参数化类型?
我尝试了以下类似的代码,但是出现了编译错误。(在TYPE附近有语法错误)
module mod_real
implicit none
type :: type1(k)
integer, kind :: k = 4
real(kind=k) :: val
end type type1
contains
subroutine out(in)
class(*) :: in
select type(in)
type is (type1(4))
print *, 'real(4):', in%val
type is (type1(8))
print *, 'real(8):', in%val
end select
end subroutine out
end module mod_real
program real_test
use mod_real
type(type1(4)) :: p
type(type1(8)) :: p2
p%val = 3.14
p2%val = 3.1456d0
call out(p)
call out(p2)
end program real_test
"type is (type1(4))" 和 "type is (type1(8))" 这两行被标为语法错误。我使用的是Portland Group Fortran编译器(版本13.5-0)。