next up previous contents
Next: Blocking Send and Receive Up: Point-to-Point Communication Previous: Point-to-Point Communication   Contents

Introduction

In general the mpiJava binding of point-to-point communication operations realizes the MPI functions as methods of the Comm class. The basic point-to-point communication operations are send and receive. Their use is illustrated in the example below.

  import mpi.* ;

  class Hello {
    static public void main(String[] args) throws MPIException {
      MPI.Init(args) ;

      int myrank = MPI.COMM_WORLD.Rank() ;
      if(myrank == 0) {
        char [] message = "Hello, there".toCharArray() ;
        MPI.COMM_WORLD.Send(message, 0, message.length, MPI.CHAR, 1, 99) ;
      }
      else {
        char [] message = new char [20] ;
        MPI.COMM_WORLD.Recv(message, 0, 20, MPI.CHAR, 0, 99) ;
        System.out.println("received:" + new String(message) + ":") ;
      }

      MPI.Finalize();
    }
  }



Bryan Carpenter 2002-07-12