/*
 * File         : .c
 * Headerfile   : .h 
 * Author       : Xinying Li
 * Created      : Thu Apr  9 12:22:15 1998
 * Revision     : $Revision: 1.1.1.1 $
 * Updated      : $Date: 1998/08/20 16:32:42 $
 * Copyright: Northeast Parallel Architectures Center
 *            at Syracuse University 1998
 */

#include <mpi.h>
#include "mpi_Intercomm.h"

#include "ID.h"

DECLARE_CLASS("mpi/Comm", comm_class)
DECLARE_FIELD_ID(comm_class, "handle", "J", CommhandleID)

/*
 * Class:     mpi_Intercomm
 * Method:    Remote_size
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_mpi_Intercomm_Remote_1size
  (JNIEnv *env, jobject jthis)
{
    int size;
    MPI_Comm_remote_size((MPI_Comm)((*env)->GetLongField(env,jthis,CommhandleID)),
		&size);
	return size;
}
/*
 * Class:     mpi_Intercomm
 * Method:    remote_group
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_mpi_Intercomm_remote_1group
  (JNIEnv *env, jobject jthis)
{
  MPI_Group group;
  MPI_Comm_remote_group((MPI_Comm)((*env)->GetLongField(env,jthis,CommhandleID)),
		&group);
  return (jlong)group;
}

/*
 * Class:     mpi_Intercomm
 * Method:    merge
 * Signature: (Z)Lmpi/Intracomm;
 */
JNIEXPORT jlong JNICALL Java_mpi_Intercomm_merge
  (JNIEnv *env, jobject jthis, jboolean high)
{
  MPI_Comm newintracomm;
  MPI_Intercomm_merge((MPI_Comm)((*env)->GetLongField(env,jthis,CommhandleID)), high,
	&newintracomm);
  return (jlong)newintracomm;
}
