added Verlet scheme and NxN non-bonded functionality
[gromacs.git] / include / types / simple.h
blobc9be7a06c1e46018cfad1208551de544a4e0ab33
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 * GRoups of Organic Molecules in ACtion for Science
36 #ifndef _simple_h
37 #define _simple_h
39 /* Dont remove this instance of HAVE_CONFIG_H!!!
41 * We dont _require_ config.h here, but IF one is
42 * available it might contain valuable information about simple types
43 * that helps us automate things better and avoid bailing out.
45 * Note that this does not have to be the gromacs config.h - several
46 * package setups define these simple types.
48 #ifdef HAVE_CONFIG_H
49 # include <config.h>
50 #endif
52 /* Information about integer data type sizes */
53 #include <limits.h>
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 #if 0
60 #endif
63 #define XX 0 /* Defines for indexing in */
64 #define YY 1 /* vectors */
65 #define ZZ 2
66 #define DIM 3 /* Dimension of vectors */
67 #define XXXX 0 /* defines to index matrices */
68 #define XXYY 1
69 #define XXZZ 2
70 #define YYXX 3
71 #define YYYY 4
72 #define YYZZ 5
73 #define ZZXX 6
74 #define ZZYY 7
75 #define ZZZZ 8
77 /* There is no standard size for 'bool' in C++, so when
78 * we previously defined it to int for C code the data types
79 * (and structs) would have different size depending on your compiler,
80 * both at gromacs build time and when you use the library.
81 * The only way around this is to NOT assume anything about the C++ type,
82 * so we cannot use the name 'bool' in our C code anymore.
85 typedef int gmx_bool;
87 #ifndef FALSE
88 # define FALSE 0
89 #endif
90 #ifndef TRUE
91 # define TRUE 1
92 #endif
93 #define BOOL_NR 2
96 typedef int atom_id; /* To indicate an atoms id */
97 #define NO_ATID (atom_id)(~0) /* Use this to indicate invalid atid */
99 /*! \brief Double precision accuracy */
100 #define GMX_DOUBLE_EPS 1.11022302E-16
102 /*! \brief Maximum double precision value - reduced 1 unit in last digit for MSVC */
103 #define GMX_DOUBLE_MAX 1.79769312E+308
105 /*! \brief Minimum double precision value */
106 #define GMX_DOUBLE_MIN 2.22507386E-308
108 /*! \brief Single precision accuracy */
109 #define GMX_FLOAT_EPS 5.96046448E-08
111 /*! \brief Maximum single precision value - reduced 1 unit in last digit for MSVC */
112 #define GMX_FLOAT_MAX 3.40282346E+38
114 /*! \brief Minimum single precision value */
115 #define GMX_FLOAT_MIN 1.17549435E-38
118 /* Check whether we already have a real type! */
119 #ifdef GMX_DOUBLE
121 #ifndef HAVE_REAL
122 typedef double real;
123 #define HAVE_REAL
124 #endif
126 #define GMX_MPI_REAL MPI_DOUBLE
127 #define GMX_REAL_EPS GMX_DOUBLE_EPS
128 #define GMX_REAL_MIN GMX_DOUBLE_MIN
129 #define GMX_REAL_MAX GMX_DOUBLE_MAX
130 #define gmx_real_fullprecision_pfmt "%21.14e"
131 #else
133 #ifndef HAVE_REAL
134 typedef float real;
135 #define HAVE_REAL
136 #endif
138 #define GMX_MPI_REAL MPI_FLOAT
139 #define GMX_REAL_EPS GMX_FLOAT_EPS
140 #define GMX_REAL_MIN GMX_FLOAT_MIN
141 #define GMX_REAL_MAX GMX_FLOAT_MAX
142 #define gmx_real_fullprecision_pfmt "%14.7e"
143 #endif
145 typedef real rvec[DIM];
147 typedef double dvec[DIM];
149 typedef real matrix[DIM][DIM];
151 typedef real tensor[DIM][DIM];
153 typedef int ivec[DIM];
155 typedef int imatrix[DIM][DIM];
158 /* For the step count type gmx_large_int_t we aim for 8 bytes (64bit),
159 * but we might only be able to get 4 bytes (32bit).
161 * We first try to find a type without reyling on any SIZEOF_XXX defines.
163 * Avoid using "long int" if we can. This type is really dangerous,
164 * since the width frequently depends on compiler options, and they
165 * might not be set correctly when (buggy) Cmake is detecting things.
166 * Instead, start by looking for "long long", and just go down if we
167 * have to (rarely on new systems). /EL 20100810
169 #if ( (defined SIZEOF_LONG_LONG_INT && SIZEOF_LONG_LONG_INT==8) || (defined LLONG_MAX && LLONG_MAX==9223372036854775807LL) )
171 /* Long long int is 64 bit */
172 typedef long long int gmx_large_int_t;
173 #define gmx_large_int_fmt "lld"
174 #define gmx_large_int_pfmt "%lld"
175 #define SIZEOF_GMX_LARGE_INT 8
176 #define GMX_LARGE_INT_MAX 9223372036854775807LL
177 #define GMX_LARGE_INT_MIN (-GMX_LARGE_INT_MAX - 1LL)
178 #define GMX_MPI_LARGE_INT MPI_LONG_LONG_INT
180 #elif ( (defined SIZEOF_LONG_INT && SIZEOF_LONG_INT==8) || (defined LONG_MAX && LONG_MAX==9223372036854775807L) )
182 /* Long int is 64 bit */
183 typedef long int gmx_large_int_t;
184 #define gmx_large_int_fmt "ld"
185 #define gmx_large_int_pfmt "%ld"
186 #define SIZEOF_GMX_LARGE_INT 8
187 #define GMX_LARGE_INT_MAX 9223372036854775807LL
188 #define GMX_LARGE_INT_MIN (-GMX_LARGE_INT_MAX - 1LL)
189 #define GMX_MPI_LARGE_INT MPI_LONG_INT
191 #elif ( (defined SIZEOF_INT && SIZEOF_INT==8) || (defined INT_MAX && INT_MAX==9223372036854775807L) )
193 /* int is 64 bit */
194 typedef int gmx_large_int_t;
195 #define gmx_large_int_fmt "d"
196 #define gmx_large_int_pfmt "%d"
197 #define SIZEOF_GMX_LARGE_INT 8
198 #define GMX_LARGE_INT_MAX 9223372036854775807LL
199 #define GMX_LARGE_INT_MIN (-GMX_LARGE_INT_MAX - 1LL)
200 #define GMX_MPI_LARGE_INT MPI_INT
202 #elif ( (defined INT_MAX && INT_MAX==2147483647) || (defined SIZEOF_INT && SIZEOF_INT==4) )
204 /* None of the above worked, try a 32 bit integer */
205 typedef int gmx_large_int_t;
206 #define gmx_large_int_fmt "d"
207 #define gmx_large_int_pfmt "%d"
208 #define SIZEOF_GMX_LARGE_INT 4
209 #define GMX_LARGE_INT_MAX 2147483647
210 #define GMX_LARGE_INT_MIN (-GMX_LARGE_INT_MAX - 1)
211 #define GMX_MPI_LARGE_INT MPI_INT
213 #else
215 #error "Cannot find any 32 or 64 bit integer data type. Please extend the gromacs simple.h file!"
217 #endif
220 /* Try to define suitable inline keyword for gmx_inline.
221 * Set it to empty if we cannot find one (and dont complain to the user)
223 #ifndef __cplusplus
225 #ifdef __GNUC__
226 /* GCC */
227 # define gmx_inline __inline__
228 #elif (defined(__INTEL_COMPILER) || defined(__ECC)) && defined(__ia64__)
229 /* ICC */
230 # define gmx_inline __inline__
231 #elif defined(__PATHSCALE__)
232 /* Pathscale */
233 # define gmx_inline __inline__
234 #elif defined(__PGIC__)
235 /* Portland */
236 # define gmx_inline __inline
237 #elif defined _MSC_VER
238 /* MSVC */
239 # define gmx_inline __inline
240 #elif defined(__xlC__)
241 /* IBM */
242 # define gmx_inline __inline
243 #else
244 # define gmx_inline
245 #endif
247 #else
248 # define gmx_inline inline
249 #endif
252 /* Restrict keywords. Note that this has to be done for C++ too. */
253 #ifdef __GNUC__
254 /* GCC */
255 # define gmx_restrict __restrict__
256 #elif (defined(__INTEL_COMPILER) || defined(__ECC)) && defined(__ia64__)
257 /* ICC */
258 # define gmx_restrict __restrict__
259 #elif defined(__PATHSCALE__)
260 /* Pathscale */
261 # define gmx_restrict __restrict
262 #elif defined(__PGIC__)
263 /* Portland */
264 # define gmx_restrict __restrict
265 #elif defined _MSC_VER
266 /* MSVC */
267 # define gmx_restrict __restrict
268 #elif defined(__xlC__)
269 /* IBM */
270 # define gmx_restrict __restrict
271 #else
272 # define gmx_restrict
273 #endif
276 /* Standard sizes for char* string buffers */
277 #define STRLEN 4096
278 #define BIG_STRLEN 1048576
281 #ifdef __cplusplus
283 #endif
285 #endif