Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

abstract interface error

clabra
New Contributor I
1,302 Views
Hi,
Someone can explain me what means this error?
test.F90(22): error #8262: The passed-object dummy argument must be dummy data object with the same declared type as the type being defined. [DATA1]
subroutine operation_type( data1, data2, result )
-------------------------------^
My compiler version is:
Intel Fortran Intel 64 Compiler XE for applications running on Intel 64, Version 12.1.3.293
And the code:
module operator_class
type data_type
real, allocatable :: values(:)
integer :: n_values
end type data_type
type operator_type
type(data_type), pointer :: data1 => null()
type(data_type), pointer :: data2 => null()
type(operator_type), pointer :: operator1 => null()
type(operator_type), pointer :: operator2 => null()
procedure(operation_type), pointer :: operation => null()
type(data_type), pointer :: result => null()
end type operator_type
abstract interface
subroutine operation_type( data1, data2, result )
import :: data_type
type(data_type), target, intent(inout) :: data1
type(data_type), target, intent(inout) :: data2
type(data_type), pointer :: result
end subroutine operation_type
end interface
end module operator_class
Thank you!
clabra
0 Kudos
2 Replies
John4
Valued Contributor I
1,302 Views

Procedure pointers, when used as derived type components, are type-bound by default ---i.e., an instance of the derived type is passed as the first argument, and is referred to as the passed-object.

The error is telling you that the first argument in the abstract interface should be of CLASS(operator_type). To override the default behavior, you can use PASS (to confirm or state which argument is the passed-object) or NOPASS (in which case no instance of the derived type is passed).

Although it might not apply in your case, one alternative to procedure pointer components is a deferred type-bound procedure; for that, you must add ABSTRACT to the derived type definition. Unlike the procedure pointer component, a deferred type-bound procedure has the advantage that it cannot be neglected (i.e., whomever uses your derived type, must extend it and override the procedure), so you can actually invoke it from other type-bound procedures of the abstract type. The ABSTRACT attribute is not allowed for recursive derived types, though.

One example:

[fortran]module operator_class type :: data_type real, allocatable :: values(:) integer :: n_values end type data_type type, abstract :: operator_type type(data_type), pointer :: data1 => null() type(data_type), pointer :: data2 => null() type(data_type), pointer :: result => null() contains procedure(operation_type), nopass, deferred :: operation end type abstract interface subroutine operation_type( data1, data2, result ) import type(data_type), target, intent(inout) :: data1 type(data_type), target, intent(inout) :: data2 type(data_type), pointer :: result end subroutine end interface end module operator_class module operator_class_implementation use operator_class type, extends(operator_type) :: operator_type_impl type(operator_type_impl), pointer :: operator1 => null() type(operator_type_impl), pointer :: operator2 => null() contains procedure, nopass :: operation end type contains subroutine operation( data1, data2, result ) type(data_type), target, intent(inout) :: data1 type(data_type), target, intent(inout) :: data2 type(data_type), pointer :: result !... end subroutine end module operator_class_implementation[/fortran]

0 Kudos
clabra
New Contributor I
1,302 Views
Thank you John.
Adding "nopass" to the procedure pointer component in operator_type the code compile (and the complete version run).
The "operation" procedure component should be a pointer, in order to select different operation types.
0 Kudos
Reply