【发布时间】:2014-12-17 13:27:10
【问题描述】:
我有两个例程,一个调用另一个根据类型选择的例程。matc_a 调用takano。当我从matc_a 拨打takano 时,我需要
所以把对takano 的调用封装在Select Type 中,或者我可以直接调用
如下
Case ("takano")
Call takano (a)
有两个套路
Subroutine takano &
( &
a &
)
Class (*), Intent (out) :: a
Select Type (a)
Type Is (Real (Real32))
a = atan ( Real(1,Real32) / Real(49,Real32) )
Type Is (Real (Real64))
a = atan ( Real(1,Real64) / Real(49,Real64) )
Type Is (Real (Real128))
a = atan ( Real(1,Real128) / Real(49,Real128) )
End Select
End Subroutine takano
Subroutine matc_a &
( &
a, strategy &
)
Class (*), Intent (out) :: a
Character (len=*) :: strategy
Select Case (Trim (strategy))
Case ("takano")
Select Type (a)
Type Is (Real (Real32))
Call takano (a)
Type Is (Real (Real64))
Call takano (a)
Type Is (Real (Real128))
Call takano (a)
End Select
End Select
End Subroutine matc_a
【问题讨论】:
标签: fortran polymorphism