			program main

      include 'mpif.h'

      double precision  PI25DT
      parameter        (PI25DT = 3.141592653589793238462643d0)

      integer n, id, numprocs, i, rc
      integer newcom, handle
      integer newcom2
      integer dupcom
      integer status (MPI_STATUS_SIZE)
      integer src, tag
      integer ooor (10)

      double precision d1, d2
      complex c1, c2

      call MPI_INIT( ierr )
      call MPI_COMM_RANK( MPI_COMM_WORLD, id, ierr )
      call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
			call MPI_COMM_DUP ( MPI_COMM_WORLD, newcom, ierr )
      print *, "Process ", id, " of ", numprocs, " is alive"
			print *, "MPI_COMM_WORLD is ", MPI_COMM_WORLD
			print *, "Dup comm is ", newcom

      call MPI_CONN_REGISTER ("TESTA", MPI_COMM_WORLD, handle, ierr)
      call MPI_CONN_INTERCOMM_CREATE (handle, "TESTB", newcom, ierr)
      call MPI_CONN_INTERCOMM_CREATE (handle, "TESTC", newcom2, ierr)


      d1 = PI25DT
      c1 = (2.0, 3.0)
      c2 = (0.0, 0.0)

      call MPI_SEND (d1,1,MPI_DOUBLE_PRECISION,id,10,newcom,ierr)
      call MPI_SEND (c1,1,MPI_COMPLEX,id,20,newcom,ierr)


!      call MPI_RECV (c2,1,MPI_COMPLEX,id,40,newcom,status,ierr)
      call MPI_RECV (d2,1,MPI_DOUBLE_PRECISION,id,30,newcom,status,ierr)
      call MPI_RECV (c2,1,MPI_COMPLEX,id,40,newcom,status,ierr)

      print *,"Send ", d1, "got back ", d2
      print *,"Send ", c1, "got back ", c2

      print *, "Status size", MPI_STATUS_SIZE
      print *, status(1), status(2), status(3)
      print *, status(4), status(5), status(6)

      print *, "Using the offsets from MPI"
      tag = status(MPI_TAG)
      src = status(MPI_SOURCE)
      print *,"Source ", src, "tag ", tag

! 	New test of out of order receives
	do 15 i=1,10
		ooor(i) = 0
15	continue

	do 20 i=10,1, -1
		call MPI_Recv (ooor(i), 1, MPI_INTEGER, id, i, newcom, status, ierr)
20	continue

      call MPI_CONN_LEAVE (ierr)

 30   call MPI_FINALIZE(rc)
      stop
      end




