File: cgetname.c

package info (click to toggle)
lam 7.1.2-1.4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 54,608 kB
  • ctags: 17,034
  • sloc: ansic: 156,264; sh: 9,976; cpp: 7,699; makefile: 5,589; perl: 476; fortran: 260; asm: 83
file content (83 lines) | stat: -rw-r--r-- 2,128 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * Copyright (c) 2001-2002 The Trustees of Indiana University.  
 *                         All rights reserved.
 * Copyright (c) 1998-2001 University of Notre Dame. 
 *                         All rights reserved.
 * Copyright (c) 1994-1998 The Ohio State University.  
 *                         All rights reserved.
 * 
 * This file is part of the LAM/MPI software package.  For license
 * information, see the LICENSE file in the top level directory of the
 * LAM/MPI source distribution.
 * 
 * $HEADER$
 *
 * $Id: cgetname.c,v 1.7 2003/06/01 14:04:07 jsquyres Exp $
 *
 *	Function:	- get communicator name
 *	Accepts:	- communicator
 *			- communicator name (out)
 *			- communicator name length (out)
 *	Returns:	- MPI_SUCCESS or error code
 */

#include <string.h>

#include <blktype.h>
#include <mpi.h>
#include <mpisys.h>
#include <etc_misc.h>


/*@
   MPI_Comm_get_name - Get the name associated with a communicator

Input Parameters:
. comm - Communicator

Output Parameters:
+ name - Name of the communicator
- length - Integer length of the resulting name

Notes:

This function returns the name of a communicator that was previously
set with 'MPI_Comm_set_name'.  If a name was not previously associated
with a communicator, the returned string will be empty and 'length'
will be 0.  The retuned name will be a maximum of
'MPI_MAX_OBJECT_NAME' characters long.

.N Errors
.N MPI_SUCCESS
.N MPI_ERR_COMM
.N MPI_ERR_ARG

.seealso MPI_Comm_set_name, MPI_Type_get_name, MPI_Type_set_name, MPI_Win_get_name, MPI_Win_set_name

.N WEB
@*/
int
MPI_Comm_get_name(MPI_Comm comm, char *name, int *length)
{
	lam_initerr_m();
	lam_setfunc_m(BLKMPICOMMGETNAME);
/*
 * Check the arguments.
 */
	if (comm == MPI_COMM_NULL) {
		return(lam_errfunc(MPI_COMM_WORLD,
			BLKMPICOMMGETNAME, lam_mkerr(MPI_ERR_COMM, EINVAL)));
	}

	if ((name == 0) || (length == 0)) {
		return(lam_errfunc(comm,
			BLKMPICOMMGETNAME, lam_mkerr(MPI_ERR_ARG, EINVAL)));
	}

	lam_strncpy(name, comm->c_name, MPI_MAX_OBJECT_NAME);
	name[MPI_MAX_OBJECT_NAME - 1] = 0;
	*length = strlen(name);

	lam_resetfunc_m(BLKMPICOMMGETNAME);
	return(MPI_SUCCESS);
}