In this section we're going to repeat the Jacobi iteration of
the Laplace equation
with fixed
boundary conditions, but on a much larger data set,
.
The answer is too large to print. Instead we'll use HDF libraries
to create an animation file.
Here's the new program:
program jacobi
use hdf
use dffunc
implicit none
!hpf$ nosequence
integer, parameter :: n = 200, iterations = 20000
real, dimension(n), parameter :: north_boundary = 30.0, &
east_boundary = 160.0, west_boundary = 160.0, south_boundary = 250.0
real, dimension(n, n) :: field = 30.0
integer :: i, j, status
character(len=1), dimension(n, n) :: raster
logical, dimension(n, n) :: mask = .true.
!hpf$ align mask(:,:) with field
!hpf$ distribute (*, block) :: field
field(ubound(field, dim=1), :) = east_boundary
mask(ubound(mask, dim=1), :) = .false.
field(lbound(field, dim=1), :) = west_boundary
mask(lbound(mask, dim=1), :) = .false.
field(:, ubound(field, dim=2)) = north_boundary
mask(:, ubound(mask, dim=2)) = .false.
field(:, lbound(field, dim=2)) = south_boundary
mask(:, lbound(mask, dim=2)) = .false.
raster=char(int(field))
status=d8pimg('movie.hdf', raster, n, n, COMP_RLE)
do i = 1, iterations
where (mask)
field = (eoshift(field, 1, dim=1) + eoshift(field, -1, dim=1) &
+ eoshift(field, 1, dim=2) + eoshift(field, -1, dim=2)) * 0.25
end where
if (mod(i, 200) .eq. 0) then
raster = char(int(field))
status = d8aimg('movie.hdf', raster, n, n, comp_rle)
write(*,*) i, ' -> ', (ichar(raster(j, 10)), j = 1, 5), &
(ichar(raster(j, 10)), j=96, 105), &
(ichar(raster(j, 10)), j=196, 200)
end if
end do
end program jacobi
Makefile as follows (under Solaris):
gustav@blanc:../src 14:57:42 !612 $ make jacobi-raster f90 -g -c -M/afs/ovpit.indiana.edu/@sys/HDF/modules jacobi-raster.f90 f90 -g -o jacobi-raster jacobi-raster.o \ -L/afs/ovpit.indiana.edu/@sys/HDF/lib \ -lmfhdf -lnsl -ldf -ljpeg -lz -lm rm jacobi-raster.o gustav@blanc:../src 14:57:52 !613 $
gustav@blanc:../src 15:00:09 !617 $ ./jacobi-raster
200 -> 160, 157, 155, 152, 150, 111, 111, 111, 111, 111, 111, \
111, 111, 111, 111, 150, 152, 155, 157, 160
400 -> 160, 161, 163, 164, 165, 145, 145, 145, 145, 145, 145, \
145, 145, 145, 145, 165, 164, 163, 161, 160
600 -> 160, 163, 166, 169, 171, 162, 162, 162, 162, 162, 162, \
162, 162, 162, 162, 171, 169, 166, 163, 160
...
movie.hdf in your working directory.
collage:
gustav@blanc:../src 15:03:41 !625 $ collage &
File menu and select
Open Animation.
movie.hdf there
and double click on it.
RIG radio button
first.
Transport menu and select
Send Selection. There is nothing else there
to select anyway.
Options/Play Mode/Continuous Bounce,
restart the animation and slow it down using the little
scroll-bar on the right hand side.