source: dihedr.f

Last change on this file was 38d77eb, checked in by baerbaer <baerbaer@…>, 14 years ago

Redirected standard out to logString.

SMMP produced a lot of log messages. This became an issue when run in massively
parallel environments. I replaced all writes to standard out to a write to logString.
The next step is to pass this string to a function that writes the messages to a log
file according to their importance and the chosen log level.

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

  • Property mode set to 100644
File size: 3.3 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 integer i1, i2, i3, i4
26
27 double precision x1, y1, z1, x2, y2, z2, ux1,uy1, uz1, a, u, u1,
28 & u2, ux2, uy2, uz2
29
30 x1=xat(i2)-xat(i1)
31 y1=yat(i2)-yat(i1)
32 z1=zat(i2)-zat(i1)
33 x2=xat(i3)-xat(i2)
34 y2=yat(i3)-yat(i2)
35 z2=zat(i3)-zat(i2)
36 ux1=y1*z2-z1*y2
37 uy1=z1*x2-x1*z2
38 uz1=x1*y2-y1*x2
39 x1=xat(i4)-xat(i3)
40 y1=yat(i4)-yat(i3)
41 z1=zat(i4)-zat(i3)
42 ux2=z1*y2-y1*z2
43 uy2=x1*z2-z1*x2
44 uz2=y1*x2-x1*y2
45
46 u1=ux1*ux1+uy1*uy1+uz1*uz1
47 u2=ux2*ux2+uy2*uy2+uz2*uz2
48 u=u1*u2
49
50 if (u.ne.zero) then
51 a=(ux1*ux2+uy1*uy2+uz1*uz2)/sqrt(u)
52 a=max(a,-one)
53 a=min(a,one)
54 dihedr=acos(a)
55 if (ux1*(uy2*z2-uz2*y2)+uy1*(uz2*x2-ux2*z2)+
56 & uz1*(ux2*y2-uy2*x2).lt.zero) dihedr =-dihedr
57 return
58 else
59 write (logString, '(a,4i5)')
60 & ' dihedr> Error in coordinates of atoms #: '
61 & ,i1,i2,i3,i4
62
63 write (logString, *) 'stored coordinates are xvals :',
64 & xat(i1),xat(i2),xat(i3),xat(i4)
65 write (logString, *) 'yvals:', yat(i1),yat(i2),yat(i3),yat(i4)
66 write (logString, *) 'zvals:', zat(i1),zat(i2),zat(i3),zat(i4)
67 call outvar(0,'crash.var')
68 stop
69 endif
70
71 end
72! ************************************
73 real*8 function valang(i1,i2,i3)
74
75! .........................................
76! PURPOSE: return valence angle (i1,i2,i3)
77! [in rad.] with 'i2' as vertex
78!
79! INPUT: i1,i2,i3 - indices of 3 atoms
80!
81! CALLS: none
82! .............................................
83
84 include 'INCL.H'
85
86 integer i1, i2, i3
87
88 double precision h1, h2, h3, x1, x2, x3, y1, y2, y3, x, y, u, a
89
90 h1=xat(i2)
91 h2=yat(i2)
92 h3=zat(i2)
93 x1=xat(i1)-h1
94 x2=yat(i1)-h2
95 x3=zat(i1)-h3
96 y1=xat(i3)-h1
97 y2=yat(i3)-h2
98 y3=zat(i3)-h3
99
100 x=x1*x1+x2*x2+x3*x3
101 y=y1*y1+y2*y2+y3*y3
102 u=x*y
103
104 if (u.ne.zero) then
105
106 a=(x1*y1+x2*y2+x3*y3)/sqrt(u)
107 a=max(a,-one)
108 a=min(a,one)
109 valang=acos(a)
110 return
111
112 else
113 write (logString, '(a,3i5)')
114 & ' valang> Error in coordinates of atoms #: '
115 & ,i1,i2,i3
116 write (logString, *) 'stored coordinates are xvals :',
117 & xat(i1),xat(i2),xat(i3)
118 write (logString, *) 'yvals:', yat(i1),yat(i2),yat(i3)
119 write (logString, *) 'zvals:', zat(i1),zat(i2),zat(i3)
120 call outvar(0,'crash.var')
121 stop
122 endif
123
124 end
125
Note: See TracBrowser for help on using the repository browser.