I'm learning Fortran and I'd like to encapsulate an array and a subroutine in a type. The problem appears to be in the type definition of the self-object.
This is the minimal test case I came up with:
module testing
implicit none
type test(para)
integer, len :: para
real, dimension(para) :: weights
contains
procedure :: testing => testing_test
end type
contains
subroutine testing_test(self)
class(test(*)) :: self
end subroutine
end module
Compiling this with gfortran raises this error:
module_test.f08:9:23:
procedure :: testing => testing_test
1
Error: Argument ‘self’ of ‘testing_test’ with PASS(self) at (1) must be of the derived-type ‘test’
It works when the array-length is fixed (so type%para
doesn't exist)
Is what I'm trying to do (type with array of variable size and bound procedure) plain impossible or am I missing something regarding dummy argument definition?
gfortran --version
:GNU Fortran (GCC) 8.1.1 20180712 (Red Hat 8.1.1-5)
– Fairfax