source: mklist.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: 12.1 KB
RevLine 
[bd2278d]1! **************************************************************
2!
3! This file contains the subroutines: mklist,quench
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! **************************************************************
[e40e335]11
12 subroutine mklist(nml)
13
[bd2278d]14! ......................................................................
15! PURPOSE: Compile interaction lists ('1-4' according to Scheraga)
16!
17! CALLS: quench
18! ......................................................................
19! TODO: Calculate van-der-Waals regions over all molecules.
[e40e335]20 include 'INCL.H'
[cb47b9c]21 integer nml
[e40e335]22
[cb47b9c]23 integer mxh, mx2, l1st1, l1st2, l2nd1, l2nd2, l1i, l2i
[e40e335]24 parameter (mxh=50, ! max. # of atom regions
[bd2278d]25 & mx2=50)
[e40e335]26
27 logical ovlp,quench
28
29 dimension l1st1(mxh),l1st2(mxh),l2nd1(mxh),l2nd2(mxh)
[bd2278d]30 & ,l1i(mxbd),l2i(mx2)
[e40e335]31
[cb47b9c]32 integer ia, i, i1s, i2s, ibd, ib, ifivr, ifiat, ilaat, im, ilavr,
33 & iob, io, ioiob, iow, it, is, iv, jbd, j, n1i, n14, n1st,
34 & n2nd, n2i, ntlms, nvw
35
[bd2278d]36! _______________________ indices of 1st vdw-region/14-partner for 'nml'
[e40e335]37 if (nml.eq.1) then
38 ivwml1(1)=1
39 i14ml1(1)=1
40 else
41 ivwml1(nml)=ivwml1(nml-1)+nvwml(nml-1)
42 i14ml1(nml)=i14ml1(nml-1)+n14ml(nml-1)
43 endif
44
45 ntlms=nmsml(nml)
46 if (ntlms.eq.0) then
[38d77eb]47 write (logString, '(a,i4)')
[bd2278d]48 & ' mklist> No mov. sets defined in molecule #',nml
[e40e335]49 nvwml(nml)=0
50 n14ml(nml)=0
51 return
52 endif
53
54 nvw=ivwml1(nml)-1 ! # of vdw-regions we have so far
55 n14=i14ml1(nml)-1 ! # of 14-partners -"-
[bd2278d]56! First atom in molecule
[e40e335]57 ifiat=iatrs1(irsml1(nml))
[bd2278d]58! Last atom in molecule
[e40e335]59 ilaat=iatrs2(irsml2(nml))
[bd2278d]60! First variable in molecule
[e40e335]61 ifivr=ivrml1(nml)
[bd2278d]62! Last variable in molecule
[e40e335]63 ilavr=ifivr+nvrml(nml)-1
[bd2278d]64! ____________________________ initialize: 1st vdw-region & 14-partner per atom
[e40e335]65 do i=ifiat,ilaat
66 ivwat1(i)=0 !!! for some atoms ...
67 i14at1(i)=0 !!! ... remains = 0
68 enddo
69 n1st=1 ! initialize 1ST list of interact. partners:
70 l1st1(1)=ifiat ! one region including ALL atoms
71 l1st2(1)=ilaat ! of molecule 'nml'
72
73 i1s=imsml1(nml)+ntlms ! 1st mov.set of molecule 'nml+1'
74
75 do io=ilavr,ifivr,-1 ! ====== from last -> first variable in 'nml'
76 iv=iorvr(io) ! ====== according to 'descendent' order
77 it=ityvr(iv) ! type of var.
78 i2s=i1s-1
79 i1s=imsvr1(iv)
80 if ((i2s-i1s+1).gt.0) then
81
[bd2278d]82! ____________ exclude mov.sets of var. 'iv' from 1ST list of interact.partn.
[e40e335]83 do is=i1s,i2s
84 ovlp=quench(latms1(is),latms2(is),n1st,mxh,l1st1,l1st2)
85 enddo
[bd2278d]86! _______________________________ intitialize 2ND list with current 1ST list
[e40e335]87 do i=1,n1st
88 l2nd1(i)=l1st1(i)
89 l2nd2(i)=l1st2(i)
90 enddo
91 n2nd=n1st
[bd2278d]92! _________________________________ exclude 'ib' of var. 'iv' from 2ND list
[e40e335]93 ib=iowat(iatvr(iv))
94 ovlp=quench(ib,ib,n2nd,mxh,l2nd1,l2nd2)
95
96 ovlp=.false.
97 iob=iowat(ib)
98 n2i=0
99 if (iob.gt.0) then ! 'iob' exists
100 ovlp=quench(iob,iob,n2nd,mxh,l2nd1,l2nd2) ! & in 2ND list
101
[bd2278d]102! _____ atoms branching from 'iob': into GENERAL list of 1-4 partners
[e40e335]103 do i=1,nbdat(iob)
104 ibd=ibdat(i,iob)
105 if (ibd.ne.ib.and.iowat(ibd).eq.iob.and.
[bd2278d]106 & quench(ibd,ibd,n2nd,mxh,l2nd1,l2nd2) ) then
[e40e335]107 n2i=n2i+1
108 if (n2i.gt.mx2) then
[38d77eb]109 write(logString, '(a,i3,2a)') ' mklist> Molecule # ',
110 & nml,
[bd2278d]111 & ': too many atoms bound to ',nmat(iob)
[e40e335]112 stop
113 endif
114 l2i(n2i)=ibd
115 endif
116 enddo ! ... branches of 'iob'
[bd2278d]117! ____________________________ check for further '1-4' partners
118! connected to branches 'l2i'
[e40e335]119 do i=1,n2i
120 ia=l2i(i)
121 im=ixmsat(ia)
122 if (im.gt.0) then
123 do j=latms1(im),latms2(im)
124 if (ia.ne.j.and.
[bd2278d]125 & quench(j,j,n2nd,mxh,l2nd1,l2nd2) ) then
[e40e335]126 n2i=n2i+1
127 if (n2i.gt.mx2) then
[38d77eb]128 write (logString, '(a,i3,a)')
129 & ' mklist> Molecule # '
[bd2278d]130 & ,nml,': too many atoms in list L2I'
[e40e335]131 stop
132 endif
133 l2i(n2i)=j
134 endif
135 enddo
136 endif
137 enddo
138
[bd2278d]139! ____ If 'iow(iob)' exists and in 2ND list: into GENERAL list of 1-4 partners
[e40e335]140 ioiob=iowat(iob) ! existence of iow( iow(base) )
141 if (ioiob.gt.0) then
142 if( quench(ioiob,ioiob,n2nd,mxh,l2nd1,l2nd2) ) then
143 n2i=n2i+1
144 if (n2i.gt.mx2) then
[38d77eb]145 write (logString, '(a,i3,2a)') ' mklist> Molecule # '
[bd2278d]146 & ,nml,': too many atoms bound to ',nmat(iob)
[e40e335]147 stop
148 endif
149 l2i(n2i)=ioiob
150 endif
151 else
152 ioiob=-10
153 endif
154
155 else
156 iob=-10
157 ioiob=-10
158 endif
159
[bd2278d]160! ______ Atoms bound to 'ib' & in 2ND list(=are NOT in m.s of 'iv'):
161! exclude from 2ND list & put in list 'l1i'
[e40e335]162 n1i=0
163 do i=1,nbdat(ib)
164 ibd=ibdat(i,ib)
165 if (iowat(ibd).eq.ib.and.
[bd2278d]166 & quench(ibd,ibd,n2nd,mxh,l2nd1,l2nd2) ) then
[e40e335]167 n1i=n1i+1
168 if (n1i.gt.mxbd) then
[38d77eb]169 write (logString, '(a,i3,2a)') ' mklist> Molecule # ',
170 & nml,
[bd2278d]171 & ': too many atoms bound to ',nmat(ib)
[e40e335]172 stop
173 endif
174 l1i(n1i)=ibd
[bd2278d]175! _______ add atoms branching from 'l1i'-atoms to GENERAL list 1-4 partners
[e40e335]176 do j=1,nbdat(ibd)
177 jbd=ibdat(j,ibd)
178 if (iowat(jbd).eq.ibd.and.
[bd2278d]179 & quench(jbd,jbd,n2nd,mxh,l2nd1,l2nd2) ) then
[e40e335]180 n2i=n2i+1
181 if (n2i.gt.mx2) then
[38d77eb]182 write (logString, '(a,i3,2a)')
183 & ' mklist> Molecule # ',nml,
184 & ': too many atoms bound to branches of ',nmat(ib)
[e40e335]185 stop
186 endif
187 l2i(n2i)=jbd
188 endif
189 enddo
190 endif
191 enddo
[bd2278d]192! _____________________________ check for further '1-4' partners
193! belonging to moving set of base 'ib'
[e40e335]194 im=ixmsat(ib)
195 if (im.gt.0) then
196 do i=latms1(im),latms2(im)
197 if (quench(i,i,n2nd,mxh,l2nd1,l2nd2) ) then
198 n2i=n2i+1
199 if (n2i.gt.mx2) then
[38d77eb]200 write (logString, '(a,i3,a)') ' mklist> Molecule # ',
201 & nml,
202 & ': too many atoms n list L2I '
[e40e335]203 stop
204 endif
205 l2i(n2i)=i
206 endif
207 enddo
208 endif
209
210 do is=i1s,i2s
211 do i=latms1(is),latms2(is) ! ============= atoms in m.s of 'iv'
[bd2278d]212! ________________________________________ Current 2ND list -> VdW-interact.
[e40e335]213 if ((nvw+n2nd).gt.mxvw) then
[38d77eb]214 write (logString, '(a,i4,a,i5)') ' mklist> Molecule # ',
215 & nml,
[bd2278d]216 & ': Number of vdw-domains > ',mxvw
[e40e335]217 stop
218 endif
219 ivwat1(i)=nvw+1 ! first and last vdW-domain ..
220 ivwat2(i)=nvw+n2nd ! .. per atom
221 do j=1,n2nd
222 nvw=nvw+1
223 ixatvw(nvw)=i
224 lvwat1(nvw)=l2nd1(j)
225 lvwat2(nvw)=l2nd2(j)
226 enddo ! ... vdW-domains
[bd2278d]227! _________________________________________ General list of 1-4 partners
[e40e335]228 if ((n14+n2i).gt.mx14) goto 1
229 i14at1(i)=n14+1
230 do j=1,n2i
231 n14=n14+1
232 ixat14(n14)=i
233 l14at(n14)=l2i(j)
234 enddo
[bd2278d]235! __________________________________ Special cases of 1-4 interactions
236! (list l1i, atoms iob,ib)
[e40e335]237 iow=iowat(i)
238 if (iow.ne.ib) then
239 if ((n14+n1i).gt.mx14) goto 1
240 do j=1,n1i ! _____ branches of 'ib' NOT in m.s
241 n14=n14+1
242 ixat14(n14)=i
243 l14at(n14)=l1i(j)
244 enddo
245 if (ovlp.and.(it.eq.1.or.it.eq.2)) then ! _____ iob:
246 n14=n14+1 ! b.lengths/angles
247 if (n14.gt.mx14) goto 1
248 ixat14(n14)=i
249 l14at(n14)=iob
250 endif
251 if (iowat(iow).ne.ib.and.it.eq.1) then ! ___ ib:
252 n14=n14+1 ! b.length
253 if (n14.gt.mx14) goto 1
254 ixat14(n14)=i
255 l14at(n14)=ib
256 endif
257 endif ! ... spec. case
258 i14at2(i)=n14
259 enddo ! ... atoms for moving set 'is'
260 enddo ! ... m.s for var. 'iv'
261
262 endif ! if there are moving sets
263 enddo ! ... variables
264
265 nvwml(nml)=nvw-ivwml1(nml)+1
266 n14ml(nml)=n14-i14ml1(nml)+1
[bd2278d]267! _________________________________ some cleaning up
[e40e335]268 do i=ifiat,ilaat
269 if (ivwat1(i).le.0) then
270 ivwat1(i)=1
271 ivwat2(i)=0
272 endif
273 if (i14at1(i).le.0) then
274 i14at1(i)=1
275 i14at2(i)=0
276 endif
277 enddo
278
[bd2278d]279! ____________________________________________ Summary
280! do i=ifiat,ilaat
[38d77eb]281! write (logString, '(3a,i5,a)') ' ######## atom ',nmat(i),'(',i,')'
[bd2278d]282! iv1=ivwat1(i)
283! iv2=ivwat2(i)
284! if (iv1.le.iv2) then
[38d77eb]285! write (logString, '(a)') ' ---> vdW :'
[bd2278d]286! do j=iv1,iv2
[38d77eb]287! write (logString, '(i5,a,i5)') lvwat1(j),'-',lvwat2(j)
[bd2278d]288! enddo
289! endif
290! i41=i14at1(i)
291! i42=i14at2(i)
292! if (i41.le.i42) then
[38d77eb]293! write (logString, '(a)') ' ---> 1-4 :'
294! write (logString, '(10i5)') (l14at(j),j=i41,i42)
[bd2278d]295! endif
296! enddo
[e40e335]297
298 return
299
[38d77eb]300 1 write (logString, '(a,i4,a,i5)') ' mklist> Molecule # ',nml,
[bd2278d]301 & ': Number of 1-4 interactions > ',mx14
[e40e335]302 stop
303 end
[bd2278d]304! *********************************************
[e40e335]305 logical function quench(i1,i2,n,mx,l1,l2)
306
[bd2278d]307! ....................................................
308! PURPOSE: Correct size/number (n) of index ranges
309! given by lists 'l1' & 'l2' in order to
310! EXCLUDE overlaps with range 'i1-i2'
311!
312! quench = true, if any overlap was obtained
313!
314! CALLS: none
315!
316! ....................................................
[e40e335]317
[6650a56]318 implicit none
319 integer mx, j, n, j1, l1, j2, l2, i1, i2, ja, k
[38d77eb]320 character(255) logString
[e40e335]321 dimension l1(mx),l2(mx)
322
323 quench=.false. ! initialize
324
325 j=1
326 do while (j.le.n) ! while there are sets
327 j1=l1(j)
328 j2=l2(j)
329
330 if (i1.le.j2.and.i2.ge.j1) then ! Overlap
331 quench=.true.
332
333 ja=0
334 if (i1.gt.j1) then
335 ja=1
336 l2(j)=i1-1
337 endif
338 if (i2.lt.j2) then
339 if (ja.gt.0) then ! +1 set
340 n=n+1
341 if (n.gt.mx) then
[38d77eb]342 write (logString, '(a)') ' quench> too many sets'
[e40e335]343 stop
344 endif
345 do k=n,j+2,-1 ! shift sets
346 l1(k)=l1(k-1)
347 l2(k)=l2(k-1)
348 enddo
349 l2(j+1)=j2
350 endif
351 l1(j+ja)=i2+1
352 ja=ja+1
353 endif
354
355 if (ja.eq.0) then ! -1 set
356 n=n-1
357 do k=j,n
358 l1(k)=l1(k+1)
359 l2(k)=l2(k+1)
360 enddo
361 else
362 j=j+ja
363 endif
364
365 else ! No overlap
366 j=j+1
367 endif
368
369 enddo ! ... sets
370
371 return
372 end
373
Note: See TracBrowser for help on using the repository browser.