- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a problem about Type-Bound-Procedure, can you help me? Thanks a lot.
Win7 (64-bit) + Visual Studio 2008 + Intel fortran 11.1.067
---- source code ------
Module GenericIntrinsicFunction
implicit none
type, public:: Rational
integer:: Num ! numerator
integer:: Den ! Denominator
contains
! The passed-object dummy argument must be a polymorphic
! dummy data object if the type being defined is extensible. [RAT_IN]
procedure:: abs => RationalAbs ! error
end type
interface Abs
module procedure RationalAbs
end interface
contains
function RationalAbs(Rat_in) result(Rat_out)
implicit none
type(Rational), intent(in):: Rat_in
type(Rational):: Rat_out
integer, intrinsic:: abs
Rat_out % Num = abs(Rat_in % Num)
Rat_out % Den = abs(Rat_in % Den)
return
end function
End Module
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi asymptotic,
as the error message says, the passed object dummy argument must be polymorphic, i.e. you have to use CLASS(Rational) instead of TYPE(Rational) in your function definition for the Rat_in argument.
Your function header should look like this:
function RationalAbs(Rat_in) result(Rat_out)
implicit none
class(Rational), intent(in):: Rat_in
type(Rational):: Rat_out
best regards,
Thomas

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page