+
+ subroutine hmc_test(itime)
+ implicit real*8 (a-h,o-z)
+ include 'DIMENSIONS'
+ include 'COMMON.CONTROL'
+ include 'COMMON.MD'
+ include 'COMMON.CHAIN'
+
+ hmc_acc=hmc_acc+1
+ delta=-(potE+EK-hmc_etot)/(Rb*t_bath)
+ if (delta .lt. -50.0d0) then
+ delta=0.0d0
+ else
+ delta=dexp(delta)
+ endif
+ xxx=ran_number(0.0d0,1.0d0)
+
+ if (me.eq.king .or. .not. out1file)
+ & write(iout,'(a8,i5,6f10.4)')
+ & 'HMC',itime,potE+EK,potE,EK,hmc_etot,delta,xxx
+
+ if (delta .le. xxx) then
+ do i=1,2*nres
+ do j=1,3
+ dc(j,i)=dc_hmc(j,i)
+ enddo
+ enddo
+ itime=itime-hmc
+ totT=totThmc
+ else
+ if (me.eq.king .or. .not. out1file)
+ & write(iout,*) 'HMC accepting new'
+ totThmc=totT
+ do i=1,2*nres
+ do j=1,3
+ dc_hmc(j,i)=dc(j,i)
+ enddo
+ enddo
+ endif
+
+ call chainbuild_cart
+ call random_vel
+ do i=0,2*nres
+ do j=1,3
+ d_t_old(j,i)=d_t(j,i)
+ enddo
+ enddo
+ call kinetic(EK)
+ kinetic_T=2.0d0/(dimen3*Rb)*EK
+ call etotal(potEcomp)
+ potE=potEcomp(0)
+ hmc_etot=potE+EK
+ if (me.eq.king .or. .not. out1file)
+ & write(iout,'(a8,i5,3f10.4)')'HMC new',itime,potE+EK,potE,EK
+
+
+ return
+ end