Fixes for Windows/ICC--typecasting
[gromacs.git] / include / network.h
bloba547ef9de77b16ccbbaf2b096bfc1d8a1461a862
1 /*
2 *
3 * This source code is part of
4 *
5 * G R O M A C S
6 *
7 * GROningen MAchine for Chemical Simulations
8 *
9 * VERSION 3.2.0
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
32 * And Hey:
33 * Gromacs Runs On Most of All Computer Systems
36 #ifndef _network_h
37 #define _network_h
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
45 * This module defines the interface of the actual communication routines.
48 #include <stdio.h>
50 #ifdef GMX_LIB_MPI
51 #include <mpi.h>
52 #endif
53 #ifdef GMX_THREADS
54 #include "tmpi.h"
55 #endif
57 #include "typedefs.h"
58 #include "main.h"
59 #include "gmx_fatal.h"
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
65 extern int gmx_setup(int *argc,char **argv,int *nnodes);
66 /* Initializes the parallel communication, return the ID of the node */
68 extern int gmx_node_num(void);
69 /* return the number of nodes in the ring */
71 extern int gmx_node_rank(void);
72 /* return the rank of the node */
74 extern void gmx_setup_nodecomm(FILE *fplog,t_commrec *cr);
75 /* Sets up fast global communication for clusters with multi-core nodes */
77 extern bool gmx_mpi_initialized(void);
78 /* return TRUE when MPI_Init has been called.
79 * return FALSE when MPI_Init has not been called OR
80 * when GROMACS was compiled without MPI support.
83 extern void gmx_barrier(const t_commrec *cr);
84 /* Wait till all processes in cr->mpi_comm_mygroup have reached the barrier */
86 extern void gmx_bcast(int nbytes,void *b,const t_commrec *cr);
87 /* Broadcast nbytes bytes from the master to cr->mpi_comm_mygroup */
89 extern void gmx_bcast_sim(int nbytes,void *b,const t_commrec *cr);
90 /* Broadcast nbytes bytes from the sim master to cr->mpi_comm_mysim */
92 extern void gmx_sumi(int nr,int r[],const t_commrec *cr);
93 /* Calculate the global sum of an array of ints */
95 extern void gmx_sumf(int nr,float r[],const t_commrec *cr);
96 /* Calculate the global sum of an array of floats */
98 extern void gmx_sumd(int nr,double r[],const t_commrec *cr);
99 /* Calculate the global sum of an array of doubles */
101 #ifdef GMX_MPI
102 extern void gmx_sumf_comm(int nr,float r[],MPI_Comm mpi_comm);
103 /* Calculate the global sum of an array of floats */
105 extern void gmx_sumd_comm(int nr,double r[],MPI_Comm mpi_comm);
106 /* Calculate the global sum of an array of doubles */
107 #endif
109 extern void gmx_sumi_sim(int nr,int r[],const gmx_multisim_t *ms);
110 /* Calculate the sum over the simulations of an array of ints */
112 extern void gmx_sumf_sim(int nr,float r[],const gmx_multisim_t *ms);
113 /* Calculate the sum over the simulations of an array of floats */
115 extern void gmx_sumd_sim(int nr,double r[],const gmx_multisim_t *ms);
116 /* Calculate the sum over the simulations of an array of doubles */
118 extern void gmx_abort(int nodeid,int nnodes,int errorno);
119 /* Abort the parallel run */
121 extern void gmx_finalize(void);
123 /* Finish the parallel run in an ordered manner */
125 #ifdef GMX_DOUBLE
126 #define gmx_sum_comm gmx_sumd_comm
127 #define gmx_sum gmx_sumd
128 #define gmx_sum_sim gmx_sumd_sim
129 #else
130 #define gmx_sum_comm gmx_sumf_comm
131 #define gmx_sum gmx_sumf
132 #define gmx_sum_sim gmx_sumf_sim
133 #endif
135 #ifdef DEBUG_GMX
136 #define debug_gmx() do { FILE *fp=debug ? debug : stderr;\
137 if (bDebugMode()) fprintf(fp,"NODEID=%d, %s %d\n",gmx_mpi_initialized() ? gmx_node_rank() : -1,__FILE__,__LINE__); fflush(fp); } while (0)
138 #else
139 #define debug_gmx()
140 #endif
142 #ifdef __cplusplus
144 #endif
147 #endif /* _network_h */