common.h

Go to the documentation of this file.
00001 
00007 /*
00008    common definitions for namd.
00009 */
00010 
00011 #ifndef COMMON_H
00012 #define COMMON_H
00013 
00014 #if !defined(WIN32) || defined(__CYGWIN__)
00015 #include <unistd.h>
00016 #endif
00017 #include <stdio.h>
00018 #include <limits.h>
00019 
00020 #if ( INT_MAX == 2147483647L )
00021 typedef int     int32;
00022 #elif ( SHRT_MAX == 2147483647L )
00023 typedef short   int32;
00024 #endif
00025 
00026 #ifdef _MSC_VER
00027 typedef __int64 int64;
00028 #else
00029 #if ( INT_MAX == 9223372036854775807LL )
00030 typedef int int64;
00031 #elif ( LONG_MAX == 9223372036854775807LL )
00032 typedef long int64;
00033 #else
00034 typedef long long int64;
00035 #endif
00036 #endif
00037 
00038 #if defined(PLACEMENT_NEW)
00039 void * ::operator new (size_t, void *p) { return p; }
00040 #elif defined(PLACEMENT_NEW_GLOBAL)
00041 void * operator new (size_t, void *p) { return p; }
00042 #endif
00043 
00044 #define COULOMB 332.0636
00045 #define BOLTZMANN 0.001987191
00046 #define TIMEFACTOR 48.88821
00047 #define PRESSUREFACTOR 6.95E4
00048 #define PDBVELFACTOR 20.45482706
00049 #define PDBVELINVFACTOR (1.0/PDBVELFACTOR)
00050 #define PNPERKCALMOL 69.479
00051 
00052 //
00053 // Defining macro namdnearbyint(X).
00054 //
00055 // Some plagtforms don't have nearbyint or round, so we'll define one
00056 // that works everywhere.
00057 //
00058 // Use namdnearbyint(X) instead of rint(X) because rint() is sensitive
00059 // to the current rounding mode and floor() is not.  It's just safer.
00060 //
00061 #ifdef ARCH_POWERPC
00062 #ifdef POWERPC_TANINT
00063 // round for BlueGeneQ (and others that set POWERPC_TANINT)
00064 extern "builtin" double __tanint(double); // IEEE round
00065 #define namdnearbyint(x)  __tanint(x)
00066 #else
00067 // round for Linux POWER
00068 #include <builtins.h>
00069 #include <tgmath.h>
00070 #define namdnearbyint(x)  (round(x))
00071 #endif
00072 #else
00073 // fall back should work everywhere
00074 #define namdnearbyint(x)  floor((x)+0.5)
00075 #endif
00076 //
00077 // End defining macro namdnearbyint(X).
00078 //
00079 
00080 #ifndef PI
00081 #define PI      3.141592653589793
00082 #endif
00083 
00084 #ifndef TWOPI
00085 #define TWOPI   2.0 * PI
00086 #endif
00087 
00088 #ifndef ONE
00089 #define ONE     1.000000000000000
00090 #endif
00091 
00092 #ifndef ZERO
00093 #define ZERO    0.000000000000000
00094 #endif
00095 
00096 #ifndef SMALLRAD
00097 #define SMALLRAD      0.0005
00098 #endif
00099 
00100 #ifndef SMALLRAD2
00101 #define SMALLRAD2     SMALLRAD*SMALLRAD
00102 #endif
00103 
00104 /* Define the size for Real and BigReal.  Real is usually mapped to float */
00105 /* and BigReal to double.  To get BigReal mapped to float, use the        */
00106 /* -DSHORTREALS compile time option                                       */
00107 typedef float   Real;
00108 
00109 #ifdef SHORTREALS
00110 typedef float   BigReal;
00111 #else
00112 typedef double  BigReal;
00113 #endif
00114 
00115 #ifndef FALSE
00116 #define FALSE 0
00117 #define TRUE 1
00118 #endif
00119 
00120 #ifndef NO
00121 #define NO 0
00122 #define YES 1
00123 #endif
00124 
00125 #ifndef STRINGNULL
00126 #define STRINGNULL '\0'
00127 #endif
00128 
00129 #define MAX_NEIGHBORS 27
00130 
00131 typedef int Bool;
00132 
00133 class Communicate;
00134 
00135 // global functions
00136 void NAMD_quit(const char *);
00137 void NAMD_die(const char *);
00138 void NAMD_err(const char *);  // also prints strerror(errno)
00139 void NAMD_bug(const char *);
00140 int NAMD_file_exists(const char *filename);
00141 void NAMD_backup_file(const char *filename, const char *extension = 0);
00142 int NAMD_open_text(const char *fname, int append=0);
00143 void NAMD_write(int fd, const char *buf, size_t count, const char *fname = "in NAMD_write()"); // NAMD_die on error
00144 void NAMD_close(int fd, const char *fname);
00145 char *NAMD_stringdup(const char *);
00146 FILE *Fopen(const char *filename, const char *mode);
00147 int  Fclose(FILE *fout);
00148 
00149 // message tags
00150 #define SIMPARAMSTAG    100     //  Tag for SimParameters class
00151 #define STATICPARAMSTAG 101     //  Tag for Parameters class
00152 #define MOLECULETAG     102     //  Tag for Molecule class
00153 #define FULLTAG 104
00154 #define FULLFORCETAG 105
00155 #define DPMTATAG 106
00156 #define GRIDFORCEGRIDTAG 107
00157 #define COMPUTEMAPTAG 108
00158 
00159 #define CYCLE_BARRIER   0
00160 #define PME_BARRIER     0
00161 #define STEP_BARRIER    0
00162 
00163 #define USE_BARRIER   (CYCLE_BARRIER || PME_BARRIER || STEP_BARRIER)
00164 
00165 
00166 // DMK - Atom Separation (water vs. non-water)
00167 //   Setting this define to a non-zero value will cause the
00168 //   HomePatches to separate the hydrogen groups in their
00169 //   HomePatch::atom lists (all water molecules first, in arbitrary
00170 //   order, followed by all non-waters, in arbitrary order).
00171 #define NAMD_SeparateWaters    0
00172 
00173 // DMK - Atom Sort
00174 //   Setting this define to a non-zero value will cause the nonbonded compute
00175 //   objects (pairs, not selfs) to sort the atoms along a line connecting the
00176 //   center of masses of the two patches.  This is only done during timesteps
00177 //   where the pairlists are being generated.  As the pairlist is being
00178 //   generated, once an atom that is far enough away along the line is found,
00179 //   the remaining atoms are automatically skipped (avoiding a distance
00180 //   calculation/check for them).
00181 // NOTE: The "less branches" flag toggles between two versions of merge sort.
00182 //   When it is non-zero, a version that has fewer branches (but more integer
00183 //   math) is used.  This version may or may not be faster or some architectures.
00184 #define NAMD_ComputeNonbonded_SortAtoms                   1
00185   #define NAMD_ComputeNonbonded_SortAtoms_LessBranches    1
00186 
00187 // plf -- alternate water models
00188 #define WAT_TIP3 0
00189 #define WAT_TIP4 1
00190 #define WAT_SWM4 2  /* Drude model (5 charge sites) */
00191 
00192 
00193 #include "converse.h"
00194 
00195 #endif
00196 

Generated on Mon Nov 20 01:17:10 2017 for NAMD by  doxygen 1.4.7