APEMoST

src/debug.h

Go to the documentation of this file.
00001 /*
00002     APEMoST - Automated Parameter Estimation and Model Selection Toolkit
00003     Copyright (C) 2009  Johannes Buchner
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #ifndef DEBUGHELPER
00020 #define DEBUGHELPER
00021 
00022 #include <stdio.h>
00023 
00024 #ifdef __NEVER_SET_FOR_DOCUMENTATION_ONLY
00025 
00031 #define DEBUG
00032 #endif
00033 
00034 #ifdef DEBUG
00035 #define IFDEBUG if(1)
00036 #else
00037 #define IFDEBUG if(0)
00038 #endif
00039 
00040 #ifdef __NEVER_SET_FOR_DOCUMENTATION_ONLY
00041 
00052 #define SEGV
00053 #endif
00054 
00055 #ifdef SEGV
00056 #define IFSEGV if(1)
00057 #else
00058 #define IFSEGV if(0)
00059 #endif
00060 
00061 #ifdef WAIT
00062 #define IFWAIT if(1)
00063 #else
00064 #define IFWAIT if(0)
00065 #endif
00066 
00067 #ifdef __NEVER_SET_FOR_DOCUMENTATION_ONLY
00068 
00071 #define VERBOSE
00072 #endif
00073 
00074 #ifdef VERBOSE
00075 #define IFVERBOSE if(1)
00076 #else
00077 #define IFVERBOSE if(0)
00078 #endif
00079 
00080 #include "memory.h"
00081 #include "mcmc.h"
00082 
00083 /* http://www.decompile.com/cpp/faq/file_and_line_error_string.htm */
00084 #define STRINGIFY(x) #x
00085 #define TOSTRING(x) STRINGIFY(x)
00086 #define AT __FILE__ ":" TOSTRING(__LINE__)
00087 
00088 #define debug(str)        IFDEBUG { printf("\tDEBUG[%s]: %s\n", AT, str); fflush(NULL); }
00089 #define dump_i(str, var)  IFDEBUG { printf("\tDEBUG[%s]: %s: %i\n", AT, str, var); fflush(NULL); }
00090 #define dump_ui(str, var) IFDEBUG { printf("\tDEBUG[%s]: %s: %u\n", AT, str, var); fflush(NULL); }
00091 #define dump_d(str, var)  IFDEBUG { printf("\tDEBUG[%s]: %s: %f\n", AT, str, var); fflush(NULL); }
00092 #define dump_l(str, var)  IFDEBUG { printf("\tDEBUG[%s]: %s: %l\n", AT, str, var); fflush(NULL); }
00093 #define dump_ul(str, var) IFDEBUG { printf("\tDEBUG[%s]: %s: %lu\n", AT, str, var); fflush(NULL); }
00094 #define dump_size(str, var) IFDEBUG { printf("\tDEBUG[%s]: %s: %lu\n", AT, str, (unsigned long)var); fflush(NULL); }
00095 #define dump_i_s(str, index, var) \
00096                           IFDEBUG { printf("\tDEBUG[%s]: %s[%i]: %s\n", AT, str, index, var); fflush(NULL); }
00097 #define dump_s(str, var)  IFDEBUG { printf("\tDEBUG[%s]: %s: %s\n", AT, str, var); fflush(NULL); }
00098 #define dump_p(str, var)  IFDEBUG { printf("\tDEBUG[%s]: %s: %p\n", AT, str, var); fflush(NULL); }
00099 #define dump_v(str, v)    IFDEBUG { printf("\tDEBUG[%s]: %s: ", AT, str); dump_vectorln(v); fflush(NULL); }
00100 #define dump_m(str, m)    IFDEBUG { printf("\tDEBUG[%s]: %s\n", AT, str); dump(m); fflush(NULL); }
00101 
00102 void dump_mcmc(const mcmc * m);
00103 void dump_vector(const gsl_vector * v);
00104 void dump_vectorln(const gsl_vector * v);
00105 
00106 #define require(x) (x) /* there is a gsl handler so we don't need that */
00107 #ifndef require
00108 void require(const int returncode);
00109 #endif
00110 
00111 #endif
00112