program hello_parallel
  
  include 'mpif.h'
  
  integer numtasks, rank, ierr, rc, len, i,PARENT
  character*(MPI_MAX_PROCESSOR_NAME) name
  character*1 arg
  
  call MPI_INIT(ierr)
  call MPI_COMM_SIZE(MPI_COMM_WORLD, numtasks, ierr)
  call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
  
  
  DO i = 1, iargc()
     CALL getarg(i, 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,name
40 format (' hello: task=',I3,' parent comm=',I12,' on host=',A,'')
  
  call MPI_BARRIER(PARENT)
  call MPI_FINALIZE(ierr)
  
end program hello_parallel

