-
Notifications
You must be signed in to change notification settings - Fork 0
/
calcCenterofMass.f
48 lines (36 loc) · 967 Bytes
/
calcCenterofMass.f
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
36
37
38
39
40
41
42
43
44
45
46
47
48
program FindCOM
integer stream,i,j,Nwater
parameter (stream=50,Nwater=20)
double precision point
double precision com(3)
c Initialize COM to 0
do j=1,3
com(j)=0.0D0
enddo
c Open Stream
open(stream,FILE='points.20',STATUS='OLD')
c Calculate COM on the fly (xyz Oxygen, then xyz H1, xyz H2)
do i=1,Nwater
do j=1,3
read(stream,*)point
com(j)=com(j)+dble(point)*15.9994D0
enddo
do j=1,3
read(stream,*)point
com(j)=com(j)+dble(point)*1.00794D0
enddo
do j=1,3
read(stream,*)point
com(j)=com(j)+dble(point)*1.00794D0
enddo
enddo
do j=1,3
com(j)=com(j)/(15.9994D0 + 2.0D0*1.00794D0)
enddo
c Output COM coordinates
print*,"Water Cage Center is : "
do j=1,3
print*, com(j)
enddo
stop
end