c----+----------------------------------------------------------------|
      subroutine MPE_DECOMP1D_all(n,numprocs,s,e)
      implicit none
c     
c     /* input                                                       */
c     /* n             data length to be decomposed (1:n)            */
c     /* numprocs      no. of processors                             */
c     /*                                                             */
c     /* output                                                      */
c     /* s(0:numprocs-1) pointer to start of memory local to procs   */
c     /* e(0:numprocs-1) pointer to end of memory local to procs     */
c     
      integer n, numprocs, myid, s(0:numprocs-1), e(0:numprocs-1)
      integer nlocal,deficit
c---- +----------------------------------------------------------------|
      do myid=0,numprocs-1
         nlocal  = n / numprocs
         s(myid) = myid * nlocal + 1
         deficit = mod(n,numprocs)
         s(myid) = s(myid) + min(myid,deficit)
         if (myid .lt. deficit) then
            nlocal = nlocal + 1
         endif
         e(myid) = s(myid) + nlocal - 1
         if (e(myid) .gt. n .or. myid .eq. numprocs-1) e(myid) = n
      enddo
      return
      end
c----+----------------------------------------------------------------|
