source: CPL/oasis3-mct/branches/OASIS3-MCT_2.0_branch/lib/mct/mpi-serial/pack.c @ 4775

Last change on this file since 4775 was 4775, checked in by aclsce, 4 years ago
  • Imported oasis3-mct from Cerfacs svn server (not suppotred anymore).

The version has been extracted from https://oasis3mct.cerfacs.fr/svn/branches/OASIS3-MCT_2.0_branch/oasis3-mct@1818

File size: 1.4 KB
Line 
1
2#include "mpiP.h"
3
4/*
5 *
6 */
7
8
9FC_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
19int 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
45FC_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
56int 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}
Note: See TracBrowser for help on using the repository browser.