      INCLUDE "mpif.h"

      INTEGER W_RANK, W_SIZE, ERRCODE

      INTEGER BLK_SIZE
      PARAMETER (BLK_SIZE = (50 + 3) / 4)

      REAL A(BLK_SIZE)

      INTEGER BLK_START, BLK_COUNT
      INTEGER L, I

      CALL MPI_INIT(ERRCODE)

      CALL MPI_COMM_RANK(MPI_COMM_WORLD, W_RANK, ERRCODE)
      CALL MPI_COMM_SIZE(MPI_COMM_WORLD, W_SIZE, ERRCODE)

      IF (W_RANK .LT. 4) THEN
          BLK_START = W_RANK * BLK_SIZE
          IF(50 - BLK_START .GE. BLK_SIZE) THEN
              BLK_COUNT = BLK_SIZE
          ELSEIF(50 - BLK_START .GT. 0) THEN
              BLK_COUNT = 50 - BLK_START
          ELSE
              BLK_COUNT = 0
          ENDIF

          DO L = 1, BLK_COUNT
              I = BLK_START + L
              A(L) = 1.0 * I
          ENDDO
      ENDIF

      
       PRINT *, W_RANK, A

      CALL MPI_FINALIZE(ERRCODE)
      END
