SUBROUTINE Metropolis(x,delta,naccept) IMPLICIT NONE REAL*8 w, xtrial, x, delta REAL rnd INTEGER naccept xtrial = x + delta*(2*rnd(0) - 1) w = p(xtrial)/p(x) IF(rnd(0) .LE. w) THEN x = xtrial naccept = naccept + 1 ! number of acceptances END IF END