+ ecorr=enetb(4,i)
+ ecorr5=enetb(5,i)
+ ecorr6=enetb(6,i)
+ eel_loc=enetb(7,i)
+ eello_turn3=enetb(8,i)
+ eello_turn4=enetb(9,i)
+ eturn6=enetb(10,i)
+ ebe=enetb(11,i)
+ escloc=enetb(12,i)
+ etors=enetb(13,i)
+ etors_d=enetb(14,i)
+ ehpb=enetb(15,i)
+ estr=enetb(18,i)
+ esccor=enetb(19,i)
+ edihcnstr=enetb(20,i)
+ evdw_t=enetb(21,i)
+ eliptran=enetb(22,i)
+ ehomology_constr=enetb(24,i)
+ esaxs=enetb(25,i)
+ if (rescale_mode.eq.1) then
+ quot=1.0d0/(T0*beta_h(ib)*1.987D-3)
+ quotl=1.0d0
+ kfacl=1.0d0
+ do l=1,5
+ quotl1=quotl
+ quotl=quotl*quot
+ kfacl=kfacl*kfac
+ fT(l)=kfacl/(kfacl-1.0d0+quotl)
+ enddo
+#if defined(FUNCTH)
+ ft(6)=(320.0d0+80.0d0*dtanh((betaT-320.0d0)/80.0d0))/
+ & 320.0d0
+ ftprim(6)=1.0d0/(320.0d0*dcosh((betaT-320.0d0)/80.0d0)**2)
+ ftbis(6)=-2.0d0*dtanh((betaT-320.0d0)/80.0d0)
+ & /(320.0d0*80.0d0*dcosh((betaT-320.0d0)/80.0d0)**3)
+#elif defined(FUNCT)
+ fT(6)=betaT/T0
+ ftprim(6)=1.0d0/T0
+ ftbis(6)=0.0d0
+#else
+ fT(6)=1.0d0
+ ftprim(6)=0.0d0
+ ftbis(6)=0.0d0
+#endif
+
+ else if (rescale_mode.eq.2) then
+ quot=1.0d0/(T0*beta_h(ib)*1.987D-3)
+ quotl=1.0d0
+ do l=1,5
+ quotl=quotl*quot
+ fT(l)=1.12692801104297249644d0/
+ & dlog(dexp(quotl)+dexp(-quotl))
+ enddo
+c write (iout,*) 1.0d0/(beta_h(ib)*1.987D-3),ft
+c call flush(iout)
+#if defined(FUNCTH)
+ ft(6)=(320.0d0+80.0d0*dtanh((betaT-320.0d0)/80.0d0))/
+ & 320.0d0
+ ftprim(6)=1.0d0/(320.0d0*dcosh((betaT-320.0d0)/80.0d0)**2)
+ ftbis(6)=-2.0d0*dtanh((betaT-320.0d0)/80.0d0)
+ & /(320.0d0*80.0d0*dcosh((betaT-320.0d0)/80.0d0)**3)
+#elif defined(FUNCT)
+ fT(6)=betaT/T0
+ ftprim(6)=1.0d0/T0
+ ftbis(6)=0.0d0
+#else
+ fT(6)=1.0d0
+ ftprim(6)=0.0d0
+ ftbis(6)=0.0d0
+#endif
+ endif
+c write (iout,*) 1.0d0/(beta_h(ib)*1.987D-3),ft
+c call flush(iout)
+c call etotal(energia(0),fT)
+c#ifdef CHUJ
+#ifdef SPLITELE
+ if (shield_mode.gt.0) then
+ etot=ft(1)*wsc*(evdw+ft(6)*evdw_t)+ft(1)*wscp*evdw2
+ & +welec*ft(1)*ees
+ & +ft(1)*wvdwpp*evdw1
+ & +wang*ebe+wtor*ft(1)*etors+wscloc*escloc
+ & +wstrain*ehpb+wcorr*ft(3)*ecorr+wcorr5*ft(4)*ecorr5
+ & +wcorr6*ft(5)*ecorr6+wturn4*ft(3)*eello_turn4
+ & +wturn3*ft(2)*eello_turn3+wturn6*ft(5)*eturn6
+ & +wel_loc*ft(2)*eel_loc+edihcnstr+wtor_d*ft(2)*etors_d
+ & +wbond*estr+wsccor*ft(1)*esccor+!ethetacnstr
+ & +wliptran*eliptran+wsaxs*esaxs
+ else
+ etot=wsc*(evdw+ft(6)*evdw_t)+wscp*evdw2+welec*ft(1)*ees
+ & +wvdwpp*evdw1
+ & +wang*ebe+wtor*ft(1)*etors+wscloc*escloc
+ & +wstrain*ehpb+wcorr*ft(3)*ecorr+wcorr5*ft(4)*ecorr5
+ & +wcorr6*ft(5)*ecorr6+wturn4*ft(3)*eello_turn4
+ & +wturn3*ft(2)*eello_turn3+wturn6*ft(5)*eturn6
+ & +wel_loc*ft(2)*eel_loc+edihcnstr+wtor_d*ft(2)*etors_d
+ & +wbond*estr+wsccor*ft(1)*esccor+ehomology_constr
+ & +wliptran*eliptran+wsaxs*esaxs
+ endif
+#else
+ if (shield_mode.gt.0) then
+ etot=ft(1)*wsc*(evdw+ft(6)*evdw_t)+ft(1)*wscp*evdw2
+ & +welec*ft(1)*(ees+evdw1)
+ & +wang*ebe+wtor*ft(1)*etors+wscloc*escloc
+ & +wstrain*ehpb+wcorr*ft(3)*ecorr+wcorr5*ft(4)*ecorr5
+ & +wcorr6*ft(5)*ecorr6+wturn4*ft(3)*eello_turn4
+ & +wturn3*ft(2)*eello_turn3+wturn6*ft(5)*eturn6
+ & +wel_loc*ft(2)*eel_loc+edihcnstr+wtor_d*ft(2)*etors_d
+ & +wbond*estr+wsccor*ft(1)*esccor+ehomology_constr
+ & +wliptran*eliptran+wsaxs*esaxs
+ else
+ etot=wsc*(evdw+ft(6)*evdw_t)+wscp*evdw2
+ & +welec*ft(1)*(ees+evdw1)
+ & +wang*ebe+wtor*ft(1)*etors+wscloc*escloc
+ & +wstrain*ehpb+wcorr*ft(3)*ecorr+wcorr5*ft(4)*ecorr5
+ & +wcorr6*ft(5)*ecorr6+wturn4*ft(3)*eello_turn4
+ & +wturn3*ft(2)*eello_turn3+wturn6*ft(5)*eturn6
+ & +wel_loc*ft(2)*eel_loc+edihcnstr+wtor_d*ft(2)*etors_d
+ & +wbond*estr+wsccor*ft(1)*esccor+!ethetacnstr
+ & +wliptran*eliptran+wsaxs*esaxs
+ endif
+#endif
+#ifdef DEBUG
+ write (iout,*) "etot2", etot
+ write (iout,*) "evdw", wsc, evdw,evdw_t
+ write (iout,*) "evdw2", wscp, evdw2
+ write (iout,*) "welec", ft(1),welec,ees
+ write (iout,*) "evdw1", wvdwpp,evdw1
+ write (iout,*) "ebe", ebe,wang
+#endif