2 C Program to cluster united-residue MCM results.
9 integer IERROR,ERRCODE,STATUS(MPI_STATUS_SIZE)
12 include 'COMMON.TIME1'
13 include 'COMMON.INTERACT'
14 include 'COMMON.NAMES'
16 include 'COMMON.HEADER'
17 include 'COMMON.CONTROL'
18 include 'COMMON.CHAIN'
20 include 'COMMON.CLUSTER'
21 include 'COMMON.IOUNITS'
23 logical printang(max_cut)
24 integer printpdb(max_cut)
25 integer printmol2(max_cut)
27 REAL CRIT(maxconf),MEMBR(maxconf)
28 REAL CRITVAL(maxconf-1)
29 INTEGER IA(maxconf),IB(maxconf)
30 INTEGER ICLASS(maxconf,maxconf-1),HVALS(maxconf-1)
31 INTEGER IORDER(maxconf-1),HEIGHT(maxconf-1)
32 integer nn,ndis,scount_buf
33 real*4 DISNN, diss_buf(maxdist)
34 DIMENSION NN(maxconf),DISNN(maxconf)
36 integer i,j,k,l,m,n,len,lev,idum,ii,ind,ioffset,jj,icut,ncon,
37 & it,ncon_work,ind1,kkk, ijk
38 double precision t1,t2,tcpu,difconf
40 double precision varia(maxvar)
41 double precision hrtime,mintime,sectime
44 call MPI_Init( IERROR )
45 call MPI_Comm_rank( MPI_COMM_WORLD, me, IERROR )
46 call MPI_Comm_size( MPI_COMM_WORLD, nprocs, IERROR )
49 write(iout,*) "SEVERE ERROR - Can't initialize MPI."
50 call mpi_finalize(ierror)
53 if (nprocs.gt.MaxProcs+1) then
54 write (2,*) "Error - too many processors",
56 write (2,*) "Increase MaxProcs and recompile"
57 call MPI_Finalize(IERROR)
67 c if (refstr) call read_ref_structure(*30)
74 c write (iout,*) "Before permut"
75 c write (iout,*) "symetr", symetr
78 c write (iout,*) "after permut"
80 print *,'MAIN: nnt=',nnt,' nct=',nct
86 IF (RCUTOFF(I).LT.0.0) THEN
87 RCUTOFF(I)=ABS(RCUTOFF(I))
93 write (iout,*) 'Number of cutoffs:',NCUT
94 write (iout,*) 'Cutoff values:'
96 WRITE(IOUT,'(8HRCUTOFF(,I2,2H)=,F8.1,2i2)')ICUT,RCUTOFF(ICUT),
97 & printpdb(icut),printmol2(icut)
105 call read_coords(ncon,*20)
106 write (iout,*) 'from read_coords: ncon',ncon
108 write (iout,*) "nT",nT
110 write (iout,*) "iT",iT
112 call work_partition(.true.,ncon)
115 call probabl(iT,ncon_work,ncon,*20)
117 if (ncon_work.lt.2) then
118 write (iout,*) "Too few conformations; clustering skipped"
122 ndis=ncon_work*(ncon_work-1)/2
123 call work_partition(.true.,ndis)
125 write(iout,*) "AFTET wort_part",NCON_work
129 WRITE (iout,'(A80)') TITEL
132 C CALCULATE DISTANCES
134 call daread_ccoords(1,ncon_work)
135 write (iout,*) "AM I HERE"
139 if (mod(i,100).eq.0) print *,'Calculating RMS i=',i
142 c(l,k)=allcart(l,k,i)
152 IND=IOFFSET(NCON_work,I,J)
154 if (ind.ge.indstart(me) .and. ind.le.indend(me)) then
157 DISS(IND1)=DIFCONF(I,J)
158 c write (iout,'(2i4,i10,f10.5)') i,j,ind,DISS(IND)
165 WRITE (iout,'(/a,1pe14.5,a/)')
166 & 'Time for distance calculation:',T2-T1,' sec.'
168 PRINT '(a)','End of distance computation'
170 scount_buf=scount(me)
173 diss_buf(ijk)=diss(ijk)
178 WRITE (iout,*) "Wchodze do call MPI_Gatherv"
179 call MPI_Gatherv(diss_buf(1),scount_buf,MPI_REAL,diss(1),
180 & scount(0),idispl(0),MPI_REAL,Master,MPI_COMM_WORLD, IERROR)
181 if (me.eq.master) then
183 open(80,file='/tmp/distance',form='unformatted')
190 IND=IOFFSET(NCON,I,J)
191 write (jrms,'(2i5,2f10.5)') i,j,diss(IND),
192 & energy(j)-energy(i)
197 C Print out the RMS deviation matrix.
199 if (print_dist) CALL DISTOUT(NCON_work)
201 C call hierarchical clustering HC from F. Murtagh
205 write(iout,*) "-------------------------------------------"
206 write(iout,*) "HIERARCHICAL CLUSTERING using"
208 write(iout,*) "WARD'S MINIMUM VARIANCE METHOD"
209 elseif (iopt.eq.2) then
210 write(iout,*) "SINGLE LINK METHOD"
211 elseif (iopt.eq.3) then
212 write(iout,*) "COMPLETE LINK METHOD"
213 elseif (iopt.eq.4) then
214 write(iout,*) "AVERAGE LINK (OR GROUP AVERAGE) METHOD"
215 elseif (iopt.eq.5) then
216 write(iout,*) "MCQUITTY'S METHOD"
217 elseif (iopt.eq.6) then
218 write(iout,*) "MEDIAN (GOWER'S) METHOD"
219 elseif (iopt.eq.7) then
220 write(iout,*) "CENTROID METHOD"
222 write(iout,*) "IOPT=",iopt," IS INVALID, use 1-7"
223 write(*,*) "IOPT=",iopt," IS INVALID, use 1-7"
227 write(iout,*) "hc.f by F. Murtagh, ESA/ESO/STECF, Garching"
228 write(iout,*) "February 1986"
229 write(iout,*) "References:"
230 write(iout,*) "1. Multidimensional clustering algorithms"
231 write(iout,*) " Fionn Murtagh"
232 write(iout,*) " Vienna : Physica-Verlag, 1985."
233 write(iout,*) "2. Multivariate data analysis"
234 write(iout,*) " Fionn Murtagh and Andre Heck"
235 write(iout,*) " Kluwer Academic Publishers, 1987"
236 write(iout,*) "-------------------------------------------"
240 write (iout,*) "The TOTFREE array"
242 write (iout,'(2i5,f10.5)') i,list_conf(i),totfree(i)
246 CALL HC(N,M,LEN,IOPT,IA,IB,CRIT,MEMBR,NN,DISNN,FLAG,DISS)
248 write (iout,*) "n",n," ncon_work",ncon_work," lev",lev
250 write (iout,*) "Too few conformations to cluster."
253 CALL HCASS(N,IA,IB,CRIT,LEV,ICLASS,HVALS,IORDER,CRITVAL,HEIGHT)
254 c CALL HCDEN(LEV,IORDER,HEIGHT,CRITVAL)
263 licz(iclass(j,i))=licz(iclass(j,i))+1
264 nconf(iclass(j,i),licz(iclass(j,i)))=j
265 c write (iout,*) i,j,iclass(j,i),licz(iclass(j,i)),
266 c & nconf(iclass(j,i),licz(iclass(j,i)))
272 IF (HEIGHT(L).EQ.IDUM) GOTO 190
275 write(IOUT,*) "i+1",i+1," idum",idum," critval",CRITVAL(IDUM),
276 & " icut",icut," cutoff",rcutoff(icut)
277 IF (CRITVAL(IDUM).LT. RCUTOFF(ICUT)) THEN
278 WRITE (iout,'(/a,f10.5)') 'AT CUTOFF:',rcutoff(icut)
279 write (iout,'(a,f8.2)') 'Maximum distance found:',
281 CALL SRTCLUST(ICUT,ncon_work,iT)
283 CALL WRTCLUST(ncon_work,ICUT,PRINTANG,PRINTPDB,PRINTMOL2,iT)
285 if (icut.gt.ncut) goto 191
292 licz(iclass(j,i))=licz(iclass(j,i))+1
293 nconf(iclass(j,i),licz(iclass(j,i)))=j
294 c write (iout,*) i,j,iclass(j,i),licz(iclass(j,i)),
295 c & nconf(iclass(j,i),licz(iclass(j,i)))
296 cd print *,j,iclass(j,i),
297 cd & licz(iclass(j,i)),nconf(iclass(j,i),licz(iclass(j,i)))
308 WRITE (iout,'(/a,1pe14.5,a/)')
309 & 'Total time for clustering:',T2-T1,' sec.'
317 close(icbase,status="delete")
319 call MPI_Finalize(IERROR)
321 stop '********** Program terminated normally.'
322 20 write (iout,*) "Error reading coordinates"
324 call MPI_Finalize(IERROR)
327 30 write (iout,*) "Error reading reference structure"
329 call MPI_Finalize(IERROR)
333 c---------------------------------------------------------------------------
334 double precision function difconf(icon,jcon)
337 include 'sizesclu.dat'
338 include 'COMMON.CONTROL'
339 include 'COMMON.CLUSTER'
340 include 'COMMON.CHAIN'
341 include 'COMMON.INTERACT'
343 include 'COMMON.IOUNITS'
345 double precision przes(3),obrot(3,3)
346 double precision xx(3,maxres2),yy(3,maxres2)
347 integer i,ii,j,icon,jcon,kkk,nperm,chalen,zzz
348 integer iaperm,ibezperm,run
349 double precision rms,rmsmina
350 c write (iout,*) "tu dochodze"
356 c write (iout,*) "nperm",nperm
358 c write (iout,*) "tabperm", tabperm(1,1)
362 chalen=int((nend-nstart+2)/symetr)
364 do i=nstart,(nstart+chalen-1)
366 c write (iout,*) "tutaj",zzz
368 iaperm=(zzz-1)*chalen+i
369 ibezperm=(run-1)*chalen+i
371 xx(j,ii)=allcart(j,iaperm,jcon)
372 yy(j,ii)=cref(j,ibezperm,kkk)
377 do i=nstart,(nstart+chalen-1)
380 iaperm=(zzz-1)*chalen+i
381 ibezperm=(run-1)*chalen+i
382 c if (itype(i).ne.10) then
385 xx(j,ii)=allcart(j,iaperm+nres,jcon)
386 yy(j,ii)=cref(j,ibezperm+nres,kkk)
391 call fitsq(rms,xx(1,1),yy(1,1),ii,przes,obrot,non_conv)
393 chalen=int((nct-nnt+2)/symetr)
395 do i=nnt,(nnt+chalen-1)
397 c write (iout,*) "tu szukaj", zzz,run,kkk
398 iaperm=(zzz-1)*chalen+i
399 ibezperm=(run-1)*chalen+i
402 c(j,i)=allcart(j,iaperm,jcon)
406 call fitsq(rms,c(1,nstart),cref(1,nstart,kkk),nend-nstart+1,
411 print *,'error, rms^2 = ',rms,icon,jcon
414 if (non_conv) print *,non_conv,icon,jcon
415 if (rmsmina.gt.rms) rmsmina=rms
417 difconf=dsqrt(rmsmina)
420 C------------------------------------------------------------------------------
421 subroutine distout(ncon)
424 include 'sizesclu.dat'
427 include 'COMMON.IOUNITS'
428 include 'COMMON.CLUSTER'
429 integer i,j,k,jlim,jlim1,nlim,ind,ioffset
432 write (iout,'(a)') 'The distance matrix'
434 nlim=min0(i+ncol-1,ncon)
435 write (iout,1000) (k,k=i,nlim)
436 write (iout,'(8h--------,10a)') ('-------',k=i,nlim)
437 1000 format (/8x,10(i4,3x))
438 1020 format (/1x,80(1h-)/)
449 IND=IOFFSET(NCON,j,k)
451 IND=IOFFSET(NCON,k,j)
454 write (iout,1010) j,(b(k),k=1,jlim-i+1)
457 1010 format (i5,3x,10(f6.2,1x))