将不同的声明类型传递给绑定过程Fortran

问题描述 投票:0回答:1

给出以下代码

  type t1 
     integer :: dum 
  type(aop), alloctable  :: bc(:) 
  end type t1 

 type aop 
   procedure(A_INT), pass(t1), pointer :: ptr => null()
 end type aop 

 abstract interface 
    subroutine A_INT ( this ) 
            import t1
            class(t1) , intent(in) :: this 
    end subroutine 

 end interface 

有人能解释为什么这是非法的吗?至少编译器说

error #8170: The passed-object dummy argument is missing from the procedure interface.   [A_INT]
            procedure(A_INT), pass(t1),
   -------------------^

更新

当我这样做时

  type t1 
     integer :: dum 
  type(aop), alloctable  :: bc(:) 
  end type t1 

 type aop 
   procedure(A_INT), pass(this), pointer :: ptr => null()
 end type aop 

 abstract interface 
    subroutine A_INT ( this ) 
            import t1
            class(t1) , intent(in) :: this 
    end subroutine 

 end interface 

我得到以下错误

error #8262: For a type-bound procedure that has the PASS binding attribute, the first dummy argument must have the same declared type as the type being defined.   [THIS]
             subroutine A_INT(  this

我想这意味着编译器期望第一个参数是aop类型?是不是有可能让this成为t1型?

class fortran intel-fortran
1个回答
1
投票

你正在使用qazxsw poi,但没有虚拟参数qazxsw poi,只有pass(t1)类型的参数t1

使用单个伪参数,我通常不会在这里使用任何明确的this。传递的伪参数只有在与定义指针的类型相同时才有意义。否则,对于其他类型的参数,只需使用t1

© www.soinside.com 2019 - 2024. All rights reserved.