ESPResSo 3.2.0-167-g2c9ead1-git
Extensible Simulation Package for Soft Matter Research
debug.h
Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2010,2012,2013 The ESPResSo project
00003   Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 
00004     Max-Planck-Institute for Polymer Research, Theory Group
00005   
00006   This file is part of ESPResSo.
00007   
00008   ESPResSo is free software: you can redistribute it and/or modify
00009   it under the terms of the GNU General Public License as published by
00010   the Free Software Foundation, either version 3 of the License, or
00011   (at your option) any later version.
00012   
00013   ESPResSo is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016   GNU General Public License for more details.
00017   
00018   You should have received a copy of the GNU General Public License
00019   along with this program.  If not, see <http://www.gnu.org/licenses/>. 
00020 */
00021 /** \file debug.h
00022  This file controls debug facilities. 
00023 
00024  The implementation is found in
00025  \ref debug.c "debug.c".
00026 
00027  For every define there exists a macro that can be used to encapsulate short lines (like printf("...",...);)
00028  of code that should be executed iff the respective *_DEBUG macro is defined.
00029 */
00030 
00031 #include "config.h"
00032 
00033 #ifdef MEM_DEBUG
00034 #ifdef __GNUC__
00035 #define realloc(v,s) __realloc((v),(s),__FILE__, __LINE__)
00036 #define malloc(s) __malloc((s),__FILE__, __LINE__)
00037 #define free(v) __free((v),__FILE__, __LINE__)
00038 #else
00039 #define realloc(v,s) __realloc((v),(s), "no line info", 0)
00040 #define malloc(s) __malloc((s), "no line info", 0)
00041 #define free(v) __free((v),"no line info", 0)
00042 #endif
00043 
00044 /** memory allocation test routine */
00045 void *__realloc(void *old, unsigned int size, char *where, int line);
00046 
00047 /** memory allocation test routine */
00048 void *__malloc(unsigned int size, char *where, int line);
00049 
00050 /** memory allocation test routine */
00051 void __free(void *p, char *where, int line);
00052 
00053 #endif
00054 
00055 #if defined FORCE_CORE || defined MPI_CORE
00056 /** this functions kills the task with SIGSEGV */
00057 void core();
00058 #endif
00059 
00060 #ifdef ADDITIONAL_CHECKS
00061 
00062 /** this performs a lot of tests which will very likely detect corruptions of
00063     \ref local_particles and the cell structure.
00064 */
00065 void check_particle_consistency();
00066 
00067 /** check the consistency of the cells and particle_node. Called from
00068     mpi_bcast_event(CHECK_PARTICLES)
00069 */
00070 void check_particles();
00071 
00072 #endif
00073 
00074 /** Print all particle positions contained in \ref cells::cells array. */
00075 void print_particle_positions();
00076 /** Print all particle forces contained in \ref cells::cells array. */
00077 void print_particle_forces();
00078 
00079 /** by setting this variable to 1, a regular exit is
00080     indicated. In that case, no core dump is generated.
00081 */
00082 extern int regular_exit;
00083 
00084 /** Identity of the particle to check extensively if ONEPART_DEBUG is defined. */
00085 extern int check_id;
00086 
00087 #ifdef COMM_DEBUG
00088 #define COMM_TRACE(cmd) { cmd; }
00089 #else
00090 /** Equals { cmd } iff COMM_DEBUG is set. */
00091 #define COMM_TRACE(cmd)
00092 #endif
00093 
00094 #ifdef EVENT_DEBUG
00095 #define EVENT_TRACE(cmd) { cmd; }
00096 #else
00097 /** Equals { cmd } iff EVENT_DEBUG is set. */
00098 #define EVENT_TRACE(cmd)
00099 #endif
00100 
00101 #ifdef PARTICLE_DEBUG
00102 #define PART_TRACE(cmd) { cmd; }
00103 #else
00104 /** Equals { cmd } iff PARTICLE_DEBUG is set. */
00105 #define PART_TRACE(cmd)
00106 #endif
00107 
00108 #ifdef INTEG_DEBUG
00109 #define INTEG_TRACE(cmd) { cmd; }
00110 #else
00111 /** Equals { cmd } iff INTEG_DEBUG is set. */
00112 #define INTEG_TRACE(cmd)
00113 #endif
00114 
00115 #ifdef CELL_DEBUG
00116 #define CELL_TRACE(cmd) { cmd;  }
00117 #else
00118 /** Equals { cmd } iff CELL_DEBUG is set. */
00119 #define CELL_TRACE(cmd)
00120 #endif
00121 
00122 #ifdef GHOST_DEBUG
00123 #define GHOST_TRACE(cmd) { cmd;  }
00124 #else
00125 /** Equals { cmd } iff GHOST_DEBUG is set. */
00126 #define GHOST_TRACE(cmd)
00127 #endif
00128 
00129 #ifdef HALO_DEBUG
00130 #define HALO_TRACE(cmd) { cmd; }
00131 #else
00132 /** Equals { cmd  } iff HALO_DEBUG is set. */
00133 #define HALO_TRACE(cmd)
00134 #endif
00135 
00136 #ifdef GRID_DEBUG
00137 #define GRID_TRACE(cmd) { cmd;  }
00138 #else
00139 /** Equals { cmd } iff GRID_DEBUG is set. */
00140 #define GRID_TRACE(cmd)
00141 #endif
00142 
00143 #ifdef LATTICE_DEBUG
00144 #define LATTICE_TRACE(cmd) { cmd; }
00145 #else
00146 /** Equals { cmd } iff LATTICE_DEBUG is set. */
00147 #define LATTICE_TRACE(cmd)
00148 #endif
00149 
00150 #ifdef FORCE_DEBUG
00151 #define FORCE_TRACE(cmd) { cmd;  }
00152 #else
00153 /** Equals { cmd } iff FORCE_DEBUG is set. */
00154 #define FORCE_TRACE(cmd)
00155 #endif
00156 
00157 #ifdef VERLET_DEBUG
00158 #define VERLET_TRACE(cmd) { cmd;  }
00159 #else
00160 /** Equals { cmd } iff VERLET_DEBUG is set. */
00161 #define VERLET_TRACE(cmd)
00162 #endif
00163 
00164 #ifdef P3M_DEBUG
00165 #define P3M_TRACE(cmd) { cmd;  }
00166 #else
00167 /** Equals { cmd } iff P3M_DEBUG is set. */
00168 #define P3M_TRACE(cmd)
00169 #endif
00170 
00171 #ifdef MDLC_DEBUG
00172 #define MDLC_TRACE(cmd) { cmd; }
00173 #else
00174 #define MDLC_TRACE(cmd)
00175 #endif
00176 
00177 #ifdef MAGGS_DEBUG
00178 #define MAGGS_TRACE(cmd) { cmd;  }
00179 #else
00180 /** Equals { cmd } iff MAGGS_DEBUG is set. */
00181 #define MAGGS_TRACE(cmd)
00182 #endif
00183 
00184 #ifdef FFT_DEBUG
00185 #define FFT_TRACE(cmd) { cmd; }
00186 #else
00187 /** Equals { cmd } iff FFT_DEBUG is set. */
00188 #define FFT_TRACE(cmd)
00189 #endif
00190 
00191 #ifdef RANDOM_DEBUG
00192 #define RANDOM_TRACE(cmd) { cmd; }
00193 #else
00194 #define RANDOM_TRACE(cmd)
00195 #endif
00196 
00197 #ifdef THERMO_DEBUG
00198 #define THERMO_TRACE(cmd) { cmd; }
00199 #else
00200 #define THERMO_TRACE(cmd)
00201 #endif
00202 
00203 #ifdef LJ_DEBUG
00204 #define LJ_TRACE(cmd) { cmd; }
00205 #else
00206 #define LJ_TRACE(cmd)
00207 #endif
00208 
00209 #ifdef MORSE_DEBUG
00210 #define MORSE_TRACE(cmd) { cmd; }
00211 #else
00212 #define MORSE_TRACE(cmd)
00213 #endif
00214 
00215 #ifdef BUCK_DEBUG
00216 #define BUCK_TRACE(cmd) { cmd; }
00217 #else
00218 #define BUCK_TRACE(cmd)
00219 #endif
00220 
00221 #ifdef ESR_DEBUG
00222 #define ESR_TRACE(cmd) { cmd; }
00223 #else
00224 #define ESR_TRACE(cmd)
00225 #endif
00226 
00227 #ifdef ESK_DEBUG
00228 #define ESK_TRACE(cmd) { cmd; }
00229 #else
00230 #define ESK_TRACE(cmd)
00231 #endif
00232 
00233 #ifdef FENE_DEBUG
00234 #define FENE_TRACE(cmd) { cmd; }
00235 #else
00236 #define FENE_TRACE(cmd)
00237 #endif
00238 
00239 #ifdef GHOST_FORCE_DEBUG
00240 #define GHOST_FORCE_TRACE(cmd) { cmd; }
00241 #else
00242 #define GHOST_FORCE_TRACE(cmd)
00243 #endif
00244 
00245 #ifdef ONEPART_DEBUG
00246 #define ONEPART_TRACE(cmd) { cmd; }
00247 #else
00248 #define ONEPART_TRACE(cmd)
00249 #endif
00250 
00251 #ifdef STAT_DEBUG
00252 #define STAT_TRACE(cmd) { cmd; }
00253 #else
00254 /** Equals { cmd } iff STAT_DEBUG is set. */
00255 #define STAT_TRACE(cmd)
00256 #endif
00257 
00258 #ifdef POLY_DEBUG
00259 #define POLY_TRACE(cmd) { cmd; }
00260 #else
00261 /** Equals { cmd } iff POLY_DEBUG is set. */
00262 #define POLY_TRACE(cmd)
00263 #endif
00264 
00265 #ifdef MOLFORCES_DEBUG
00266 #define MOLFORCES_TRACE(cmd) { cmd; }
00267 #else
00268 #define MOLFORCES_TRACE(cmd)
00269 #endif
00270 
00271 
00272 #ifdef PTENSOR_DEBUG
00273 #define PTENSOR_TRACE(cmd) { cmd; }
00274 #else
00275 #define PTENSOR_TRACE(cmd)
00276 #endif
00277 
00278 #ifdef LB_DEBUG
00279 #define LB_TRACE(cmd) { cmd; }
00280 #else
00281 /** Equals { cmd } iff LB_DEBUG is set. */
00282 #define LB_TRACE(cmd)
00283 #endif
00284 
00285 #ifdef NAN_DEBUG
00286 #define NANCHECK(expr) { if(isnan(expr)) fprintf(stderr, "nan in expression expr %s in %s:%d\n", #expr, __FILE__, __LINE__); }
00287 #else
00288 /** Equals { cmd } iff LB_DEBUG is set. */
00289 #define NANCHECK(expr)
00290 #endif