Adam's changes
[unres.git] / source / unres / src-HCD-5D / readpdb-mult.F
index cc9aec9..40bf9ac 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
@@ -296,14 +304,14 @@ C Calculate internal coordinates.
       write (iout,'(/a)')
      &  "Cartesian coordinates of the reference structure"
       write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
-     & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
+     & "Residue ","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
       do ires=1,nres
-        write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
+        write (iout,'(a3,1x,i4,3f8.3,5x,3f8.3)')
      &    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
@@ -338,9 +346,9 @@ C Copy the coordinates to reference coordinates
       enddo
   100 format (//'              alpha-carbon coordinates       ',
      &          '     centroid coordinates'/
-     1          '       ', 6X,'X',11X,'Y',11X,'Z',
+     1          '       ', 7X,'X',11X,'Y',11X,'Z',
      &                          10X,'X',11X,'Y',11X,'Z')
-  110 format (a,'(',i3,')',6f12.5)
+  110 format (a,'(',i4,')',6f12.5)
 cc enddiag
       do j=1,nbfrag     
         do i=1,4                                                       
@@ -636,9 +644,9 @@ C Calculate internal coordinates.
       write (iout,'(/a)') 
      &  "Cartesian coordinates of the reference structure"
       write (iout,'(a,3(3x,a5),5x,3(3x,a5))') 
-     & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
+     & "Residue ","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
       do ires=1,nres
-        write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)') 
+        write (iout,'(a3,1x,i4,3f8.3,5x,3f8.3)') 
      &    restyp(itype(ires)),ires,(c(j,ires),j=1,3),
      &    (c(j,ires+nres),j=1,3)
       enddo