update new files
[unres.git] / source / cluster / wham / src-M / rmsnat.f
1       double precision function rmsnat(jcon)
2       implicit real*8 (a-h,o-z)
3       include 'DIMENSIONS'
4       include 'sizesclu.dat'
5       include 'DIMENSIONS.COMPAR'
6       include 'COMMON.IOUNITS'
7       include 'COMMON.CHAIN' 
8       include 'COMMON.INTERACT'
9       include 'COMMON.VAR'
10       include 'COMMON.CONTROL'
11       double precision przes(3),obrot(3,3),cc(3,2*maxres),
12      &   ccref(3,2*maxres)
13       logical non_conv
14       integer ishif,i,j,resprzesun
15       rminrms=10.0d10
16       rmsminsing=10d10
17       nperm=1
18 c      write (iout,*) "tu2", nres,nsup,nperm
19       noverlap=nres
20       if (nres.gt.nsup+nnt-1) noverlap=nsup+nnt-1
21 c      write (iout,*) "tu3,",noverlap
22       do i=1,symetr
23        nperm=nperm*i
24       enddo
25       do kkk=1,nperm
26        nnsup=0
27        do i=1,noverlap
28         if (itype(i).ne.ntyp1) then
29           nnsup=nnsup+1
30           do j=1,3
31             cc(j,nnsup)=c(j,i)
32             ccref(j,nnsup)=cref_pdb(j,i,kkk)
33           enddo
34 c          write (iout,'(i5,3f10.5,5x,3f10.5)') 
35 c     &     nnsup,(cc(j,nnsup),j=1,3),(ccref(j,nnsup),j=1,3)
36         endif
37        enddo
38        call fitsq(rms,cc(1,1),ccref(1,1),nnsup,przes,obrot,non_conv)
39        if (non_conv) then
40         print *,'Error: FITSQ non-convergent, jcon',jcon,i
41         rms=1.0d10
42        else if (rms.lt.-1.0d-6) then 
43         print *,'Error: rms^2 = ',rms,jcon,i
44         rms = 1.0d10
45        else if (rms.ge.1.0d-6 .and. rms.lt.0) then
46         rms=0.0d0
47        endif
48        if (rms.le.rminrms) rminrms=rms
49 c       write (iout,*) "kkk",kkk," rmsnat",rms , rminrms
50       enddo
51       rmsnat = dsqrt(rminrms)
52 C      write (iout,*)  "analysys",rmsnat, anatemp
53 C      liczenie rmsdla pojedynczego lancucha
54       return
55       end
56 c-----------------------------------------------------------------------------
57       double precision function gyrate(jcon)
58       implicit real*8 (a-h,o-z)
59       include 'DIMENSIONS'
60       include 'COMMON.INTERACT'
61       include 'COMMON.CHAIN'
62       double precision cen(3),rg
63
64       do j=1,3
65        cen(j)=0.0d0
66       enddo
67
68       do i=nnt,nct
69           do j=1,3
70             cen(j)=cen(j)+c(j,i)
71           enddo
72       enddo
73       do j=1,3
74             cen(j)=cen(j)/dble(nct-nnt+1)
75       enddo
76       rg = 0.0d0
77       do i = nnt, nct
78         do j=1,3
79          rg = rg + (c(j,i)-cen(j))**2
80         enddo
81       end do
82       gyrate = dsqrt(rg/dble(nct-nnt+1))
83       return
84       end