-C Fish out the ATOM cards.
-c if (index(card(1:4),'ATOM').gt.0) then
-c read (card(14:16),'(a3)') atom
-c if (atom.eq.'CA' .or. atom.eq.'CH3') then
-C Calculate the CM of the preceding residue.
- read (card(23:26),*) ires
- read (card(18:20),'(a3)') res
- if (ires-ishift+ishift1.ne.ires_old) then
- if (ibeg.eq.0) then
- if (unres_pdb) then
- do j=1,3
- dc(j,ires+nres)=sccor(j,iii)
- enddo
+! 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
+c write (iout,*) "! ",atom," !",ires
+! if (atom.eq.'CA' .or. atom.eq.'CH3') then
+ read (card(23:26),*) ires
+ read (card(18:20),'(a3)') res
+c write (iout,*) "ires",ires,ires-ishift+ishift1,
+c & " ires_old",ires_old
+c write (iout,*) "ishift",ishift," ishift1",ishift1
+c write (iout,*) "IRES",ires-ishift+ishift1,ires_old
+ if (ires-ishift+ishift1.ne.ires_old) then
+! Calculate the CM of the preceding residue.
+! if (ibeg.eq.0) call sccenter(ires,iii,sccor)
+ if (ibeg.eq.0) then
+c write (iout,*) "Calculating sidechain center iii",iii
+ if (unres_pdb) then
+ do j=1,3
+ dc(j,ires+nres)=sccor(j,iii)
+ enddo
+ else
+ call sccenter(ires_old,iii,sccor)
+ endif
+ iii=0
+ sccalc=.true.
+ endif
+! Start new residue.
+ if (res.eq.'Cl-' .or. res.eq.'Na+') then
+ ires=ires_old
+ cycle
+ else if (ibeg.eq.1) then
+c write (iout,*) "BEG ires",ires
+ ishift=ires-1
+ if (res.ne.'GLY' .and. res.ne. 'ACE') then
+ ishift=ishift-1
+ itype(1)=ntyp1
+ endif
+ ires=ires-ishift+ishift1
+ ires_old=ires
+! write (iout,*) "ishift",ishift," ires",ires,&
+! " ires_old",ires_old
+ ibeg=0
+ else if (ibeg.eq.2) then
+! Start a new chain
+ ishift=-ires_old+ires-1 !!!!!
+ ishift1=ishift1-1 !!!!!
+c write (iout,*) "New chain started",ires,ishift,ishift1,"!"
+ ires=ires-ishift+ishift1
+ ires_old=ires
+ ibeg=0