Monte Carlo algorithm implemented in fortran90