/* -*- Mode: C++; c-basic-offset:4 ; -*- */ /* * * (C) 2003 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. */ #include "mpi.h" #include "mpitestconf.h" #ifdef HAVE_IOSTREAM // Not all C++ compilers have iostream instead of iostream.h #include #ifdef HAVE_NAMESPACE_STD // Those that do need the std namespace; otherwise, a bare "cout" // is likely to fail to compile using namespace std; #endif #else #include #endif #include "mpitestcxx.h" static char MTEST_Descrip[] = "A simple test of Comm_spawn, followed by intercomm merge"; int main( int argc, char *argv[] ) { int errs = 0, err; int rank, size, rsize, i; int np = 2; int errcodes[2]; MPI::Intercomm parentcomm, intercomm; MPI::Intracomm intracomm, intracomm2, intracomm3; bool isChild = false; MPI::Status status; MTest_Init( ); parentcomm = MPI::Comm::Get_parent(); if (parentcomm == MPI::COMM_NULL) { /* Create 2 more processes */ intercomm = MPI::COMM_WORLD.Spawn( "./spawnintrax", MPI::ARGV_NULL, np, MPI::INFO_NULL, 0, errcodes ); } else intercomm = parentcomm; /* We now have a valid intercomm */ rsize = intercomm.Get_remote_size( ); size = intercomm.Get_size(); rank = intercomm.Get_rank(); if (parentcomm == MPI::COMM_NULL) { /* Master */ if (rsize != np) { errs++; cout << "Did not create " << np << " processes (got " << rsize << ")\n"; } if (rank == 0) { for (i=0; i