3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
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
33 * GRoups of Organic Molecules in ACtion for Science
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.
52 /* Information about integer data type sizes */
63 #define XX 0 /* Defines for indexing in */
64 #define YY 1 /* vectors */
66 #define DIM 3 /* Dimension of vectors */
67 #define XXXX 0 /* defines to index matrices */
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.
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! */
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"
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"
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) )
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
215 #error "Cannot find any 32 or 64 bit integer data type. Please extend the gromacs simple.h file!"
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)
227 # define gmx_inline __inline__
228 #elif (defined(__INTEL_COMPILER) || defined(__ECC)) && defined(__ia64__)
230 # define gmx_inline __inline__
231 #elif defined(__PATHSCALE__)
233 # define gmx_inline __inline__
234 #elif defined(__PGIC__)
236 # define gmx_inline __inline
237 #elif defined _MSC_VER
239 # define gmx_inline __inline
240 #elif defined(__xlC__)
242 # define gmx_inline __inline
248 # define gmx_inline inline
252 /* Restrict keywords. Note that this has to be done for C++ too. */
255 # define gmx_restrict __restrict__
256 #elif (defined(__INTEL_COMPILER) || defined(__ECC)) && defined(__ia64__)
258 # define gmx_restrict __restrict__
259 #elif defined(__PATHSCALE__)
261 # define gmx_restrict __restrict
262 #elif defined(__PGIC__)
264 # define gmx_restrict __restrict
265 #elif defined _MSC_VER
267 # define gmx_restrict __restrict
268 #elif defined(__xlC__)
270 # define gmx_restrict __restrict
272 # define gmx_restrict
276 /* Standard sizes for char* string buffers */
278 #define BIG_STRLEN 1048576