!=============================================== ! dotprod.f90 ! prompt for two real vectors of length 3, ! calculate dot product; if magnitude of ! dot product is less than 1e-6, print warning, ! then print result !=============================================== program dotprod implicit none integer :: i real :: c real, dimension(3) :: a, b !---------------------------- ! input vectors !---------------------------- print*,'Enter first vector' read*, a print*,'Enter second vector' read*, b !---------------------------- ! calculate dot product !---------------------------- c = 0.0 do i = 1, 3 c = c + a(i)*b(i) enddo !---------------------------- ! 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