Next: More about Parallel execution Up: Fields Previous: Parallel Execution

## Fields and Rasters

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 • The program can be compiled and linked using our 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 $• To run it, simply type 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
...

• At the end of the run, which may take some time, you will find a file movie.hdf in your working directory.
• You can view the animation with   NCSA collage:
• Invoke collage by typing
gustav@blanc:../src 15:03:41 !625 \$ collage &

• Pull down the File menu and select Open Animation.
• You'll get a pop-up window with file names in the right panel. Find movie.hdf there and double click on it.
• Another window will appear showing the contents of the file. Click on the RIG radio button first.
• Then click on the first image, scroll the contents window to the end and click on the last image while holding the shift key. This should select all images in the animation.
• Pull down the Transport menu and select Send Selection. There is nothing else there to select anyway.
• This will bring up an animation window with tape recorder controls, which you can use to view the progres of Jacobi iterations.
• Observe that the iterations are quite fast initially, but slow down markedly towards the end.
• Select Options/Play Mode/Continuous Bounce, restart the animation and slow it down using the little scroll-bar on the right hand side.

Next: More about Parallel execution Up: Fields Previous: Parallel Execution
Zdzislaw Meglicki
2001-02-26