-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvectors.f90
More file actions
35 lines (21 loc) · 898 Bytes
/
vectors.f90
File metadata and controls
35 lines (21 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
!------------------------------------------------------------------------------!
!------Module contains functions for calculating the dot product---------------!
!------of two vectors, and the magnitude of a vector.--------------------------!
!------------------------------------------------------------------------------!
module vectors
use physical_constants
implicit none
contains
!Function to calculate the dot product between two vectors, A and B.
function dot(A,B)
real(kind=dp) :: dot
real(kind=dp), dimension(3) :: A, B
dot = A(1)*B(1) + A(2)*B(2) + A(3)*B(3)
endfunction dot
!Function to calculate the magnitude of a vector A.
function magnitude(A)
real(kind=dp), dimension(3) :: A
real(kind=dp) :: magnitude
magnitude = sqrt(A(1)**2 + A(2)**2 + A(3)**2)
endfunction magnitude
endmodule vectors