update new files
[unres.git] / source / maxlik / src_FPy.org / rmscalc.f
1       double precision function rmsnat(ib,jcon,iref,iprot)
2       implicit none
3       include 'DIMENSIONS'
4       include 'DIMENSIONS.ZSCOPT'
5       include 'COMMON.IOUNITS'
6       include 'COMMON.COMPAR'
7       include 'COMMON.CHAIN' 
8       include 'COMMON.INTERACT'
9       include 'COMMON.VAR'
10       double precision creff(3,maxres2),cc(3,maxres2)
11       double precision przes(3),obrot(3,3)
12       logical non_conv
13       integer ishif,i,ii,j,jcon,ib,iref,iprot
14       double precision rms
15       if (caonly(iprot)) then
16         call fitsq(rms,c(1,nstart_sup(iprot)),cref(1,nstart_sup(iprot),
17      &  iref,ib,iprot),nsup(iprot),przes,obrot,non_conv)
18       else if (sconly(iprot)) then
19         call fitsq(rms,c(1,nstart_sup(iprot)+nres),
20      &    cref(1,nstart_sup(iprot)+nres,iref,ib,
21      &    iprot),nsup(iprot),przes,obrot,non_conv)
22       else
23         ii=0
24         do i=nstart_sup(iprot),nend_sup(iprot)
25           ii=ii+1
26           do j=1,3
27             cc(j,ii)=c(j,i)
28             creff(j,ii)=cref(j,i,iref,ib,iprot)
29           enddo
30         enddo
31         do i=nstart_sup(iprot),nend_sup(iprot)
32           if (itype(i).ne.10 .and. itype(i).ne.21) then
33             ii=ii+1
34             do j=1,3
35               cc(j,ii)=c(j,i+nres)
36               creff(j,ii)=cref(j,i+nres,iref,ib,iprot)
37             enddo
38           endif
39         enddo
40         call fitsq(rms,cc(1,1),creff(1,1),ii,przes,obrot,non_conv)
41       endif
42       if (non_conv) then
43         print *,'Error: FITSQ non-convergent, jcon',jcon
44         rmsnat=1.0d2
45       else if (rms.lt.-1.0d-6) then 
46         print *,'Error: rms^2 = ',rms,jcon
47         rmsnat = 1.0d2
48       else if (rms.ge.1.0d-6 .and. rms.lt.0) then
49         rmsnat=0.0d0
50       else 
51         rmsnat = dsqrt(rms)
52       endif
53       return
54       end