!2345678901234567890123456789012345678901234567890123456789012345678901234567890
!    &                                                                  &

      SUBROUTINE globalInit(numChunk)
          IMPLICIT NONE
          INTEGER numChunk
          numChunk = 5
      END SUBROUTINE

      SUBROUTINE processorInit()
      END SUBROUTINE

      SUBROUTINE chunkInit(width,height, chunkStruct)
          USE chunkModule
	  IMPLICIT NONE

          TYPE(chunk_struct) :: chunkStruct
          TYPE(chunk_type), POINTER :: chunk
          INTEGER width, height
          INTEGER i,j

          ALLOCATE (chunk)
          chunkStruct%chunk_ptr => chunk

          chunk%height = height
          chunk%width = width + 2

          DO i = 1, width
            DO j = 0, height-1
              chunk%temperature(j+1, i+1) = 100*(i-1) + j
            ENDDO 
          ENDDO
        END SUBROUTINE        

 	SUBROUTINE fillBorder(chunk, d, fromleft)
          USE chunkModule
	  IMPLICIT NONE

          TYPE(chunk_type), POINTER :: chunk
          REAL(KIND=8) d(1:*)
          INTEGER fromleft
          INTEGER w,i

          IF (fromleft .eq. 1) THEN
             w = 2
          ELSE
             w = chunk%width-1
          END IF

          DO i = 1 , chunk%height
              d(i) = chunk%temperature(i, w);
          END DO
        END SUBROUTINE

        SUBROUTINE nextIteration(chunk)
          USE chunkModule
	  IMPLICIT NONE

          TYPE(chunk_type), POINTER :: chunk
          INTEGER i,j

          DO i = 2, 11
           DO j = 2, 99
             chunk%temperature(j,i) = ( chunk%temperature(j, i) + chunk%&
     &temperature(j, i+1) + chunk%temperature(j, i-1) + chunk%temperatur&
     &e(j+1, i) + chunk%temperature(j-1, i))/5.0
	   END DO
	  ENDDO
        END SUBROUTINE

 	SUBROUTINE copyBorder(chunk, a, toleft)
          USE chunkModule
	  IMPLICIT NONE

          TYPE(chunk_type), POINTER :: chunk
          REAL(KIND=8) a(*)
          INTEGER toleft
          INTEGER w, i

          IF (toleft .eq. 1) THEN
             w = 1
          ELSE
             w = chunk%width
          END IF
          DO i = 1 , chunk%height
              chunk%temperature(i,w) = a(i)
          END DO
        END SUBROUTINE


!2345678901234567890123456789012345678901234567890123456789012345678901234567890
!    &                                                                  &


