double precision :: x, y, z end type vector type(vector) :: a, b, c a%x=1.0d0 a%y=0.0d0 a%z=0.0d0 b%x=1.0d0 b%y=1.0d0 b%z=0.0d0 c = vector_product(a,b) write(*,*) c
function vector_product( u, v) result(w) type(vector) :: u, v, w w%x = u%y * v%z - u%z * v%y w%y = u%z * v%x - u%x * v%z w%z = u%x * v%y - u%y * v%x