Hi,

I tried MPI.ERRORS_RETURN in a small Java program with Open MPI
1.10.2 and master. I get the expected behaviour, if I use a
wrong value for the root process in "bcast". Unfortunately I
get an MPI or Java error message if I try to broadcast more data
than available. Is this intended or is it a problem in the Java
interface of Open MPI? I would be grateful if somebody can answer
my question.

loki java 194 mpijavac Exception_1_Main.java
loki java 195 mpijavac Exception_2_Main.java

loki java 196 mpiexec -np 1 java Exception_1_Main
Set error handler for MPI.COMM_WORLD to MPI.ERRORS_RETURN.
Call "bcast" with wrong "root" process.
Caught an exception.
MPI_ERR_ROOT: invalid root


loki java 197 mpiexec -np 1 java Exception_2_Main
Set error handler for MPI.COMM_WORLD to MPI.ERRORS_RETURN.
Call "bcast" with index out-of bounds.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
        at mpi.Comm.bcast(Native Method)
        at mpi.Comm.bcast(Comm.java:1231)
        at Exception_2_Main.main(Exception_2_Main.java:44)
-------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code.. Per user-direction, the job has been aborted.
-------------------------------------------------------
--------------------------------------------------------------------------
mpiexec detected that one or more processes exited with non-zero status, thus 
causing
the job to be terminated. The first process to do so was:

  Process name: [[38300,1],0]
  Exit code:    1
--------------------------------------------------------------------------
loki java 198


Kind regards and thank you very much for any help in advance

Siegmar
import mpi.*;

public class Exception_1_Main
{
  public static void main (String args[]) throws MPIException
  {
    int mytid,                          /* my task id                   */
        intValue[] = new int[1];        /* broadcast one intValue       */

    MPI.Init(args);
    mytid = MPI.COMM_WORLD.getRank ();
    if (mytid == 0)
    {
      intValue[0] = 10;                 /* arbitrary value              */
    }
    System.out.printf ("Set error handler for MPI.COMM_WORLD to " +
                       "MPI.ERRORS_RETURN.\n");
    MPI.COMM_WORLD.setErrhandler (MPI.ERRORS_RETURN);
    try {
      /* use wrong "root process" to produce an error                   */
      System.out.printf ("Call \"bcast\" with wrong \"root\" process.\n");
      MPI.COMM_WORLD.bcast (intValue, 1, MPI.INT, 10);
    }
    catch (MPIException ex)
    {
      System.err.printf ("Caught an exception.\n");
      System.err.printf ("%s\n", ex.getMessage ());
      MPI.Finalize ();
      System.exit (0);
    }
    MPI.Finalize ();
  }
}
import mpi.*;

public class Exception_2_Main
{
  public static void main (String args[]) throws MPIException
  {
    int mytid,                          /* my task id                   */
        intValue[] = new int[1];        /* broadcast one intValue       */

    MPI.Init(args);
    mytid = MPI.COMM_WORLD.getRank ();
    if (mytid == 0)
    {
      intValue[0] = 10;                 /* arbitrary value              */
    }
    System.out.printf ("Set error handler for MPI.COMM_WORLD to " +
                       "MPI.ERRORS_RETURN.\n");
    MPI.COMM_WORLD.setErrhandler (MPI.ERRORS_RETURN);
    try {
      /* use index out-of bounds to produce an error                    */
      System.out.printf ("Call \"bcast\" with index out-of bounds.\n");
      MPI.COMM_WORLD.bcast (intValue, 2, MPI.INT, 0);
    }
    catch (MPIException ex)
    {
      System.err.printf ("Caught an exception.\n");
      System.err.printf ("%s\n", ex.getMessage ());
      MPI.Finalize ();
      System.exit (0);
    }
    MPI.Finalize ();
  }
}

Reply via email to