! --------------------------------------------------------- !
    program mm
! --------------------------------------------------------- !
! Purpose:  This is the main program for the master of
!           the atomic kinetic codes.
!  
! Remark:   i   --  Initializing 
!           x   --  This executable
!           p   --  Parent that spawned this program (ct)
!           c   --  Child process spawned by this program ms
!          _c   --  Communicate (Send & Rec) with child proc. 
!          _r   --  Receive
!          _s   --  Send
!          _g   --  Global var. 
!          _sp  --  Spawning util
!           flg --  Flag
!           dat --  Data 
!           
! --------------------------------------------------------- !
    use stopwatch
    use communicate 

    implicit none

    integer :: info
    integer :: istat = 1
    integer :: nints = 0
    integer :: nproc
    integer :: strt  = 0
    integer :: shft  = 0
    integer :: icntt = 0
    integer :: msg
    character(len=30) :: ct        = "ct"
    character(len=30) :: myname    = "mm"
    character(len=30) :: ms        = "ms"
    character(len=70) :: envstring = 'STDOUT'
    external fbuff
    snd_p = 1
    snd_c = 2
    call myinit( myname, ct, envstring )
    call x_rtids_p( 10, myname )
    call rdfile( nproc )
    call x_sp_c( ms, nproc, 0, 0 )
    call x_stids( 80, ms, ms )
    call mm_sdat_ms( 81, ms )
    do
       icntt=icntt+1            
       call x_rdat_p( 11, istat )
       msg = 2
       call x_sflg_c(msg,ms,istat)
       if(istat.eq.0) goto 10
       call rdfile( nproc )
       msg=82
       call mm_cdat_ms( msg, nproc, ms) ! sends istat=-1 
       msg=msg+1
       istat=1
       call x_sflg_c(msg,ms,istat)  ! Iteration conv. sign.
       call mm_rrt_ms(1,nproc)      ! Relay rt data
       call mm_srt_ct(101)          ! Relay rt data
       call x_sdat_p(12)
       call fbuff()
    enddo

10  continue

    call pvmfexit(info)
    end
