! ------------------------------------------------------------ !
      program ct
! ------------------------------------------------------------ !
! Purpose: This program is the main program
!          of the controller
!
! 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
!
! ------------------------------------------------------------ !
! NOTE: TO CHANGE NUM. OF ZONE CHANGE nchild HERE & mz IN GRT.F90
      use communicate 
      use radtrans
      implicit none

      integer :: istat
      integer :: info   
      integer :: nchild
      integer :: again
      integer :: ilabel
      integer :: strt  = 0   ! First node to spawn: 0=current node.
      integer :: shft  = 0   ! Next node to spawn:  1=next node on list.
      real(8) :: dlabel, label
      real(8) :: tail
      character(len=30) :: gq         = 'gq'
      character(len=30) :: myname     = 'ct'
      character(len=30) :: rt         = 'rt'
      character(len=30) :: mm         = 'mm'
      character(len=70) :: envstring  = 'STDOUT'
      external fbuff
      snd_p  = 2
      snd_c  = 2    ! snd_c  = (t,dna)
      nchild = 10  ! nchild = #plasma zones
      call myinit( myname, gq, envstring ) 
      call x_rtids_p( 1, myname )
      call x_sp_c( mm, nchild, strt, shft)           
      call x_stids(10, mm, mm )
      again=0
      do 
         again=again+1
         call x_rdat_p( 2, istat )
         call x_sdat_c( 11, mm, istat )
         if(istat.eq.0) goto 10
         call ct_rrt_mm(101)
         call x_rdat_c( 12, mm )                  ! Ne: rcv_c =1 from ea. mm
         write(1,*) 'aft x_rdat_c'
         call radtransport
         write(1,*) 'aft rad'
         ilabel=get_mytid()
         dlabel=dble(ilabel)
         tail=0.001d0*again
         label=dlabel+tail
         write(1,*) 'label=',label
         write(1,*) 'c=',c
         write(1,*) 'q2=',q2
!        r8_frm_c(1)=1.0/q2
          r8_frm_c(1)=1.0
         r8_frm_c(2)=label
         call x_sdat_p( 2 )
      enddo
10    continue
      close(1)
      call pvmfexit(info)
      end
