readpdb correction
[unres.git] / source / unres / src-HCD-5D / readpdb-mult.F
index cc9aec9..4c47572 100644 (file)
@@ -19,7 +19,7 @@ C geometry.
       double precision sccor(3,50)
       double precision e1(3),e2(3),e3(3)
       integer rescode,iterter(maxres),cou
-      logical fail
+      logical fail,sccalc
       integer i,j,iii,ires,ires_old,ishift,ishift1,ibeg
       double precision dcj,efree_temp
       bfac=0.0d0
@@ -32,6 +32,7 @@ C geometry.
       nhfrag=0
       nbfrag=0
       iii=0
+      sccalc=.false.
       do
         read (ipdbin,'(a80)',end=10) card
 c        write (iout,'(a)') card
@@ -72,11 +73,13 @@ c        write (iout,'(a)') card
             call sccenter(ires,iii,sccor)
           endif
           iii=0
+          sccalc=.true.
         endif
 ! Read free energy
         if (index(card,"FREE ENERGY").gt.0) read(card(35:),*) efree_temp
 ! Fish out the ATOM cards.
         if (index(card(1:4),'ATOM').gt.0) then  
+          sccalc=.false.
           read (card(12:16),*) atom
 c          write (2,'(a)') card
 c          write (iout,*) "ibeg",ibeg
@@ -101,6 +104,7 @@ c              write (iout,*) "Calculating sidechain center iii",iii
                 call sccenter(ires_old,iii,sccor)
               endif
               iii=0
+              sccalc=.true.
             endif
 ! Start new residue.
             if (res.eq.'Cl-' .or. res.eq.'Na+') then
@@ -200,6 +204,7 @@ C 2/15/2013 by Adam: corrected insertion of the last dummy residue
             if (dcj.eq.0) dcj=1.23591524223
              c(j,i)=c(j,i-1)+dcj
              c(j,nres+i)=c(j,i)
+             dC(j,i)=c(j,i)
            enddo     
           endif   !unres_pdb
          else     !itype(i+1).eq.ntyp1
@@ -220,6 +225,7 @@ C 2/15/2013 by Adam: corrected insertion of the first dummy residue
             if (dcj.eq.0) dcj=1.23591524223
             c(j,i)=c(j,i+1)-dcj
             c(j,nres+i)=c(j,i)
+            dC(j,i)=c(j,i)
            enddo
           endif !unres_pdb
          endif !itype(i+1).eq.ntyp1
@@ -227,6 +233,7 @@ C 2/15/2013 by Adam: corrected insertion of the first dummy residue
       enddo
       write (iout,*) "After loop in readpbd"
 C Calculate the CM of the last side chain.
+      if (.not. sccalc) then
       if (unres_pdb) then
         do j=1,3
           dc(j,ires)=sccor(j,iii)
@@ -235,6 +242,7 @@ C Calculate the CM of the last side chain.
 c        write (iout,*) "Calling sccenter iii",iii
         call sccenter(ires,iii,sccor)
       endif
+      endif
       nsup=nres
       nstart_sup=1
       if (itype(nres).ne.10) then
@@ -302,8 +310,8 @@ C Calculate internal coordinates.
      &    restyp(itype(ires)),ires,(c(j,ires),j=1,3),
      &    (c(j,ires+nres),j=1,3)
       enddo
-      endif
       call flush(iout)
+      endif
 c      write(iout,*)"before int_from_cart nres",nres
       call int_from_cart(.true.,.false.)
       do i=1,nres