      program example3b
      include 'mpif.h'
      integer ierr, size, rank, n, i, MAX, ibeg, iend
      parameter (MAX=100)
      call MPI_INIT(ierr)
      call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
      call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
      n=(MAX-1)/size+1;
      ibeg=rank*n+1
      iend=(rank+1)*n
      do i = ibeg, min(iend, MAX)
         print *, 'process ', rank, ', ', i, '^2=', i*i
      end do
      call MPI_FINALIZE(ierr)
      end
