function that calculates the dot product of two real 3-dimensional vectors and
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in), | DIMENSION(:) | :: | a | ||
real(kind=dp), | intent(in), | DIMENSION(:) | :: | b |
FUNCTION dot(a, b) RESULT(result) REAL(dp), DIMENSION(:), INTENT(IN) :: a, b REAL(dp) :: result INTEGER :: i IF (SIZE(a) /= SIZE(b)) STOP "Error: Vectors must be of the same size." result = 0.0_dp DO i = 1, SIZE(a) result = result + a(i) * b(i) END DO END FUNCTION dot