Newsgroups: comp.parallel.mpi
From: "Marc A. Chiarini" <mchiarin@vt.edu>
Subject: Re: Can I use MPI_Pack?
Organization: VT Systems Research Center
Date: 15 Sep 1995 17:13:49 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <43cc8d$66r@solaris.cc.vt.edu>

Once you've initialized the MPI communication subsystem, the short method
requires allocating a pack buffer (statically or dynamically), and then packing
the not necessarily contiguous data into that buffer:

char buff[1000];  /*Note this may be too small, but you can also allocate it
		    dynamically using MPI_Type_size */		
int position = 0;

MPI_Pack( ddata, dlength, MPI_DOUBLE, buff, 1000, &position, MPI_COMM_WORLD);
MPI_Pack( fdata, dlength, MPI_FLOAT, buff, 1000, &position, MPI_COMM_WORLD);
MPI_Pack( idata, dlength, MPI_INT, buff, 1000, &position, MPI_COMM_WORLD);

MPI_Send( buff, position, MPI_PACKED, 1, 0, MPI_COMM_WORLD )

-----

Then process 1 would receive a message of type MPI_PACKED and unpack it into
the appropriate arrays.

See http://www.erc.msstate.edu/mpi/presentations.html for help in using MPI.
You really need to learn a few of the concepts about MPI before you can use it
effectively.  I would suggest doing an in-depth reading of the MPI Standard
document available from http://www.mcs.anl.gov/mpi/index.html...


============================================================================
||   Marc A. Chiarini    || Email: mchiarin@vt.edu                        ||
|| Systems Administrator || WWW  : http://mchiarin.bevc.blacksburg.va.us  ||
||   108 McBryde Hall    || Phone: (540) 953-5035 (H)                     ||
||  SRC - Virginia Tech  ||      : (540) 231-6097 (O)                     ||
|| Blacksburg, VA  24060 || Fax  : (540) 231-4330                         ||
============================================================================
|| Snail Mail:	800 Washington St. #5					  ||
||              Blacksburg, VA 24060					  ||
============================================================================


