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