[Fortran] 纯文本查看 复制代码
USE DFLIB
integer,PARAMETER::IR=400
integer,parameter::JR=400
INTEGER IS(0:IR+1,0:JR+1),TMAX,ISN(1:8),NSTATE,T,NR,IX,IY
WRITE(*,*)"PLEASE INPUT THE TIME STEP "
READ(*,*)TMAX
ISEED=RTC()
IRC=IR/2
JRC=JR/2
R=MIN(IRC,JRC)-10
IS=1
DO I=1,IR
DO J=1,JR
DISTANCE=SQRT(1.0*(I-IRC)**2+1.0*(J-JRC)**2)
IF(DISTANCE.LT.R)IS(I,J)=2
ISE=SETCOLOR(IS(I,J))
ISE=SETPIXEL(I,J)
END DO
END DO
OPEN(1,FILE="E:\LUKE.DAT")
!
DO T=1,TMAX
DO X=1,IR
DO Y=1,JR
IX=IR*RAN(ISEED)+1
JY=JR*RAN(ISEED)+1
ISN=(/IS(IX-1,JY-1),IS(IX-1,JY),IS(IX-1,JY+1),IS(IX,JY-1) ,IS(IX,JY+1),IS(IX+1,JY-1),IS(IX+1,JY),IS(IX+1,JY+1)/)
E0=COUNT(ISN.NE.IS(IX,JY))
IF(E0.EQ.0)CYCLE
NR=8*RAN(ISEED)+1
NSTATE=ISN(NR)
E=COUNT(ISN.NE.NSTATE)
RD=RAN(ISEED)
DE=E-E0+NSTATE-IS(IX,JY)+2.5*RD-1.25
IF(DE.LT.0.0)IS(IX,JY)=NSTATE
ISRE=SETCOLOR(IS(IX,JY))
ISRE=SETPIXEL(IX,JY)
ENDDO
ENDDO
WRITE(1,*)T,COUNT(IS.EQ.2)
ENDDO
CLOSE(1)
stop
END