source: dihedr.f@ bd2278d

Last change on this file since bd2278d was bd2278d, checked in by baerbaer <baerbaer@…>, 16 years ago

Reformatting comments and continuation marks.

Fortran 90 and higher use ! to mark comments no matter where they are in the
code. The only valid continuation marker is &.
I also added the SMMP.kdevelop.filelist to the repository to make it easier
to use kdevelop.

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/smmp/trunk@12 26dc1dd8-5c4e-0410-9ffe-d298b4865968

  • Property mode set to 100644
File size: 2.9 KB
Line 
1! **************************************************************
2!
3! This file contains the subroutines: dihedr,valang
4!
5! Copyright 2003-2005 Frank Eisenmenger, U.H.E. Hansmann,
6! Shura Hayryan, Chin-Ku
7! Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann,
8! Jan H. Meinke, Sandipan Mohanty
9!
10! **************************************************************
11
12 real*8 function dihedr(i1,i2,i3,i4)
13
14! .............................................
15! PURPOSE: return dihedral angle (i1,i2,i3,i4)
16! [in rad.]
17!
18! INPUT: i1,i2,i3,i4 - indices of four atoms
19!
20! CALLS: none
21! .............................................
22
23 include 'INCL.H'
24
25 x1=xat(i2)-xat(i1)
26 y1=yat(i2)-yat(i1)
27 z1=zat(i2)-zat(i1)
28 x2=xat(i3)-xat(i2)
29 y2=yat(i3)-yat(i2)
30 z2=zat(i3)-zat(i2)
31 ux1=y1*z2-z1*y2
32 uy1=z1*x2-x1*z2
33 uz1=x1*y2-y1*x2
34 x1=xat(i4)-xat(i3)
35 y1=yat(i4)-yat(i3)
36 z1=zat(i4)-zat(i3)
37 ux2=z1*y2-y1*z2
38 uy2=x1*z2-z1*x2
39 uz2=y1*x2-x1*y2
40
41 u1=ux1*ux1+uy1*uy1+uz1*uz1
42 u2=ux2*ux2+uy2*uy2+uz2*uz2
43 u=u1*u2
44
45 if (u.ne.zero) then
46 a=(ux1*ux2+uy1*uy2+uz1*uz2)/sqrt(u)
47 a=max(a,-one)
48 a=min(a,one)
49 dihedr=acos(a)
50 if (ux1*(uy2*z2-uz2*y2)+uy1*(uz2*x2-ux2*z2)+
51 & uz1*(ux2*y2-uy2*x2).lt.zero) dihedr =-dihedr
52 return
53 else
54 write (*,'(a,4i5)')' dihedr> Error in coordinates of atoms #: '
55 & ,i1,i2,i3,i4
56
57 write (*,*) 'stored coordinates are xvals :',
58 & xat(i1),xat(i2),xat(i3),xat(i4)
59 write (*,*) 'yvals:', yat(i1),yat(i2),yat(i3),yat(i4)
60 write (*,*) 'zvals:', zat(i1),zat(i2),zat(i3),zat(i4)
61 call outvar(0,'crash.var')
62 stop
63 endif
64
65 end
66! ************************************
67 real*8 function valang(i1,i2,i3)
68
69! .........................................
70! PURPOSE: return valence angle (i1,i2,i3)
71! [in rad.] with 'i2' as vertex
72!
73! INPUT: i1,i2,i3 - indices of 3 atoms
74!
75! CALLS: none
76! .............................................
77
78 include 'INCL.H'
79 h1=xat(i2)
80 h2=yat(i2)
81 h3=zat(i2)
82 x1=xat(i1)-h1
83 x2=yat(i1)-h2
84 x3=zat(i1)-h3
85 y1=xat(i3)-h1
86 y2=yat(i3)-h2
87 y3=zat(i3)-h3
88
89 x=x1*x1+x2*x2+x3*x3
90 y=y1*y1+y2*y2+y3*y3
91 u=x*y
92
93 if (u.ne.zero) then
94
95 a=(x1*y1+x2*y2+x3*y3)/sqrt(u)
96 a=max(a,-one)
97 a=min(a,one)
98 valang=acos(a)
99 return
100
101 else
102 write (*,'(a,3i5)')' valang> Error in coordinates of atoms #: '
103 & ,i1,i2,i3
104 write (*,*) 'stored coordinates are xvals :',
105 & xat(i1),xat(i2),xat(i3)
106 write (*,*) 'yvals:', yat(i1),yat(i2),yat(i3)
107 write (*,*) 'zvals:', zat(i1),zat(i2),zat(i3)
108 call outvar(0,'crash.var')
109 stop
110 endif
111
112 end
113
Note: See TracBrowser for help on using the repository browser.