!
! *****************************************************************
! *                                                               *
! *    Copyright (c) Digital Equipment Corporation, 1995          *
! *                                                               *
! *   All Rights Reserved.  Unpublished rights  reserved  under   *
! *   the copyright laws of the United States.                    *
! *                                                               *
! *   The software contained on this media  is  proprietary  to   *
! *   and  embodies  the  confidential  technology  of  Digital   *
! *   Equipment Corporation.  Possession, use,  duplication  or   *
! *   dissemination of the software and media is authorized only  *
! *   pursuant to a valid written license from Digital Equipment  *
! *   Corporation.                                                *
! *                                                               *
! *   RESTRICTED RIGHTS LEGEND   Use, duplication, or disclosure  *
! *   by the U.S. Government is subject to restrictions  as  set  *
! *   forth in Subparagraph (c)(1)(ii)  of  DFARS  252.227-7013,  *
! *   or  in  FAR 52.227-19, as applicable.                       *
! *                                                               *
! *****************************************************************
!
!
! HISTORY
!
! $RCSfile: heat_example.f90,v $ $Revision: 1.1.2.5 $ (DEC) $Date: 1995/04/12 13:13:21 $
!
!
! *****************************************************************
! *                                                               *
! *    Copyright (c) Digital Equipment Corporation, 1994          *
! *                                                               *
! *   All Rights Reserved.  Unpublished rights  reserved  under   *
! *   the copyright laws of the United States.                    *
! *                                                               *
! *   The software contained on this media  is  proprietary  to   *
! *   and  embodies  the  confidential  technology  of  Digital   *
! *   Equipment Corporation.  Possession, use,  duplication  or   *
! *   dissemination of the software and media is authorized only  *
! *   pursuant to a valid written license from Digital Equipment  *
! *   Corporation.                                                *
! *                                                               *
! *   RESTRICTED RIGHTS LEGEND   Use, duplication, or disclosure  *
! *   by the U.S. Government is subject to restrictions  as  set  *
! *   forth in Subparagraph (c)(1)(ii)  of  DFARS  252.227-7013,  *
! *   or  in  FAR 52.227-19, as applicable.                       *
! *                                                               *
! *****************************************************************
!
!
! HISTORY
!
! $RCSfile: heat_example.f90,v $ $Revision: 1.1.2.5 $ (DEC) $Date: 1995/04/12 13:13:21 $
!

program heat_test
  implicit none
  integer, parameter :: n = 500, number_of_iterations = 205
  integer i, j, k
  real, dimension(n, n)             :: slab
    !hpf$ distribute (*, block)     :: slab
  real t0, t1

  slab = 10				! Initialize array
  slab(ubound(slab, dim=1),:) = 100	! South edge
  slab(lbound(slab, dim=1),:) = 0	! North edge
  slab(:, ubound(slab, dim=2)) = 50	! East edge
  slab(:, lbound(slab, dim=2)) = 50	! West edge

  t0 = secnds(0.0)  
  call Jacobi
  t1 = secnds(t0)

  print *, "Elapsed time for Jacobi subroutine = ", t1, " seconds"

contains
  subroutine Jacobi
    do k = 1, number_of_iterations
      forall (i=2:size(slab, dim=1)-1, j=2:size(slab, dim=2)-1)
        slab(i, j) = (slab(i, j-1)+slab(i-1, j)+slab(i+1, j)+slab(i, j+1))/4
      end forall
    end do
  end subroutine Jacobi

end program heat_test
