program hello_parallel
   
  include 'mpif.h'
  
  integer numtasks, rank, ierr, rc, len, i,PARENT,request,tag
  character*(MPI_MAX_PROCESSOR_NAME) name
  character(len=2) arg
 
  
  call MPI_INIT(ierr)
  call MPI_COMM_SIZE(MPI_COMM_WORLD, numtasks, ierr)
  call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
  
  tag = 21
!  DO i = 1, iargc()
     CALL getarg(1, arg)
!     WRITE (*,*) "pid: ",rank,"parent =",arg
!  END DO
  
  call MPI_COMM_GET_PARENT(PARENT, ierr)
  
  call MPI_GET_PROCESSOR_NAME(name, len, ierr)
  

  write (*,40) rank,parent,arg,name
40 format (' hello: task=',I3,' parent comm=',I12,', parent pid=',A,',  on host=',A,'')
  
!  call sleep(5)
  call MPI_BARRIER(MPI_COMM_WORLD,ierr)
  if (rank .eq. 0) then
     call MPI_ISEND(rank, 1, MPI_INTEGER, 0, TAG, PARENT, request, ierr)
  endif


  call MPI_FINALIZE(ierr)
  
end program hello_parallel
