一个DLA模型的Fortran代码,能编译,能运行,但是出来的结构不对。画出的图形除了中间有点外,四个角上也有点存在,不知道哪里有问题。希望各位虫友看看,不胜感激!
program dla
implicit none
parameter M=100
parameter N=100
parameter Particles=2000
integer :: A(M,N)
integer :: i, j, counter, p
real(4):: s, num1, num2, num3
open (30,file="dla2d.dat"
do i =1, M
do j=1, N
A(i,j)=0
enddo
enddo
A(50,50)=1
counter=0
do while (counter .LT. Particles)
counter=counter+1
write (*,*) 'Current Particles is ', counter
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.EQ.0)
call random_number(num3)
s = num3
if(s.LE.0.25) then
j=j+1
elseif(s.LE.0.50) then
j=j-1
elseif(s.LE. 0.75) then
i=i+1
else
i=i-1
endif
if (j.EQ.N+1) then
j=1
goto 55
endif
if (j.EQ.0) then
j=N
goto 55
endif
if (i .EQ. M+1) then
i=1
goto 55
endif
if (i.EQ.0) then
i=M
goto 55
endif
if(A(i,j-1).EQ.1.OR.A(i,j+1).EQ.1.OR.A(i+1,j).EQ.1.OR.A(i-1,j).EQ.1) then
A(i,j)=1
write(30,*) i, j
p=10
endif
enddo
enddo
end program dla
![]()
DLA结果 |