#include <stdio.h>

#include "localmpi.h"
#define extern
#include "extern.h"
#undef extern

int mpi_allocate ( int argc, char ** argv )
{
    // Initialize the MPI execution environment, using command line

    mpi_err = MPI_Init ( &argc, &argv );
    if ( mpi_err != MPI_SUCCESS )
    {
    handle_err ( "mpi_allocate" );
    fprintf ( stderr, "Fatal: Could not initialize MPI\n" );
    return ( 1 );
    }

    // Determine the rank of calling process in the communicator

    mpi_err = MPI_Comm_rank ( MPI_COMM_WORLD, &my_rank );
    if ( mpi_err != MPI_SUCCESS )
    {
    handle_err ( "mpi_allocate" );
    return ( 1 );
    }

    // Determine the size of the group associated with a communicator.
    // Size is the number of processes in the group of comm.

    mpi_err = MPI_Comm_size ( MPI_COMM_WORLD, &num_procs );
    if ( mpi_err != MPI_SUCCESS )
    {
    handle_err ( "mpi_allocate" );
    return ( mpi_err );
    }

    return ( 0 );
}