source: bldmol.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: 8.9 KB
Line 
1! **************************************************************
2!
3! This file contains the subroutines: bldmol, fnd3ba,eyring,
4! setsys,setgbl
5!
6! Copyright 2003-2005 Frank Eisenmenger, U.H.E. Hansmann,
7! Shura Hayryan, Chin-Ku
8! Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann,
9! Jan H. Meinke, Sandipan Mohanty
10!
11! **************************************************************
12
13 subroutine bldmol(nml)
14
15! .................................................
16! PURPOSE: calculate coordinates for molecule 'nml'
17!
18! OUTPUT: xat,yat,zat,xbaat,ybaat,zbaat,xtoat,ytoat,
19! ztoat (via 'eyring')
20!
21! 1st backbone atom of 1st residue of 'nml':
22!
23! - it's position: from 'gbpr(1-3,nml)'
24! - it's axes: from 'setgbl' according to
25! global angles 'gbpr(4-5,nml)'
26!
27! CALLS: eyring, fnd3ba,setgbl,setsys
28! .................................................
29
30 include 'INCL.H'
31
32 dimension xg(3),zg(3)
33
34
35 call fnd3ba(nml,i1,i2,i3)
36! ------------------------------ first 3 bb atoms of 'nml'
37 ixrfpt(1,nml)=i1
38 ixrfpt(2,nml)=i2
39 ixrfpt(3,nml)=i3
40
41! ------------------------------ position of 1st bb atom
42 xat(i1) = gbpr(1,nml)
43 yat(i1) = gbpr(2,nml)
44 zat(i1) = gbpr(3,nml)
45
46 rfpt(1,nml)=xat(i1)
47 rfpt(2,nml)=yat(i1)
48 rfpt(3,nml)=zat(i1)
49
50 call setgbl(nml,i1,i2,i3, xg, zg)
51
52 xbaat(i1) = zg(1)
53 ybaat(i1) = zg(2)
54 zbaat(i1) = zg(3)
55
56 xtoat(i1) = xg(1)
57 ytoat(i1) = xg(2)
58 ztoat(i1) = xg(3)
59
60 ifirs=irsml1(nml)
61
62 do i=ifirs,irsml2(nml)
63 if (i.eq.ifirs) then ! not construct
64 jj=iatrs1(i)+1 ! 1st bb atom again
65 else
66 jj=iatrs1(i)
67 endif
68 do j=jj,iatrs2(i)
69 jow=iowat(j)
70 call eyring(j,jow)
71 enddo
72 enddo
73
74 call setsys(i1,i2,i3, x1,x2,x3,y1,y2,y3,z1,z2,z3)
75
76 xrfax(1,nml)=x1 ! J
77 xrfax(2,nml)=x2
78 xrfax(3,nml)=x3
79 yrfax(1,nml)=-y1 ! K
80 yrfax(2,nml)=-y2
81 yrfax(3,nml)=-y3
82 zrfax(1,nml)=-z1 ! L
83 zrfax(2,nml)=-z2
84 zrfax(3,nml)=-z3
85
86 return
87 end
88! ***********************************
89 subroutine fnd3ba(nml,i1,i2,i3)
90
91! .................................................
92! PURPOSE: return indices 'i1,i2,i3' of
93! first 3 backbone atoms in molecule 'nml'
94!
95! CALLS: fndbrn
96! .................................................
97
98 include 'INCL.H'
99
100 dimension ibd(4)
101 logical bb
102
103
104 irs=irsml1(nml)
105
106! --------------------------- 1st bb atom
107 i1=iatrs1(irs)
108
109 call fndbrn(nml,irs,i1,i,ix,i2,bb)
110
111! --------------------------- 2nd bb atom
112 i2=i+1
113
114! ------------------------ check for ring
115
116 ibd(1)=iowat(i1)
117 ibd(2)=ibdat(1,i1)
118 ibd(3)=ibdat(2,i1)
119 ibd(4)=ibdat(3,i1)
120
121 ix = 0
122 do i=1,nbdat(i1)+1
123
124 if (iowat(ibd(i)).ne.i1) then
125
126 if (ix.ne.0) then
127 write (*,'(2a,i3)')
128 & ' fnd3ba> Can handle only simple ring at 1st',
129 & ' atom of molecule #',nml
130 stop
131 endif
132
133 ix=ibd(i)
134 endif
135 enddo
136
137! --------------------------- 3rd bb atom
138
139 ix=ixatrs(irs)
140
141 if (i2.eq.ix) then
142
143 if (irs.lt.irsml2(nml)) then
144 i3 = iatrs1(irs+1)
145 return
146 endif
147
148 else
149
150 do i = ix,i2+1,-1
151 if (iowat(i).eq.i2) then
152 i3=i
153 return
154 endif
155 enddo
156
157 endif
158
159 write (*,'(4a,i4,a,i4)')
160 & ' fnd3ba> Cannot find backbone atom following ',nmat(i2),
161 & ' of residue ',seq(irs),irs,' in molecule #',nml
162 stop
163
164 end
165! ***************************
166 subroutine eyring(i,ia)
167
168! .........................................................
169! PURPOSE: calculate cartesian coordinates of atom 'i'
170! using EYRING's algorithm
171! INPUT: i - index of atom to be constructed
172! for 'i': blat,csbaat,snbaat,cstoat,sntoat
173! ia- index of atom from which 'i' is to be built
174! OUTPUT: for 'i': xat,yat,zat,xbaat,ybaat,zbaat,xtoat,ytoat,ztoat
175!
176! CALLS: none
177! .........................................................
178
179 include 'INCL.H'
180
181 ct=cstoat(i)
182 st=sntoat(i)
183 ca=csbaat(i)
184 sa=snbaat(i)
185 bl=blat(i)
186
187 x1=xtoat(ia)
188 x2=ytoat(ia)
189 x3=ztoat(ia)
190
191 z1=xbaat(ia)
192 z2=ybaat(ia)
193 z3=zbaat(ia)
194
195 y1=z2*x3-z3*x2
196 y2=z3*x1-z1*x3
197 y3=z1*x2-z2*x1
198
199 h2=-sa*ct
200 h3=-sa*st
201
202 x1=-ca*x1+h2*y1+h3*z1
203 x2=-ca*x2+h2*y2+h3*z2
204 x3=-ca*x3+h2*y3+h3*z3
205
206 dx=one/sqrt(x1*x1+x2*x2+x3*x3)
207 x1=x1*dx
208 x2=x2*dx
209 x3=x3*dx
210
211 xtoat(i)=x1
212 ytoat(i)=x2
213 ztoat(i)=x3
214
215 z1=-st*y1+ct*z1
216 z2=-st*y2+ct*z2
217 z3=-st*y3+ct*z3
218
219 dz=one/sqrt(z1*z1+z2*z2+z3*z3)
220 xbaat(i)=z1*dz
221 ybaat(i)=z2*dz
222 zbaat(i)=z3*dz
223
224 xat(i)=xat(ia)+x1*bl
225 yat(i)=yat(ia)+x2*bl
226 zat(i)=zat(ia)+x3*bl
227
228 return
229 end
230! ***********************************************************
231 subroutine setsys(i1,i2,i3, x1,x2,x3,y1,y2,y3,z1,z2,z3)
232
233! ..........................................................
234! PURPOSE: calculate axes X,Y,Z of right-handed orthogonal
235! system given by three atom positions R1, R2, R3
236!
237! X = (R2-R1)/ |( )|
238! Z = {X x (R2-R3)} / |{ }|
239! Y = Z x X
240!
241! INPUT: i1, i2, i3 - indices of three atoms
242! OUTPUT: x1,x2,x3 |
243! y1,y2,y3 | -direction cosines of X,Y,Z
244! z1,z2,z3 |
245!
246! CALLS: none
247! ...................................................
248
249
250 include 'INCL.H'
251
252 h1=xat(i2)
253 h2=yat(i2)
254 h3=zat(i2)
255
256 x1=h1-xat(i1)
257 x2=h2-yat(i1)
258 x3=h3-zat(i1)
259
260 y1=h1-xat(i3)
261 y2=h2-yat(i3)
262 y3=h3-zat(i3)
263
264 z1=x2*y3-x3*y2
265 z2=x3*y1-x1*y3
266 z3=x1*y2-x2*y1
267
268 dx=one/sqrt(x1*x1+x2*x2+x3*x3)
269 x1=x1*dx
270 x2=x2*dx
271 x3=x3*dx
272
273 dz=one/sqrt(z1*z1+z2*z2+z3*z3)
274 z1=z1*dz
275 z2=z2*dz
276 z3=z3*dz
277
278 y1=z2*x3-z3*x2
279 y2=z3*x1-z1*x3
280 y3=z1*x2-z2*x1
281
282 return
283 end
284
285! *****************************************
286 subroutine setgbl(nml,i1,i2,i3,xg,zg)
287
288! ...................................................
289!
290! PURPOSE: 1. Obtain global axes (J,K,L)
291! related to x(1 0 0),y(0 1 0),z(0 0 1)
292! by 3 rotations (gbl. parameters #4-#6):
293!
294! - round z by angle alpha
295! - round x' by a. beta
296! - round y" by a. gamma
297!
298! 2. Return x-axis (xg) & z-axis (zg)
299! for atom #1 in order to orientate J
300! along the bond from backbone atom #1
301! to bb.a. #2 and L according to the
302! cross product [ bond(#1->#2) x
303! bond(#2->#3) ] when using Eyring's
304! algorithm to get the coordinates
305!
306! CALLS: none
307! ..............................................
308
309 include 'INCL.H'
310
311 dimension xg(3),zg(3),ag(3,3)
312
313
314 ca = cos(gbpr(4,nml)) ! alpha
315 sa = sin(gbpr(4,nml))
316 cb = cos(gbpr(5,nml)) ! beta
317 sb = sin(gbpr(5,nml))
318 cg = cos(gbpr(6,nml)) ! gamma
319 sg = sin(gbpr(6,nml))
320
321! ----------------------------- J
322 x1 = ca*cg - sa*sb*sg
323 x2 = sa*cg + ca*sb*sg
324 x3 = -cb*sg
325
326 d = sqrt(x1**2+x2**2+x3**2)
327 ag(1,1) = x1/d
328 ag(2,1) = x2/d
329 ag(3,1) = x3/d
330! ----------------------------- K
331 y1 = -sa*cb
332 y2 = ca*cb
333 y3 = sb
334
335 d = sqrt(y1**2+y2**2+y3**2)
336 ag(1,2) = y1/d
337 ag(2,2) = y2/d
338 ag(3,2) = y3/d
339! ----------------------------- L
340 z1 = ca*sg + sa*sb*cg
341 z2 = sa*sg - ca*sb*cg
342 z3 = cb*cg
343
344 d = sqrt(z1**2+z2**2+z3**2)
345 ag(1,3) = z1/d
346 ag(2,3) = z2/d
347 ag(3,3) = z3/d
348
349! ------------------------------------ X1
350 ct2 = cstoat(i2)
351 st2 = sntoat(i2)
352 sa2 = snbaat(i2)
353
354 x1 = -csbaat(i2)
355 x2 = -sa2*ct2
356 x3 = -sa2*st2
357
358 dx = sqrt(x1**2+x2**2+x3**2)
359 x1 = x1/dx
360 x2 = x2/dx
361 x3 = x3/dx
362! ------------------------------------- Z1
363 st3 = sntoat(i3)
364 ct3 = cstoat(i3)
365
366 z1 = -st3*(st2*x3+ct2*x2)
367 z2 = st3*ct2*x1 + ct3*st2
368 z3 = st3*st2*x1 - ct3*ct2
369
370 dz = sqrt(z1**2+z2**2+z3**2)
371 z1 = z1/dz
372 z2 = z2/dz
373 z3 = z3/dz
374! ------------------------------------- Y1
375 y1 = z2 * x3 - z3 * x2
376 y3 = z1 * x2 - z2 * x1 ! do not need y2
377
378! ----------------------------- into global system
379
380 xg(1) = ag(1,1)*x1 + ag(1,2)*y1 + ag(1,3)*z1
381 xg(2) = ag(2,1)*x1 + ag(2,2)*y1 + ag(2,3)*z1
382 xg(3) = ag(3,1)*x1 + ag(3,2)*y1 + ag(3,3)*z1
383
384 dx = sqrt(xg(1)**2+xg(2)**2+xg(3)**2)
385
386 zg(1) = ag(1,1)*x3 + ag(1,2)*y3 + ag(1,3)*z3
387 zg(2) = ag(2,1)*x3 + ag(2,2)*y3 + ag(2,3)*z3
388 zg(3) = ag(3,1)*x3 + ag(3,2)*y3 + ag(3,3)*z3
389
390 dz = sqrt(zg(1)**2+zg(2)**2+zg(3)**2)
391
392 do i=1,3
393 xg(i) = xg(i)/dx
394 zg(i) = zg(i)/dz
395 enddo
396
397 return
398 end
399
Note: See TracBrowser for help on using the repository browser.