subroutine su0dminit

!**** *su0dminit* - Sets up distributed memory environment by calling
!                   appropriate message passing interface routines.
!                   MPL_XXXX are ECMWF's message passing interface
!                   layer which presently calls MPI routines underneath.

!     Purpose.
!     --------
!           Define processor topology and environment 

!**   Interface.
!     ----------
!        *call* *su0dminit

!        explicit arguments :
!        --------------------

!        implicit arguments :
!        --------------------

!     method.
!     -------
!        see documentation

!     externals.
!     ----------
!        mpl_myrank -  determines logical PE-number for this PE

!     reference.
!     ----------
!        ECMWF Research Department documentation of the IFS

!     author.
!     -------
!        MPP Group *ECMWF*

!     modifications.
!     --------------
!        original : 95-10-01
!        modified : 00-04-17 J.Vivoda, LMESSP used with nproc=1 without MPL
!        modified : 00-05-26 E.Sevault, cleaning and introduction of LMPOFF
!        Modified : 00-09-01 by D.Dent : MPE to MPL conversion
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        M.Hamrud      01-Dec-2003 CY28R1 Cleaning
!     ------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMCT0   , ONLY : NPROC    ,LMPOFF
USE YOMMP    , ONLY : NPRCIDS  ,MYPROC   ,MYSETA   ,MYSETB &
 & ,MYSETV   ,MYSETW ,MYSETM   ,MYSETN  
USE MPL_MODULE

IMPLICIT NONE

INTEGER(KIND=JPIM) ::  jj
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"
#include "pe2set.intfb.h"

!     ------------------------------------------------------------------

IF (LHOOK) CALL DR_HOOK('SU0DMINIT',0,ZHOOK_HANDLE)
if ( .not.lmpoff ) then
  myproc=mpl_myrank()
  if (myproc > nproc) then
    call abor1(' *** INCONSISTENCY IN NUMBER OF PROCESSORS USED ***')
  endif

else

  myproc=1

endif

do jj=1,nproc
  nprcids(jj)=jj
enddo

!     a-set and b-set for the actual PE is determined

call pe2set(myproc,myseta,mysetb,mysetw,mysetv)
mysetm=mysetw
mysetn=mysetv

IF (LHOOK) CALL DR_HOOK('SU0DMINIT',1,ZHOOK_HANDLE)
end subroutine su0dminit
