1 | |
---|
2 | #include "mpiP.h" |
---|
3 | |
---|
4 | /* |
---|
5 | * |
---|
6 | */ |
---|
7 | |
---|
8 | |
---|
9 | FC_FUNC( mpi_pack , MPI_PACK ) |
---|
10 | ( void *inbuf, int *incount, int *datatype, |
---|
11 | void *outbuf, int *outsize, int *position, int *comm, int *ierror) |
---|
12 | { |
---|
13 | *ierror=MPI_Pack(inbuf, *incount,* datatype, |
---|
14 | outbuf, *outsize, position, *comm); |
---|
15 | } |
---|
16 | |
---|
17 | |
---|
18 | |
---|
19 | int MPI_Pack( void *inbuf, int incount, MPI_Datatype datatype, |
---|
20 | void *outbuf, int outsize, int *position, MPI_Comm comm) |
---|
21 | { |
---|
22 | int size; |
---|
23 | |
---|
24 | size=datatype*incount; |
---|
25 | |
---|
26 | if ( (*position)+size > outsize) |
---|
27 | { |
---|
28 | fprintf(stderr,"MPI_Pack: ran out of space in outbuf\n"); |
---|
29 | abort(); |
---|
30 | } |
---|
31 | |
---|
32 | memcpy( (char *)outbuf+(*position), inbuf, size); |
---|
33 | (*position)+=size; |
---|
34 | |
---|
35 | return(MPI_SUCCESS); |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | |
---|
40 | /* |
---|
41 | * |
---|
42 | */ |
---|
43 | |
---|
44 | |
---|
45 | FC_FUNC( mpi_unpack , MPI_UNPACK ) |
---|
46 | ( void *inbuf, int *insize, int *position, |
---|
47 | void *outbuf, int *outcount, int *datatype, |
---|
48 | int *comm, int *ierror ) |
---|
49 | { |
---|
50 | *ierror=MPI_Unpack( inbuf, *insize, position, |
---|
51 | outbuf, *outcount, *datatype, *comm); |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | |
---|
56 | int MPI_Unpack( void *inbuf, int insize, int *position, |
---|
57 | void *outbuf, int outcount, MPI_Datatype datatype, |
---|
58 | MPI_Comm comm ) |
---|
59 | { |
---|
60 | int size; |
---|
61 | |
---|
62 | size=datatype*outcount; |
---|
63 | |
---|
64 | if ( (*position)+size > insize ) |
---|
65 | { |
---|
66 | fprintf(stderr,"MPI_Unpack: ran out of data in inbuf\n"); |
---|
67 | abort(); |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | memcpy(outbuf, (char *)inbuf+(*position) , size); |
---|
72 | (*position)+=size; |
---|
73 | |
---|
74 | return(MPI_SUCCESS); |
---|
75 | |
---|
76 | } |
---|