PROGRAM Poisson_equation_in_2D parameter (kx= 40 ,ky= 40 ) integer ::i,j,k real ::rho(kx,ky),V(kx,ky),R(kx,ky),d open ( 1 , file ='poisson input', status ='unknown') open ( 2 , file ='poisson output', status ='unknown') read ( 1 ,*)((rho(i,j),j= 1 ,ky),i= 1 ,kx) k= 0 d= 0 . 025 do i= 1 ,kx do j= 1 ,ky V(i,j)= 0 . 0 enddo enddo 4 do i= 2 ,kx- 1 do j= 2 ,ky- 1 R(i,j)=V(i+ 1 ,j)+V(i- 1 ,j)+V(i,j+ 1 )+V(i,j- 1 )- 4 *V(i,j)+rho(i,j)*d** 2 enddo enddo do i= 2 ,kx- 1 do j= 2 ,ky- 1 if ( abs (R(i,j))> 0 . 0000001 ) goto 3 enddo enddo goto 5 3 k=k+ 1 do i= 2 ,kx- 1 do j= 2 ,ky- 1 V(i,j)=V(i,j)+ 0 . 25 *R(i,j) enddo enddo goto 4 5 write (*, 6 )k do i= 1 ,kx+ 1 do j= 1 ,ky+ 1 write ( 2 , 7 )i,j,V(i,j) enddo enddo 6 format ('no of Iteration=',i5) 7 format (i2,1x,i2,1x,f7. 5 ) end