/[escript]/trunk/paso/src/Paso_MPI.c
ViewVC logotype

Annotation of /trunk/paso/src/Paso_MPI.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 731 - (hide annotations)
Mon May 15 04:09:52 2006 UTC (13 years, 5 months ago) by bcumming
File MIME type: text/plain
File size: 1243 byte(s)


1 bcumming 731 #include <stdlib.h>
2     #include <stdio.h>
3    
4    
5     #include "Paso.h"
6    
7     #ifdef PASO_MPI
8    
9     /* allocate memory for an mpi_comm, and find the communicator details */
10     Paso_MPIInfo* Paso_MPIInfo_alloc( MPI_Comm comm )
11     {
12     int error;
13     Paso_MPIInfo *out=NULL;
14    
15     out = MEMALLOC( 1, Paso_MPIInfo );
16    
17     out->reference_counter = 0;
18     error = MPI_Comm_rank( comm, &out->rank )==MPI_SUCCESS && MPI_Comm_size( comm, &out->size )==MPI_SUCCESS;
19     if( !error ) {
20     Paso_setError( PASO_MPI_ERROR, "Paso_MPIInfo_alloc : error finding comm rank/size" );
21     }
22    
23     out->comm = comm;
24     out->reference_counter++;
25    
26     return out;
27     }
28    
29     /* free memory for an mpi_comm */
30     void Paso_MPIInfo_dealloc( Paso_MPIInfo *in )
31     {
32     if( in && !(--in->reference_counter) )
33     MEMFREE( in );
34     }
35    
36     Paso_MPIInfo *Paso_MPIInfo_getReference( Paso_MPIInfo* in )
37     {
38     if (in!=NULL)
39     ++(in->reference_counter);
40    
41     return in;
42     }
43    
44     /**************************************************
45     WRAPPERS
46     **************************************************/
47    
48     int Paso_MPI_initialized( void )
49     {
50     int error=0, initialised=0;
51    
52     error = MPI_Initialized( &initialised );
53     if( error!=MPI_SUCCESS )
54     Paso_setError( PASO_MPI_ERROR, "mpi_initialised : MPI error" );
55    
56     return initialised;
57     }
58    
59     #endif

  ViewVC Help
Powered by ViewVC 1.1.26