program laplace real dimension 15 15 V1 real dimension 15 15 V2 do 15

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
program laplace
real, dimension(15,15) :: V1
real, dimension(15,15) :: V2
do I=1,15
do J=1,15
V1(I,J) = 1000*random(L)
end do
end do
do I=1,15
V1(1,I)=0.0
end do
do I=1,15
V1(I,1) = 0.0
end do
do I=1,15
V1(15,I)=0.0
end do
do I=1,15
V1(I,15)=100.0
end do
do M=1,50
do I=1,15
do J=1,15
V1(I,J) = (V1(I-1,J)+V1(I+1,J)+V1(I,J-1)+V1(I,J+1))/4
end do
end do
end do
do i=1,15
write(*,'(1X,100G14.5)') (V1(i,j),j=1,15)
end do
end program laplace
function random(L)
integer :: L
L = mod(1366*L+150889,714025)
Random=Real(L)/Real(7142024)
return
end