arcos = 0.5D0*(PI-DSIGN(1.0D0,X)*PI)
[unres.git] / source / xdrfpdb / src / xdrf2pdb.F
index c87e9ff..1f7ce8e 100644 (file)
@@ -3,6 +3,7 @@
       include 'COMMON.CHAIN'
       include 'COMMON.INTERACT'
       include 'COMMON.SBRIDGE'
+      include 'COMMON.DISTFIT'
       real*4 coord(3,2*maxres)
       real*4 prec,time,potE,uconst,t_bath,qfrag(100)
       real*8 etot
@@ -17,6 +18,7 @@
       external rescode
       logical iblnk
       external iblnk
+      double precision cm(3)
       
       ifreq=1
       is=1
       if (itype(nres).eq.21) nct = nres-1
       print *,"nnt",nnt," nct",nct
       print *,"file",arg
+      do i=nnt,nct
+        if (itype(i).ne.20) then
+          itel(i)=1
+        else
+          itel(i)=2
+        endif 
+      enddo
       call xdrfopen(ixdrf,arg, "r", iret)
       if (iret.eq.0) stop
-      print *,"iret",iret
-      print *,"is",is," ie",ie
+c      print *,"iret",iret
+c      print *,"is",is," ie",ie
       kk = 0
       do while(is.eq.0 .or. kk.lt.ie) 
        call xdrffloat(ixdrf, time, iret)
-       print *,"time",time," iret",iret
+c       print *,"time",time," iret",iret
        if(iret.eq.0) exit
        kk = kk + 1
        call xdrffloat(ixdrf, potE, iret)
        call xdrffloat(ixdrf, uconst, iret)
-       print *,"potE",potE," uconst",uconst
+c       print *,"potE",potE," uconst",uconst
 #ifdef NEWUNRES
        call xdrffloat(ixdrf, uconst_back, iret)
+c       print *,"uconst_back",uconst_back
 #endif
-       print *,"uconst_back",uconst_back
        call xdrffloat(ixdrf, t_bath, iret)
-       print *,"t_bath",t_bath
+c       print *,"t_bath",t_bath
        call xdrfint(ixdrf, nss, iret) 
        do j=1,nss
         call xdrfint(ixdrf, ihpb(j), iret)
         call xdrfint(ixdrf, jhpb(j), iret)
        enddo
-       print *,"nss",nss
+c       print *,"nss",nss
+c       print *,"   ",(ihpb(j),"-",jhpb(j),j=1,nss)
        call xdrfint(ixdrf, nfrag, iret)
        do i=1,nfrag
         call xdrffloat(ixdrf, qfrag(i), iret)
        enddo
-       print *,"nfrag",nfrag
+c       print *,"nfrag",nfrag
        prec=10000.0
 
        isize=0
@@ -149,8 +159,25 @@ c       write (*,'(8f10.5)') ((coord(k,j),k=1,3),j=1,isize)
              c(j,i+nres)=coord(j,ii+nres)
            enddo
          enddo
+c Calculate the CM
+         do j=1,3
+           cm(j)=0.0d0
+           do i=1,nres
+             cm(j)=cm(j)+c(j,i)
+           enddo
+           cm(j)=cm(j)/nres
+         enddo
+         do i=1,nres
+           do j=1,3
+             c(j,i)=c(j,i)-cm(j)
+             c(j,i+nres)=c(j,i+nres)-cm(j)
+           enddo
+         enddo
          etot=potE
          write (tytul,'(a,i6)') "Structure",kk
+#ifdef SECONDARY
+         call secondary2(.false.)
+#endif
          call pdbout(etot,tytul,9)
        endif
       enddo