- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
[bash]! 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.
[/bash]
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?.
[fortran]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[/fortran]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. What is the expcted relase date for the next update ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you mean the update that includes the fix for this, I believe it is currently scheduled for sometime in October.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page