      PROGRAM gaussian
      PARAMETER (nproc0 = 4)
      PARAMETER (N = 99)
      PARAMETER (NN = 100)
      INTEGER indx (N), iTmp (1)
      REAL a (N, 25)
      REAL row (25)
      REAL fac (N)
      REAL maxNum
      REAL x (N), T
C     DECOMPOSITION d (100)
C     DISTRIBUTE d (BLOCK)
C     ALIGN a (:, i) WITH d (i)
C     ALIGN row (i) WITH d (i)
      INTEGER Ti1
      INTEGER Tllb1, Tllb2
      INTEGER Tlub1, Tlub2
      INTEGER minLoc1, maxLoc1, minLoc2, maxLoc2, coord(3)
      COMMON /g_to_l/minLoc1, maxLoc1, minLoc2, maxLoc2, coord
      INTEGER TTT0temp_info (8,7), TTT3temp_info (8,7), TTT2temp_info (8
     &,7)
      INTEGER proclist(8)
      INTEGER TT4temp_comm (5,7), TT8temp_comm (5,7), TT7temp_comm (5,7)
     &, a_comm (5,7), TT6temp_comm (5,7), TT1temp_comm (5,7), TT5temp_co
     &mm (5,7)
      REAL TT0temp (N - 1 + 1)
      REAL TT1temp (N - 1 + 1)
      LOGICAL TT2temp (N)
      INTEGER TT3temp (1)
      REAL TT4temp
      REAL TT5temp (N - 1 + 1)
      REAL TT6temp
      REAL TT7temp
      REAL TT8temp
      INTEGER TT9temp
      CALL parameter_for_intrinsic (TTT0temp_info, 1, 1, N - 1 + 1, N - 
     &1 + 1, 0, 0)
      CALL parameter_for_intrinsic (TTT3temp_info, 1, 1, 1, 1, 0, 0)
      CALL parameter_for_intrinsic (TTT2temp_info, 1, 1, N, N, 0, 0)
      CALL EXP_init_1 (4, 25)
      proclist(1)=-1
      CALL input (a, N, NN)
      TT9temp = 1
      DO Ti1 = 1, N
      indx (Ti1) = (-1)
      END DO
      CALL start_timer ()
      DO 7000 k = 1, N
      TT9temp = 1
      TT9temp = 1
      CALL parameter_for_comm (a_comm, 1, 1, N, N)
      CALL parameter_for_comm (a_comm, 2, k - minLoc1 + 1, k - minLoc1 +
     & 1, 25)
      CALL parameter_for_comm (TT1temp_comm, 1, 1, N - 1 + 1, N - 1 + 1)
      CALL broadcast_R (TT1temp, 1, TT1temp_comm, a, 2, a_comm, (k - 1) 
     &/ 25)
      DO Ti1 = 1, N - 1 + 1
      TT0temp (Ti1) = TT1temp (Ti1)
      END DO
      TT9temp = 1
      DO Ti1 = 1, N
      TT2temp (Ti1) = indx (Ti1) .EQ. (-1)
      END DO
      CALL maxloc_1_R_M (TT0temp, TTT0temp_info (1, 1), TTT0temp_info (2
     &, 1), TTT0temp_info, TT2temp, TTT2temp_info (1, 1), TTT2temp_info 
     &(2, 1), TTT2temp_info, TT3temp, TTT3temp_info (1, 1), TTT3temp_inf
     &o (2, 1), TTT3temp_info, proclist)
      DO Ti1 = 1, 1
      iTmp (Ti1) = TT3temp (Ti1)
      END DO
      indxRow = iTmp (1)
      CALL parameter_for_comm (a_comm, 1, indxRow, indxRow, N)
      CALL parameter_for_comm (a_comm, 2, k - minLoc1 + 1, k - minLoc1 +
     & 1, 25)
      CALL broadcast_R (TT4temp, 0, TT4temp_comm, a, 2, a_comm, (k - 1) 
     &/ 25)
      maxNum = TT4temp
      indx (indxRow) = k
      TT9temp = 1
      CALL parameter_for_comm (a_comm, 1, 1, N, N)
      CALL parameter_for_comm (a_comm, 2, k - minLoc1 + 1, k - minLoc1 +
     & 1, 25)
      CALL parameter_for_comm (TT5temp_comm, 1, 1, N - 1 + 1, N - 1 + 1)
      CALL broadcast_R (TT5temp, 1, TT5temp_comm, a, 2, a_comm, (k - 1) 
     &/ 25)
      DO Ti1 = 1, N
      fac (Ti1) = TT5temp (Ti1) / maxNum
      END DO
      TT9temp = 1
      DO Ti1 = 1, 25
      row (Ti1) = a (indxRow, Ti1)
      END DO
      CALL adjust_local_bounds (k, NN, Tllb2, Tlub2, 1, 25)
      TT9temp = 1
      DO j = Tllb2, Tlub2
      DO i = 1, N
      IF (indx (i) .EQ. (-1)) THEN
      a (i, j) = a (i, j) - fac (i) * row (j)
      END IF
      END DO
      END DO
7000  CONTINUE
      CALL stop_timer ()
      DO 7004 j = N, 1, (-1)
      T = 0.0
      DO 7002 k = j + 1, N
      CALL parameter_for_comm (a_comm, 1, j, j, N)
      CALL parameter_for_comm (a_comm, 2, k - minLoc1 + 1, k - minLoc1 +
     & 1, 25)
      CALL broadcast_R (TT6temp, 0, TT6temp_comm, a, 2, a_comm, (k - 1) 
     &/ 25)
      T = T + TT6temp * x (k)
7002  CONTINUE
      CALL parameter_for_comm (a_comm, 1, j, j, N)
      CALL parameter_for_comm (a_comm, 2, NN - minLoc1 + 1, NN - minLoc1
     & + 1, 25)
      CALL broadcast_R (TT7temp, 0, TT7temp_comm, a, 2, a_comm, (NN - 1)
     & / 25)
      CALL parameter_for_comm (a_comm, 1, j, j, N)
      CALL parameter_for_comm (a_comm, 2, j - minLoc1 + 1, j - minLoc1 +
     & 1, 25)
      CALL broadcast_R (TT8temp, 0, TT8temp_comm, a, 2, a_comm, (j - 1) 
     &/ 25)
      x (j) = (TT7temp - T) / TT8temp
7004  CONTINUE
      DO 7006 i = 1, N
      CALL ksingl (6)
      WRITE (6, 1) i, x (i)
1     FORMAT (1x,'x',i2,'=',f10.3)
      CALL kflush (6)
7006  CONTINUE
      STOP
      END
