next up previous index
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 $\nabla^2 T(x, y) = 0$ with fixed boundary conditions, but on a much larger data set, $200\times200$. 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



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