      PROGRAM LAPLACE
      PARAMETER (nproc0 = 2)
      PARAMETER (nproc1 = 4)
      PARAMETER (N = 4)
      INTEGER A (2, 1), B (2, 1), C (2, 1), D (2, 1), tolerence
      INTEGER nIter, nIcycle, x, y
      INTEGER error, toler (2)
C     DECOMPOSITION TEMP (4, 4)
C     DISTRIBUTE TEMP (BLOCK, BLOCK)
C     ALIGN A (I, J) WITH TEMP (I, J)
C     ALIGN B (I, J) WITH TEMP (I, J)
C     ALIGN C (I, J) WITH TEMP (I, J)
C     ALIGN D (I, J) WITH TEMP (I, J)
      INTEGER Tllb1, Tllb2
      INTEGER Tlub1, Tlub2
      INTEGER minLoc1, maxLoc1, minLoc2, maxLoc2, coord(3)
      COMMON /g_to_l/minLoc1, maxLoc1, minLoc2, maxLoc2, coord
      INTEGER proclist(8)
      INTEGER TT0temp
      INTEGER TT1temp
      INTEGER TT2temp
      INTEGER TT3temp (2)
      INTEGER TT4temp (2)
      INTEGER TT5temp (2)
      LOGICAL TT6temp
      INTEGER TT7temp
      INTEGER TT8temp (2)
      INTEGER TT9temp (2)
      LOGICAL TT10temp
      INTEGER TT11temp
      INTEGER TT12temp (2)
      INTEGER TT13temp (2)
      LOGICAL TT14temp
      INTEGER TT15temp
      INTEGER TT16temp (2)
      INTEGER TT17temp (2)
      LOGICAL TT18temp
      CALL EXP_init_2 (2, 4, 2, 1)
      proclist(1)=-1
      TT0temp = 1
      DO J = 1, 1
      DO I = 1, 2
      B (I, J) = 8
      END DO
      END DO
      TT0temp = 1
      DO J = 1, 1
      DO I = 1, 2
      A (I, J) = 1
      END DO
      END DO
      CALL adjust_local_bounds (2, N - 1, Tllb1, Tlub1, 1, 2)
      CALL adjust_local_bounds (2, N - 1, Tllb2, Tlub2, 2, 1)
      TT0temp = 1
      TT6temp = .TRUE.
      IF (TT6temp) THEN
      TT2temp = 1
      DO J = Tllb2, Tlub2
      DO I = Tllb1, Tlub1
      TT3temp (1) = ((I + minLoc1 - 1) - 1) / 2
      TT3temp (2) = ((J + minLoc2 - 1) - 1 - 1) / 1
      TT4temp (TT2temp) = KXGDPR (TT3temp)
      TT5temp (TT2temp) = ((I + minLoc1 - 1) - (2 * TT3temp (1))) + (((J
     & + minLoc2 - 1) - 1 - (1 * TT3temp (2)) - 1) * 2)
      TT2temp = TT2temp + 1
      
      END DO
      END DO
      TT2temp = TT2temp - 1
      TT1temp = IFSCHEDULE (TT5temp, TT4temp, TT2temp)
      
      TT6temp = .FALSE.
      END IF
      
      CALL IFGATHER (TT1temp, TT5temp, A)
      
      TT10temp = .TRUE.
      IF (TT10temp) THEN
      TT7temp = 1
      DO J = Tllb2, Tlub2
      DO I = Tllb1, Tlub1
      TT4temp (1) = ((I + minLoc1 - 1) - 1) / 2
      TT4temp (2) = ((J + minLoc2 - 1) + 1 - 1) / 1
      TT8temp (TT7temp) = KXGDPR (TT4temp)
      TT9temp (TT7temp) = ((I + minLoc1 - 1) - (2 * TT4temp (1))) + (((J
     & + minLoc2 - 1) + 1 - (1 * TT4temp (2)) - 1) * 2)
      TT7temp = TT7temp + 1
      
      END DO
      END DO
      TT7temp = TT7temp - 1
      TT2temp = IFSCHEDULE (TT9temp, TT8temp, TT7temp)
      
      TT10temp = .FALSE.
      END IF
      
      CALL IFGATHER (TT2temp, TT9temp, A)
      
      TT14temp = .TRUE.
      IF (TT14temp) THEN
      TT11temp = 1
      DO J = Tllb2, Tlub2
      DO I = Tllb1, Tlub1
      TT8temp (1) = ((I + minLoc1 - 1) - 1 - 1) / 2
      TT8temp (2) = ((J + minLoc2 - 1) - 1) / 1
      TT12temp (TT11temp) = KXGDPR (TT8temp)
      TT13temp (TT11temp) = ((I + minLoc1 - 1) - 1 - (2 * TT8temp (1))) 
     &+ (((J + minLoc2 - 1) - (1 * TT8temp (2)) - 1) * 2)
      TT11temp = TT11temp + 1
      
      END DO
      END DO
      TT11temp = TT11temp - 1
      TT7temp = IFSCHEDULE (TT13temp, TT12temp, TT11temp)
      
      TT14temp = .FALSE.
      END IF
      
      CALL IFGATHER (TT7temp, TT13temp, A)
      
      TT18temp = .TRUE.
      IF (TT18temp) THEN
      TT15temp = 1
      DO J = Tllb2, Tlub2
      DO I = Tllb1, Tlub1
      TT12temp (1) = ((I + minLoc1 - 1) + 1 - 1) / 2
      TT12temp (2) = ((J + minLoc2 - 1) - 1) / 1
      TT16temp (TT15temp) = KXGDPR (TT12temp)
      TT17temp (TT15temp) = ((I + minLoc1 - 1) + 1 - (2 * TT12temp (1)))
     & + (((J + minLoc2 - 1) - (1 * TT12temp (2)) - 1) * 2)
      TT15temp = TT15temp + 1
      
      END DO
      END DO
      TT15temp = TT15temp - 1
      TT11temp = IFSCHEDULE (TT17temp, TT16temp, TT15temp)
      
      TT18temp = .FALSE.
      END IF
      
      CALL IFGATHER (TT11temp, TT17temp, A)
      
      DO J = Tllb2, Tlub2
      DO I = Tllb1, Tlub1
      B (I, J) = TT5temp (TT0temp) + TT9temp (TT0temp) + TT13temp (TT0te
     &mp) + TT17temp (TT0temp)
      TT0temp = TT0temp + 1
      END DO
      END DO
      DO 7002 I = 1, N / nproc0
      DO 7000 J = 1, N / nproc1
      CALL kmultI (6)
      WRITE (6, *) 'I=', I + mInloc1 - 1, 'J=', J + mInloc2 - 1, B (I, J
     &)
      CALL kflush (6)
7000  CONTINUE
7002  CONTINUE
      STOP
      END
