!=============================================== ! dotprod.f90 ! dot product using derived type for vectors !=============================================== program dotprod !------------------------------------------- ! module containing precision parameter !------------------------------------------- use prec_mod, only: rk !------------------------------------------- ! module containing derived type !------------------------------------------- use rvec3_mod, only: rvec3 implicit none integer :: i real(rk) :: c type(rvec3) :: a, b !... Note type of vectors !---------------------------- ! input vectors !---------------------------- print*,'Enter first vector' read*, a%x !... Note derived type notation print*,'Enter second vector' read*, b%x !---------------------------- ! calculate dot product !---------------------------- call dp(a%x, b%x, c) !---------------------------- ! check magnitude !---------------------------- if(abs(c) < 1.0e-6) then print*,'---------------------------------------------------' print*,'Warning: magnitude of dot product is less than 1e-6' print*,'---------------------------------------------------' endif !---------------------------- ! print result !---------------------------- print*,' ' print*,'dot product = ', c end program dotprod