      PROGRAM gaussian
      PARAMETER (nproc0 = 4)
      PARAMETER (N = 99)
      PARAMETER (NN = 100)
      INTEGER indx (N), iTmp (1)
      INTEGER a (N, 25)
      INTEGER row (25)
      INTEGER fac (N)
      INTEGER maxNum
      INTEGER 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), TTT2temp_info (8,7), TTT1temp_info (8
     &,7)
      INTEGER proclist(8)
      INTEGER TT14temp_comm (5,7), maxNum_comm (5,7), TT13temp_comm (5,7
     &), TT12temp_comm (5,7), a_comm (5,7)
      INTEGER TT0temp (N - 1 + 1)
      LOGICAL TT1temp (N)
      INTEGER TT2temp (1)
      INTEGER TT3temp
      INTEGER TT4temp
      INTEGER TT5temp
      INTEGER TT6temp (1)
      INTEGER TT7temp (2475)
      INTEGER TT8temp (2475)
      INTEGER TT9temp
      INTEGER TT10temp (1)
      INTEGER TT11temp (2475)
      INTEGER TT12temp
      INTEGER TT13temp
      INTEGER TT14temp
      CALL parameter_for_intrinsic (TTT0temp_info, 1, 1, N - 1 + 1, N - 
     &1 + 1, 0, 0)
      CALL parameter_for_intrinsic (TTT2temp_info, 1, 1, 1, 1, 0, 0)
      CALL parameter_for_intrinsic (TTT1temp_info, 1, 1, N, N, 0, 0)
      CALL EXP_init_1 (4, 25)
      proclist(1)=-1
      CALL input (a, N, NN)
      TT3temp = 1
      DO Ti1 = 1, N
      indx (Ti1) = (-1)
      END DO
      CALL start_timer ()
      DO 7000 k = 1, N
      TT3temp = 1
      TT3temp = 1
      TT5temp = 1
      DO Ti1 = 1, N - 1 + 1
      TT6temp (1) = (k - 1) / 25
      TT7temp (TT5temp) = KXGDPR (TT6temp)
      TT8temp (TT5temp) = Ti1 + ((k - (25 * TT6temp (1)) - 1) * N)
      TT5temp = TT5temp + 1
      
      END DO
      TT5temp = TT5temp - 1
      TT4temp = IFSCHEDULE (TT8temp, TT7temp, TT5temp)
      
      CALL IFGATHER (TT4temp, TT8temp, a)
      
      DO Ti1 = 1, N - 1 + 1
      TT0temp (Ti1) = TT8temp (TT3temp)
      TT3temp = TT3temp + 1
      END DO
      TT3temp = 1
      DO Ti1 = 1, N
      TT1temp (Ti1) = indx (Ti1) .EQ. (-1)
      END DO
      CALL maxloc_1_I_M (TT0temp, TTT0temp_info (1, 1), TTT0temp_info (2
     &, 1), TTT0temp_info, TT1temp, TTT1temp_info (1, 1), TTT1temp_info 
     &(2, 1), TTT1temp_info, TT2temp, TTT2temp_info (1, 1), TTT2temp_inf
     &o (2, 1), TTT2temp_info, proclist)
      DO Ti1 = 1, 1
      iTmp (Ti1) = TT2temp (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_I (maxNum, 0, maxNum_comm, a, 2, a_comm, (k - 1) / 
     &25)
      indx (indxRow) = k
      TT5temp = 1
      TT9temp = 1
      DO Ti1 = 1, N
      TT10temp (1) = (k - 1) / 25
      TT7temp (TT9temp) = KXGDPR (TT10temp)
      TT11temp (TT9temp) = Ti1 + ((k - (25 * TT10temp (1)) - 1) * N)
      TT9temp = TT9temp + 1
      
      END DO
      TT9temp = TT9temp - 1
      TT3temp = IFSCHEDULE (TT11temp, TT7temp, TT9temp)
      
      CALL IFGATHER (TT3temp, TT11temp, a)
      
      DO Ti1 = 1, N
      fac (Ti1) = TT11temp (TT5temp) / maxNum
      TT5temp = TT5temp + 1
      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)
      TT5temp = 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_I (TT12temp, 0, TT12temp_comm, a, 2, a_comm, (k - 1
     &) / 25)
      T = T + TT12temp * 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_I (TT13temp, 0, TT13temp_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_I (TT14temp, 0, TT14temp_comm, a, 2, a_comm, (j - 1
     &) / 25)
      x (j) = (TT13temp - T) / TT14temp
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
