1 | import mpi.* |
2 | class Hello { |
3 | static public void main(String[] args) { |
4 | MPI.Init(args) ; |
5 | int myrank = MPI.COMM_WORLD.Rank() ; |
6 | if(myrank == 0) { |
7 | char[] message = "Hello, there".toCharArray() ; |
8 | MPI.COMM_WORLD.Send(message, 0, message.length, MPI.CHAR, 1, 99) ; |
9 | } |
10 | else { |
11 | char[] message = new char [20] ; |
12 | MPI.COMM_WORLD.Recv(message, 0, 20, MPI.CHAR, 0, 99) ; |
13 | System.out.println("received:" + new String(message) + ":") ; |
14 | } |
15 | MPI.Finalize() ; |
16 | } |
17 | } |