NAMD
common.h
Go to the documentation of this file.
1 
7 /*
8  common definitions for namd.
9 */
10 
11 #ifndef COMMON_H
12 #define COMMON_H
13 
14 #if !defined(WIN32) || defined(__CYGWIN__)
15 #include <unistd.h>
16 #endif
17 #include <stdio.h>
18 #include <limits.h>
19 
20 #if ( INT_MAX == 2147483647L )
21 typedef int int32;
22 #elif ( SHRT_MAX == 2147483647L )
23 typedef short int32;
24 #endif
25 
26 #ifdef _MSC_VER
27 typedef __int64 int64;
28 #else
29 #if ( INT_MAX == 9223372036854775807LL )
30 typedef int int64;
31 #elif ( LONG_MAX == 9223372036854775807LL )
32 typedef long int64;
33 #else
34 typedef long long int64;
35 #endif
36 #endif
37 
38 #if defined(PLACEMENT_NEW)
39 void * ::operator new (size_t, void *p) { return p; }
40 #elif defined(PLACEMENT_NEW_GLOBAL)
41 void * operator new (size_t, void *p) { return p; }
42 #endif
43 
44 #define COULOMB 332.0636
45 #define BOLTZMANN 0.001987191
46 #define TIMEFACTOR 48.88821
47 #define PRESSUREFACTOR 6.95E4
48 #define PDBVELFACTOR 20.45482706
49 #define PDBVELINVFACTOR (1.0/PDBVELFACTOR)
50 #define PNPERKCALMOL 69.479
51 
52 //
53 // Defining macro namdnearbyint(X).
54 //
55 // Some plagtforms don't have nearbyint or round, so we'll define one
56 // that works everywhere.
57 //
58 // Use namdnearbyint(X) instead of rint(X) because rint() is sensitive
59 // to the current rounding mode and floor() is not. It's just safer.
60 //
61 #ifdef ARCH_POWERPC
62 #ifdef POWERPC_TANINT
63 // round for BlueGeneQ (and others that set POWERPC_TANINT)
64 extern "builtin" double __tanint(double); // IEEE round
65 #define namdnearbyint(x) __tanint(x)
66 #else
67 // round for Linux POWER
68 #include <builtins.h>
69 #include <tgmath.h>
70 #define namdnearbyint(x) (round(x))
71 #endif
72 #else
73 // fall back should work everywhere
74 #define namdnearbyint(x) floor((x)+0.5)
75 #endif
76 //
77 // End defining macro namdnearbyint(X).
78 //
79 
80 #ifndef PI
81 #define PI 3.141592653589793
82 #endif
83 
84 #ifndef TWOPI
85 #define TWOPI 2.0 * PI
86 #endif
87 
88 #ifndef ONE
89 #define ONE 1.000000000000000
90 #endif
91 
92 #ifndef ZERO
93 #define ZERO 0.000000000000000
94 #endif
95 
96 #ifndef SMALLRAD
97 #define SMALLRAD 0.0005
98 #endif
99 
100 #ifndef SMALLRAD2
101 #define SMALLRAD2 SMALLRAD*SMALLRAD
102 #endif
103 
104 /* Define the size for Real and BigReal. Real is usually mapped to float */
105 /* and BigReal to double. To get BigReal mapped to float, use the */
106 /* -DSHORTREALS compile time option */
107 typedef float Real;
108 
109 #ifdef SHORTREALS
110 typedef float BigReal;
111 #else
112 typedef double BigReal;
113 #endif
114 
115 #ifndef FALSE
116 #define FALSE 0
117 #define TRUE 1
118 #endif
119 
120 #ifndef NO
121 #define NO 0
122 #define YES 1
123 #endif
124 
125 #ifndef STRINGNULL
126 #define STRINGNULL '\0'
127 #endif
128 
129 #define MAX_NEIGHBORS 27
130 
131 typedef int Bool;
132 
133 class Communicate;
134 
135 // global functions
136 void NAMD_quit(const char *);
137 void NAMD_die(const char *);
138 void NAMD_err(const char *); // also prints strerror(errno)
139 void NAMD_bug(const char *);
140 int NAMD_file_exists(const char *filename);
141 void NAMD_backup_file(const char *filename, const char *extension = 0);
142 int NAMD_open_text(const char *fname, int append=0);
143 void NAMD_write(int fd, const char *buf, size_t count, const char *fname = "in NAMD_write()"); // NAMD_die on error
144 void NAMD_close(int fd, const char *fname);
145 char *NAMD_stringdup(const char *);
146 FILE *Fopen(const char *filename, const char *mode);
147 int Fclose(FILE *fout);
148 
149 // message tags
150 #define SIMPARAMSTAG 100 // Tag for SimParameters class
151 #define STATICPARAMSTAG 101 // Tag for Parameters class
152 #define MOLECULETAG 102 // Tag for Molecule class
153 #define FULLTAG 104
154 #define FULLFORCETAG 105
155 #define DPMTATAG 106
156 #define GRIDFORCEGRIDTAG 107
157 #define COMPUTEMAPTAG 108
158 
159 #define CYCLE_BARRIER 0
160 #define PME_BARRIER 0
161 #define STEP_BARRIER 0
162 
163 #define USE_BARRIER (CYCLE_BARRIER || PME_BARRIER || STEP_BARRIER)
164 
165 
166 // DMK - Atom Separation (water vs. non-water)
167 // Setting this define to a non-zero value will cause the
168 // HomePatches to separate the hydrogen groups in their
169 // HomePatch::atom lists (all water molecules first, in arbitrary
170 // order, followed by all non-waters, in arbitrary order).
171 #define NAMD_SeparateWaters 0
172 
173 // DMK - Atom Sort
174 // Setting this define to a non-zero value will cause the nonbonded compute
175 // objects (pairs, not selfs) to sort the atoms along a line connecting the
176 // center of masses of the two patches. This is only done during timesteps
177 // where the pairlists are being generated. As the pairlist is being
178 // generated, once an atom that is far enough away along the line is found,
179 // the remaining atoms are automatically skipped (avoiding a distance
180 // calculation/check for them).
181 // NOTE: The "less branches" flag toggles between two versions of merge sort.
182 // When it is non-zero, a version that has fewer branches (but more integer
183 // math) is used. This version may or may not be faster or some architectures.
184 #define NAMD_ComputeNonbonded_SortAtoms 1
185  #define NAMD_ComputeNonbonded_SortAtoms_LessBranches 1
186 
187 // plf -- alternate water models
188 #define WAT_TIP3 0
189 #define WAT_TIP4 1
190 #define WAT_SWM4 2 /* Drude model (5 charge sites) */
191 
192 
193 #include "converse.h"
194 
195 #endif
196 
void NAMD_err(const char *err_msg)
Definition: common.C:102
int NAMD_open_text(const char *fname, int append)
Definition: common.C:194
void NAMD_quit(const char *err_msg)
Definition: common.C:64
short int32
Definition: dumpdcd.c:24
float Real
Definition: common.h:107
int NAMD_file_exists(const char *filename)
Definition: common.C:143
#define NAMD_write
Definition: dcdlib.C:24
#define NAMD_close
Definition: Output.C:52
char * NAMD_stringdup(const char *s)
Definition: common.C:50
void NAMD_bug(const char *err_msg)
Definition: common.C:123
int Bool
Definition: common.h:131
FILE * Fopen(const char *filename, const char *mode)
Definition: common.C:265
void NAMD_die(const char *err_msg)
Definition: common.C:83
void NAMD_backup_file(const char *filename, const char *extension)
Definition: common.C:159
int Fclose(FILE *fout)
Definition: common.C:359
long long int64
Definition: common.h:34
double BigReal
Definition: common.h:112