CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C  FORTRAN 77 + MESSAGE PASSING PROGRAM
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

      PROGRAM gaussian
      PARAMETER (nproc0 = 4)
      PARAMETER (N = 100)
      PARAMETER (NN = 100)
      INTEGER indx (100), iTmp (1)
      REAL a (N, 25)
      REAL row (25)
      REAL fac (N)
      REAL maxNum
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 TT0temp_comm (5,7), maxNum_comm (5,7), TT3temp_comm (5,7),
     & a_comm (5,7)
      REAL TT0temp (N - 1 + 1)
      LOGICAL TT1temp (100)
      INTEGER TT2temp (1)
      REAL TT3temp (N - 1 + 1)
      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, 100, 100, 0, 0)
      CALL EXP_init_1 (4, 25)
      DO Ti1 = 1, 100
      indx (Ti1) = (-1)
      END DO
      DO 7000 k = 1, N
      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 (TT0temp_comm, 1, 1, N - 1 + 1, N - 1 + 1)
      CALL broadcast_R (TT0temp, 1, TT0temp_comm, a, 2, a_comm, (k - 1) 
     &/ 25)
      DO Ti1 = 1, 100
      TT1temp (Ti1) = indx (Ti1) .EQ. (-1)
      END DO
      CALL maxloc_1_R_M (TT0temp, TTT0temp_info, TT1temp, TTT1temp_info,
     & TT2temp, 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_R (maxNum, 0, maxNum_comm, a, 2, a_comm, (k - 1) / 
     &25)
      indx (indxRow) = k
      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 (TT3temp_comm, 1, 1, N - 1 + 1, N - 1 + 1)
      CALL broadcast_R (TT3temp, 1, TT3temp_comm, a, 2, a_comm, (k - 1) 
     &/ 25)
      DO Ti1 = 1, N
      fac (Ti1) = TT3temp (Ti1) / maxNum
      END DO
      DO Ti1 = 1, 25
      row (Ti1) = a (indxRow, Ti1)
      END DO
      CALL adjust_local_bounds (k, NN, Tllb2, Tlub2, 1, 25)
      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
      END
