01 function varargout = MPI_Recv( source , tag , comm )
02 % MPI_Recv - Receives message from source.
03 %
04 % [var1, var2, ...] = MPI_Recv( source, tag, comm )
05 %
06 % Receives message from source with a given tag
07 % and returns the variables in the message.
08 %
09 % source can be an iteger from 0 to comm_size-1
10 % tag can be any integer
11 % comm is an MPI Communicator (typically a copy of MPI_COMM_WORLD)
12 %
13
14 % Get processor rank.
15 my_rank = MPI_Comm_rank(comm) ;
16
17 % Get file names.
18 buffer_file = MatMPI_Buffer_file(source ,my_rank ,tag ,comm) ;
19 lock_file = MatMPI_Lock_file(source ,my_rank ,tag ,comm) ;
20
21 % Spin on lock file until it is created.
22 loop = 0 ;
23 while exist(lock_file) ~ = 2
24 loop = loop + 1 ;
25 end
26
27 % Read all data out of buffer_file.
28 buf = load(buffer_file) ;
29
30 % Delete buffer and lock files.
31 if (not(comm.save_message_flag))
32 delete(buffer_file) ;
33 delete(lock_file) ;
34 end
35
36 % Get variable out of buf.
37 varargout = buf.varargin ;
38
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 % MatlabMPI
41 % Dr. Jeremy Kepner
42 % MIT Lincoln Laboratory
43 % kepner@ll.mit.edu
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 % Copyright 2002 Massachusetts Institute of Technology
46 %
47 % Permission is herby granted, without payment, to copy, modify, display
48 % and distribute this software and its documentation, if any, for any
49 % purpose, provided that the above copyright notices and the following
50 % three paragraphs appear in all copies of this software. Use of this
51 % software constitutes acceptance of these terms and conditions.
52 %
53 % IN NO EVENT SHALL MIT BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
54 % SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
55 % THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF MIT HAS BEEN ADVISED OF THE
56 % POSSIBILITY OF SUCH DAMAGE.
57 %
58 % MIT SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING,
59 % BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
60 % FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
61 %
62 % THIS SOFTWARE IS PROVIDED "AS IS," MIT HAS NO OBLIGATION TO PROVIDE
63 % MAINTENANCE, SUPPORT, UPDATE, ENHANCEMENTS, OR MODIFICATIONS.
64
|