1
#ifndef __CS_SYR3_COMM_H__
2
#define __CS_SYR3_COMM_H__
4
/*============================================================================
5
* Communication with SYRTHES 3
6
*============================================================================*/
9
This file is part of Code_Saturne, a general-purpose CFD tool.
11
Copyright (C) 1998-2011 EDF S.A.
13
This program is free software; you can redistribute it and/or modify it under
14
the terms of the GNU General Public License as published by the Free Software
15
Foundation; either version 2 of the License, or (at your option) any later
18
This program is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23
You should have received a copy of the GNU General Public License along with
24
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25
Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
/*----------------------------------------------------------------------------*/
30
/*----------------------------------------------------------------------------
32
*----------------------------------------------------------------------------*/
36
/*----------------------------------------------------------------------------*/
40
/*============================================================================
42
*============================================================================*/
44
#define CS_SYR3_COMM_FIN_FICHIER "EOF"
46
#define CS_SYR3_COMM_H_LEN 32 /* Length of a header name */
48
/* Socket communications: we suppose a maximum of 8 coupled SYRTHES instances;
49
this value may be modified through the CS_SYR3_COMM_SOCKET_NBR_MAX
50
environment variable */
52
/*============================================================================
54
*============================================================================*/
56
/*----------------------------------------------------------------------------
58
*----------------------------------------------------------------------------*/
62
CS_SYR3_COMM_TYPE_NONE, /* No communication (pre-initialization) */
63
CS_SYR3_COMM_TYPE_MPI, /* MPI messages */
64
CS_SYR3_COMM_TYPE_SOCKET /* IP sockets */
66
} cs_syr3_comm_type_t;
68
/* Pointer associated with an opaque communicator structure. */
70
typedef struct _cs_syr3_comm_t cs_syr3_comm_t;
72
/* Structure used to save message header data, to simplify its use. */
76
char sec_name[CS_SYR3_COMM_H_LEN + 1];
80
} cs_syr3_comm_msg_header_t;
82
/*============================================================================
84
*============================================================================*/
86
/*=============================================================================
87
* Public function prototypes
88
*============================================================================*/
90
/*----------------------------------------------------------------------------
91
* Initialize a communication
94
* number, <-- coupling number
95
* proc_rank, <-- communicating process rank (< 0 if using sockets)
96
* type, <-- communication type
97
* echo <-- echo on main output (< 0 if none, header if 0,
98
* n first and last elements if n)
101
* pointer to communication structure
102
*----------------------------------------------------------------------------*/
105
cs_syr3_comm_initialize(int number,
106
#if defined(HAVE_MPI)
109
cs_syr3_comm_type_t type,
112
/*----------------------------------------------------------------------------
113
* Finalize a communication
114
*----------------------------------------------------------------------------*/
117
cs_syr3_comm_finalize(cs_syr3_comm_t *comm);
119
/*----------------------------------------------------------------------------
120
* Return a pointer to a communicator name
123
* comm <-- communicator
126
* pointer to communicator name
127
*----------------------------------------------------------------------------*/
130
cs_syr3_comm_get_name(const cs_syr3_comm_t *comm);
132
/*----------------------------------------------------------------------------
136
* nom_rub <-- section name
137
* n_elts <-- number of elements
138
* elt_type <-- element type if n_elts > 0
139
* elts <-- elements if n_elts > 0
140
* comm <-- communicator
141
*----------------------------------------------------------------------------*/
144
cs_syr3_comm_send_message(const char nom_rub[CS_SYR3_COMM_H_LEN],
148
const cs_syr3_comm_t *comm);
150
/*----------------------------------------------------------------------------
151
* Receive message header
154
* header --> message header
155
* comm <-- communicator
158
* number of elements in message body
159
*----------------------------------------------------------------------------*/
162
cs_syr3_comm_receive_header(cs_syr3_comm_msg_header_t *header,
163
const cs_syr3_comm_t *comm);
165
/*----------------------------------------------------------------------------
166
* Receive a message body
169
* header <-- message header
170
* elt --> received body values
171
* comm <-- communicator
172
*----------------------------------------------------------------------------*/
175
cs_syr3_comm_receive_body(const cs_syr3_comm_msg_header_t *header,
177
const cs_syr3_comm_t *comm);
179
#if defined(HAVE_SOCKET)
181
/*----------------------------------------------------------------------------
182
* Open an IP socket to prepare for this communication mode
185
* port_num <-- port number (only used for rank 0; automatic on others)
186
*----------------------------------------------------------------------------*/
189
cs_syr3_comm_init_socket(int port_num);
191
/*----------------------------------------------------------------------------
192
* Close an IP socket associated with this communication mode
193
*----------------------------------------------------------------------------*/
196
cs_syr3_comm_finalize_socket(void);
198
#endif /* HAVE_SOCKET */
200
/*----------------------------------------------------------------------------*/
204
#endif /* __CS_SYR3_COMM_H__ */