[ifort v12.0]error #8314:If the rightmost part-name is of abstract type, data-ref sha ll be polymorphic

[ifort v12.0]error #8314:If the rightmost part-name is of abstract type, data-ref sha ll be polymorphic

Can some one help me fix the error with this code. I have seen this error in a couple of other threads but they were for earliler compilers verions. I have tried compiling the code using ifort v12.0.

! Code Source : http://portal.acm.org/citation.cfm?id=1644004&picked=formats&CFID=111758759&CFTOKEN=88505529
! Paper Title : Design patterns for multiphysics modeling in Fortran 2003 and C++
! Journal     : ACM TOMS, Volume 37 Issue 1, January 2010
module integrable_model_module
 implicit none ! Prevent implicit typing
 private ! Hide everything by default
 public :: integrate ! expose time integration procedure

! This stateless type specifies the operators required to support Runge-Kutta time integration,
! while deferring the actual implementation of those operators to extensions (children) of this type.
 type , abstract ,public :: integrable_model
  contains
  procedure(time_derivative ) ,deferred :: d_dt ! time derivative
  procedure( symmetric_operator ) ,deferred :: add ! add two integrable_model objects
  procedure( symmetric_assignment) ,deferred :: assign ! assign one integrable_model to another
  procedure(asymmetric_operator ) ,deferred :: multiply ! multiply an integrable_model by a real scalar
  generic :: operator(+) => add
  generic :: operator(*) => multiply
  generic :: assignment(=) => assign
 end type integrable_model

 abstract interface

  function time_derivative(this) result(dState_dt)
   import :: integrable_model
   class(integrable_model) ,intent(in) :: this
   class(integrable_model) ,allocatable :: dState_dt
  end function time_derivative

  function symmetric_operator(lhs,rhs) result(operator_result)
   import :: integrable_model
   class(integrable_model) ,intent(in) :: lhs,rhs
   class(integrable_model) ,allocatable :: operator_result
  end function symmetric_operator

  function asymmetric_operator(lhs,rhs) result(operator_result)
   import :: integrable_model
   class(integrable_model) ,intent(in) :: lhs
   class(integrable_model) ,allocatable :: operator_result
   real ,intent(in) :: rhs
  end function asymmetric_operator

  subroutine symmetric_assignment(lhs,rhs)
   import :: integrable_model
   class(integrable_model) ,intent(in) :: rhs
   class(integrable_model) ,intent(inout) :: lhs
  end subroutine symmetric_assignment

 end interface

 contains

  subroutine integrate(model,dt) ! Explicit Euler time integration
   class(integrable_model) :: model
   real ,intent(in) :: dt ! time step size (integration interval)
   model = model + d_dt(model)*dt ! Explicit Euler formula
   contains
    function d_dt(this) result(dThis_dt) ! support d_dt(arg) time differentiation syntax
     class(integrable_model) ,intent(in) :: this
     class(integrable_model) ,allocatable :: dThis_dt
     allocate(dThis_dt,source=this)
     dThis_dt = this%d_dt()
    end function
  end subroutine

end module integrable_model_module
! Command used for compilation

! ifort -c integrable_model.F90

!--Error Mesage on compilation

!error #8314: If the rightmost part-name is of abstract type, dat
!a-ref shall be polymorphic   [D_DT]
!     dThis_dt = this%d_dt()
!---------------------^
!compilation aborted for integrable_model.F90 (code 1)

!--Compiler Info
! ifort (IFORT) 12.0.0 20101006
! Copyright (C) 1985-2010 Intel Corporation.  All rights reserved.
6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

integrable_model is an abstract type. The language doesn't allow you to use such types directly - you can only extend them. This particular usage, where you try to call a type-bound procedure of an abstract type, has been discussed among the Fortran standards committee and they agreed that such a use was not legal.

Steve - Intel Developer Support

I Have simplified the code and implemented another module, in which the abstract type is extended. I am not sure if i did this correctly. I still got that error message. Can you please check this?.

module integrable_model_module
 implicit none ! Prevent implicit typing

 type , abstract ,public :: integrable_model
  contains
  procedure(time_derivative ) ,deferred :: d_dt ! time derivative
  procedure( symmetric_assignment) ,deferred :: assign ! assign one integrable_model to another

  generic :: assignment(=) => assign
 end type integrable_model

 abstract interface

  function time_derivative(this) result(dState_dt)
   import :: integrable_model
   class(integrable_model) ,intent(in) :: this
   class(integrable_model) ,allocatable :: dState_dt
  end function time_derivative

  subroutine symmetric_assignment(lhs,rhs)
   import :: integrable_model
   class(integrable_model) ,intent(in) :: rhs
   class(integrable_model) ,intent(inout) :: lhs
  end subroutine symmetric_assignment

 end interface


end module integrable_model_module

module integrable_model_extended_module
 use integrable_model_module
 implicit none ! Prevent implicit typing
! private ! Hide everything by default
! public :: integrate ! expose time integration procedure

type , extends(integrable_model) ,public :: integrable_model_extended
  contains
  procedure :: d_dt=>time_derivative_ex ! time derivative
  procedure :: assign=>symmetric_assignment_ex ! assign one integrable_model to another

 end type integrable_model_extended

  contains

 ! there will be a warning, ignore it
  function time_derivative_ex(this) result(dState_dt)

   class(integrable_model_extended) ,intent(in) :: this
   class(integrable_model) ,allocatable :: dState_dt
  end function time_derivative_ex


  subroutine symmetric_assignment_ex(lhs,rhs)

   class(integrable_model) ,intent(in) :: rhs
   class(integrable_model_extended) ,intent(inout) :: lhs
  end subroutine symmetric_assignment_ex



  subroutine integrate(model,dt) ! Explicit Euler time integration
   class(integrable_model_extended) :: model
   real ,intent(in) :: dt ! time step size (integration interval)
   model =  d_dt(model) ! Explicit Euler formula
   contains
    function d_dt(this) result(dThis_dt) ! support d_dt(arg) time differentiation syntax
     class(integrable_model_extended) ,intent(in) :: this
     class(integrable_model) ,allocatable :: dThis_dt
     allocate(dThis_dt,source=this)
     dThis_dt = this%d_dt()
    end function

  end subroutine

end module integrable_model_extended_module

A follow-up to this - after more research and discussion, we decided that this usage is legal and the compiler will be fixed in an update later this year.

Steve - Intel Developer Support

Thank you. What is the expcted relase date for the next update ?

If you mean the update that includes the fix for this, I believe it is currently scheduled for sometime in October.

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today