c
c###################################################################
c                  tempCalcRoutines.f
c###################################################################
c
c  Creator : Chris Anderson
c  (C) UCLA 1997  7/16/97
c
c###################################################################
c
       subroutine inittemp(T, m, n, a, b, c, d)
       implicit real*8 (a-h,o-z)
       integer*4 m,n
       real*8 T(m,n)

       hx = (b-a)/(m-1.0)
       hy = (d-c)/(n-1)

       do 50 i = 1,m
       x = a + i*hx
       do 50 j = 1,n
       y = c + j*hy
       T(i,j) = sin(4.0d00*x*y)
50     continue

      do 75 i = 1,m
      T(i,1) = 0.0
      T(i,n) = 0.0
75    continue

      do 100 j = 1,n
      T(1,j)   = 0.0
      T(m,j)   = 0.0
100   continue

      return
      end

      subroutine evtemp(T, m,  n, a,  b, c, d, dt, diffusivity, W)
      implicit real*8 (a-h,o-z)
      integer*4 m,n
      real*8 T(m,n)
      real*8 W(m,n)
c
c      Evolve using Forward Euler timestepping
c
       hx = (b-a)/(m-1)
       hy = (d-c)/(n-1)

       do 100 i = 2,m-1
       do 100 j = 2,n-1
       W(i,j) = diffusivity*dt*
     x (((T(i+1,j) - 2.0*T(i,j) + T(i-1,j))/(hx*hx)) +
     x ((T(i,j+1)  - 2.0*T(i,j) + T(i,j-1))/(hy*hy)))
100    continue

       do 200 i = 1,m
       do 200 j = 1,n
       T(i,j) = T(i,j) + W(i,j)
200    continue


       return
       end




