#include <stdio.h>
#include <time.h>
#include <string.h>

#include "localmpi.h"
#include "extern.h"

int main ( int argc, char ** argv )
{
    // Allocate the MPI system

    if ( mpi_allocate ( argc, argv ) != 0 )
    return ( mpi_err );

    if ( my_rank != MASTER_RANK )   // Child process
    {
        if ( child_proc() != 0 )
    {
        fprintf ( stderr, "%s: Error: Error in executing child\n", argv[0]);
        return ( mpi_err );
    }
    }
    else                // Parent process
    {
    if ( handle_returns() != 0 )
    {
        fprintf ( stderr, "%s: Error: Error in handling return from child\n", argv[0] );
        return ( mpi_err );
    }
    }

    // Do the final clean up

    mpi_err = MPI_Finalize();
    if ( mpi_err != MPI_SUCCESS )
    return ( mpi_err );

    // Finished

    return ( 0 );
}