Quantcast
Viewing all articles
Browse latest Browse all 3270

procedure pointer to type bound procedure

Hi all

the following construct:

Module ModTestParent
Implicit None
Type :: TestParent
Integer :: i
Procedure(suba), Pointer :: pt => Null()
contains
Procedure, Pass, Public :: a => suba
Procedure, Pass, Pbulic :: b => subb
End Type
Private :: suba, subb
contains
Subroutine suba(this,i)
Implicit None
Class(TestParent), Intent(InOut) :: this
Integer, Intent(In) :: i
this%i=this%i+i
End suba
Subroutine subb(this,i)
Implicit None
Class(TestParent), Intent(InOut) :: this
Integer, Intent(In) :: i
this%i=this%i-i
End subb
End Module
Module ModTestChild
use ModTestParent
Implicit None
Type, extends(TestParent) :: TestChild
Integer :: j
contains
Procedure, Pass :: SetPointer => SubSetPointer
End Type
Private :: SubSetPointer
contains
Subroutine SubSetPointer(this,which)
Implicit None
Class(TesChild), Intent(InOut) :: this
Character(len=*), Intent(In) :: which
Select Case(Trim(AdjustL(which))
Case("add")
this%pt => this%a
Case("substract")
this%pt=>this%b
End SubSetPointer
End Module ModTestChild

this won't compile with the error message: "The procedure target must be a procedure or a procedure pointer."


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>