
\documentstyle{article}

\textwidth=6.0in
\textheight=8.5in
\topmargin=-0.5in
% \oddsidemargin=0.25in

\begin{document}

\pagestyle{empty}

{\small


\begin{verbatim}
C----------------------------------------------------------------------C
C       Metropolis Monte Carlo update of the Ising model               C
C       in Express Fortran (Fortran with message passing).             C
C                                                                      C
C   As long as size is >=2, don't need to do a red/black checkerboard  C
C   update, since sites being updated simultaneously on different      C
C   processors will not be neighbors.                                  C
C----------------------------------------------------------------------C

      SUBROUTINE metupdate()
      INCLUDE "common.h"
      INTEGER n,i,j, shift()
      INTEGER old_spin, new_spin, spin1,spin2,spin3,spin4
      INTEGER spin_sum, old_energy, new_energy, energy_diff
      REAL random()    
	
      DO i=1,size
      DO j=1,size

          old_spin = spin(i,j)
          new_spin = -old_spin
C
C ------  Get neighboring spins.
C
          spin1 = shift(i-1,j)
          spin2 = shift(i+1,j)
          spin3 = shift(i,j-1)
          spin4 = shift(i,j+1)
C
C ------  Sum neighboring spins to get energy.
C
          spin_sum = spin1 + spin2 + spin3 + spin4
          old_energy = old_spin * spin_sum
          new_energy = - old_energy
          energy_diff = new_energy - old_energy
C
C ------  Metropolis accept/reject step.
C
          IF ( ( energy_diff.LE.0 ) .OR.
     &         ( EXP(-beta*energy_diff).GT.random() ) ) THEN
             spin(i,j) = new_spin
          ENDIF

      ENDDO
      ENDDO

      RETURN 
      END
\end{verbatim}

\protect\vfill
\centerline{CPS-MC-68} 

}

\end{document}

