real,allocatable::spin(:,:) c*** read init data open(10,file="ising.in") read (10,*)n,ta,tl,dt,niter n2=n*n sm=n2 allocate (spin(n,n)) c*** init spins ********* do i=1,n do j=1,n spin(i,j)=1. enddo enddo c*** clculations for different temperatures do t=ta,tl,dt ! temperature smag=0. do k=1,niter ! iterations do i=1,n ! spin rotation i1=i+1 i2=i-1 if(i.eq.1) i2=n if(i.eq.n) i1=1 do j=1,n !*** spin rotation spin0=spin(i,j) j1=j+1 j2=j-1 if(j.eq.1) j2=n if(j.eq.n) j1=1 de=2.*spin0*(spin(i,j1)+spin(i,j2)+spin(i1,j)+spin(i2,j)) c*** metropolis test******** if(de.lt.0.) then spin(i,j)=-spin0 sm=sm-2.*spin0 else ur=rand(0) if(exp(-de/t).ge.ur) then spin(i,j)=-spin0 sm=sm-2.*spin0 ! the new magnet momentum calculation endif endif c*** end the metropolis test ****** enddo enddo smag=smag+sm ! for average momentum calculaiton enddo ! end of ittertions print *,t,smag/(n2*niter) ! temperature and average momentum enddo ! different temperetures stop end !*** ising.in ************