      PROGRAM gaussian
      PARAMETER (nproc0 = 4)
      PARAMETER (N = 100)
      PARAMETER (NN = 101)
      INTEGER indx (25), iTmp (1)
      REAL a (25, NN)
      REAL row (NN)
      REAL fac (25), temp (25)
      REAL maxNum
      REAL x (N), T
C     DECOMPOSITION d (100)
C     DISTRIBUTE d (BLOCK)
C     ALIGN a (i, :) WITH d (i)
C     ALIGN temp (i) WITH d (i)
C     ALIGN fac (i) WITH d (i)
C     ALIGN indx (i) WITH d (i)
      INTEGER Ti1
      INTEGER Tllb1
      INTEGER Tlub1
      INTEGER minLoc1, maxLoc1, minLoc2, maxLoc2, coord(3)
      COMMON /g_to_l/minLoc1, maxLoc1, minLoc2, maxLoc2, coord
      INTEGER TTT0temp_info (8,7), Ttemp_info (8,7), TTT1temp_info (8,7)
      INTEGER proclist(8)
      INTEGER TT4temp_comm (5,7), maxNum_comm (5,7), TT3temp_comm (5,7),
     & TT2temp_comm (5,7), a_comm (5,7), TT5temp_comm (5,7)
      LOGICAL TT0temp (25)
      INTEGER TT1temp (1)
      REAL TT2temp (NN - 1 + 1)
      REAL TT3temp
      REAL TT4temp
      REAL TT5temp
      CALL parameter_for_intrinsic (TTT0temp_info, 1, 1, 25, 25, 0, 0)
      CALL parameter_for_intrinsic (Ttemp_info, 1, 1, 25, 25, 1, 4)
      CALL parameter_for_intrinsic (TTT1temp_info, 1, 1, 1, 1, 0, 0)
      CALL EXP_init_1 (4, 25)
      DO 7002 i = minLoc1, maxLoc1
      DO 7000 j = 1, NN
      IF (j .EQ. i) THEN
      a (i - minLoc1 + 1, j) = 2.0
      ELSE
      a (i - minLoc1 + 1, j) = 1.0
      END IF
7000  CONTINUE
7002  CONTINUE
      s = N * NN / 2
      DO 7004 i = minLoc1, maxLoc1
      a (i - minLoc1 + 1, NN) = s + i
7004  CONTINUE
      DO Ti1 = 1, 25
      indx (Ti1) = (-1)
      END DO
      CALL start_timer ()
      DO 7006 k = 1, N
      DO Ti1 = 1, 25
      temp (Ti1) = a (Ti1, k)
      END DO
      DO Ti1 = 1, 25
      TT0temp (Ti1) = indx (Ti1) .EQ. (-1)
      END DO
      CALL maxloc_1_R_M (temp, Ttemp_info, TT0temp, TTT0temp_info, TT1te
     &mp, TTT1temp_info, proclist)
      DO Ti1 = 1, 1
      iTmp (Ti1) = TT1temp (Ti1)
      END DO
      indxRow = iTmp (1)
      CALL parameter_for_comm (a_comm, 1, indxRow - minLoc1 + 1, indxRow
     & - minLoc1 + 1, 25)
      CALL parameter_for_comm (a_comm, 2, k, k, NN)
      CALL broadcast_R (maxNum, 0, maxNum_comm, a, 2, a_comm, (indxRow -
     & 1) / 25)
      indx (indxRow) = k
      DO Ti1 = 1, 25
      fac (Ti1) = a (Ti1, k) / maxNum
      END DO
      CALL parameter_for_comm (a_comm, 1, indxRow - minLoc1 + 1, indxRow
     & - minLoc1 + 1, 25)
      CALL parameter_for_comm (a_comm, 2, 1, NN, NN)
      CALL parameter_for_comm (TT2temp_comm, 1, 1, NN - 1 + 1, NN - 1 + 
     &1)
      CALL broadcast_R (TT2temp, 1, TT2temp_comm, a, 2, a_comm, (indxRow
     & - 1) / 25)
      DO Ti1 = 1, NN
      row (Ti1) = TT2temp (Ti1) + 0.0
      END DO
      DO j = k, NN
      DO i = 1, 25
      IF (indx (i) .EQ. (-1)) THEN
      a (i, j) = a (i, j) - fac (i) * row (j)
      END IF
      END DO
      END DO
7006  CONTINUE
      CALL stop_timer ()
      DO 7010 j = N, 1, (-1)
      T = 0.0
      DO 7008 k = j + 1, N
      CALL parameter_for_comm (a_comm, 1, j - minLoc1 + 1, j - minLoc1 +
     & 1, 25)
      CALL parameter_for_comm (a_comm, 2, k, k, NN)
      CALL broadcast_R (TT3temp, 0, TT3temp_comm, a, 2, a_comm, (j - 1) 
     &/ 25)
      T = T + TT3temp * x (k)
7008  CONTINUE
      CALL parameter_for_comm (a_comm, 1, j - minLoc1 + 1, j - minLoc1 +
     & 1, 25)
      CALL parameter_for_comm (a_comm, 2, NN, NN, NN)
      CALL broadcast_R (TT4temp, 0, TT4temp_comm, a, 2, a_comm, (j - 1) 
     &/ 25)
      CALL parameter_for_comm (a_comm, 1, j - minLoc1 + 1, j - minLoc1 +
     & 1, 25)
      CALL parameter_for_comm (a_comm, 2, j, j, NN)
      CALL broadcast_R (TT5temp, 0, TT5temp_comm, a, 2, a_comm, (j - 1) 
     &/ 25)
      x (j) = (TT4temp - T) / TT5temp
7010  CONTINUE
      DO 7012 i = 1, N
      CALL ksingl (6)
      WRITE (6, 1) i, x (i)
1     FORMAT (1x,'x',i2,'=',f10.3)
      CALL kflush (6)
7012  CONTINUE
      STOP
      END
