parameterised procedure in derived types

37 views Asked by At

I am trying to write a small module that makes derived type vector, however, when I compile with gcc10.1 I get an error

overload1.f95:10:14:

   10 |      procedure :: ciao
      |              1
Error: Argument â of â with PASS(sh) at (1) must be of the derived-type â
overload1.f95:30:5:

Looking in internet I found no explicit example of using parameterised types in type-bind procedure. Anybody has a clue on where is the error? (below the small code)

module mat
implicit none

type  vector(k, ndim)
 integer, kind :: k=KIND(4)
 integer, len  :: ndim
 real(kind = k), dimension(ndim) :: v
contains
 procedure :: ciao
end type vector

contains

subroutine ciao(sh,a)
class (vector(KIND(4),ndim)) :: sh
real(kind=8) :: a
a = 1d0
end subroutine ciao


end module mat
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
use mat
type( vector(4,10) ) :: A
A%v(1) =  1d0
A%V(2) =  2d0
A%v(3) =  3d0
write(*,*) A

end program
0

There are 0 answers