comparison src/is_master_node.cc @ 255:072aee55bb75

Import UFL in a parallel-safe fashion
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Wed, 30 Jul 2014 18:09:13 +0200
parents
children 61830a4f9ab9
comparison
equal deleted inserted replaced
254:2b51546a28f7 255:072aee55bb75
1 /*
2 Copyright (C) 2014 Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
3
4 This program is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free Software
6 Foundation; either version 3 of the License, or (at your option) any later
7 version.
8
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 details.
13
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <dolfin.h>
19 #include <octave/oct.h>
20 #include "dolfin_compat.h"
21
22 DEFUN_DLD (is_master_node, args, nargout,
23 "-*- texinfo -*-\n\
24 @deftypefn {Function File} {} \
25 is_master_process ()\n\
26 Return true if called on node zero.\n\
27 @end deftypefn")
28 {
29 octave_value retval;
30 int nargin = args.length ();
31
32 if (nargin > 0 || nargout > 1)
33 print_usage ();
34 else
35 {
36 #ifdef LATEST_DOLFIN
37 retval = (dolfin::MPI::rank (MPI_COMM_WORLD) == 0);
38 #else
39 // This works also in 1.4.0, but it is now deprecated
40 retval = (dolfin::MPI::process_number () == 0);
41 #endif
42 }
43
44 return retval;
45 }