I'm trying to compile the Fortran module below (using gfortran 7.2.0). The point is to define a derived type that in turn contains two instances of the derived type bspline_3d
from the bspline-fortran library (https://github.com/jacobwilliams/bspline-fortran). I then want to define a type-bound procedure that will in turn call the type-bound evaluate
procedure of both of those types, and return the result as an array with two elements.
When I try to compile the module below, I get an error message saying
procedure :: evaluate => evaluate_2d
1
Error: Non-polymorphic passed-object dummy argument of 'evaluate_2d' at (1)
I understand absolutely nothing of the error message.
I managed to compile the simple example program found here: http://fortranwiki.org/fortran/show/Object-oriented+programming and as far as I can tell, the only difference is that in my case, the "passed-object" (this
) does itself have derived-type member variables (type(bspline_3d) :: fvx, fvy
), which in turn probably contain all sorts of stuff.
module interpolator_module
use bspline_module
use parameters, only: WP
implicit none
private
public :: interpolator
type :: interpolator
type(bspline_3d) :: fvx, fvy
contains
private
procedure :: evaluate => evaluate_2d
end type interpolator
contains
function evaluate_2d(this, X, t) result(V)
implicit none
! inputs
type(interpolator), intent(inout) :: this
real(WP), dimension(2), intent(in) :: X
real(WP), intent(in) :: t
! output
real(WP), dimension(2) :: V
! local variables
integer :: iflag
integer, parameter :: d = 0
call this%fvx%evaluate(X(1), X(2), t, d, d, d, V(1), iflag)
call this%fvy%evaluate(X(1), X(2), t, d, d, d, V(2), iflag)
end function
end module interpolator_module