[Fortran] 纯文本查看 复制代码
program dla
implicit none
parameter M=100
parameter N=100
parameter Particles=2000
integer::A(M,N)
integer::i, j, count, p
real*8::s,num1,num2,num3
open(13,file="dla.txt")
do i=1,M
do j=1,N
A(i,j)=0
end do
end do
A(50,50)=1
count=0
do while (cout<Particles)
count=count+1
write(*,*)'Current Particles is',count
call random_number(num1)
i=1+int(num1*(N-1))
call random_number(num2)
j=1+int(num2*(N-1))
p=0
55 do while(p==0)
call random_number(num3)
s=num3
if(s<=0.25) then
j=j+1
else if(s<=0.50) then
j=j-1
else if(s<=0.75) then
i=i+1
else
i=i-1
endif
if (j==N+1) then
j=1
goto 55
endif
if (j==0) then
j=N
goto 55
endif
if (i==M+1) then
i=1
goto 55
endif
if (i==0) then
i=M
goto 55
endif
if(A(i,j-1)==1.OR.A(i,j+1)==1.OR.A(i+1,j)==1.OR.A(i-1,j)==1) then
A(i,j)=1
write(30,*) i, j
p=10
endif
enddo
enddo
end program dla