8 #include "svnversion.h"
18 #define _VERSION_ "v3.3.0"
28 #define _ERRORMSGSIZE_ 2048
29 typedef char ErrorMsg[_ERRORMSGSIZE_];
31 #define _FILENAMESIZE_ 256
32 typedef char FileName[_FILENAMESIZE_];
34 #define _SUFFIXNAMESIZE_ 4
36 #define _PI_ 3.1415926535897932384626433832795e0
38 #define _PIHALF_ 1.57079632679489661923132169164e0
40 #define _TWOPI_ 6.283185307179586476925286766559e0
42 #define _SQRT2_ 1.41421356237309504880168872421e0
44 #define _SQRT6_ 2.4494897427831780981972840747059e0
46 #define _SQRT_PI_ 1.77245385090551602729816748334e0
48 #define _E_ 2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003059921817413596629043572900334295260595630738132328627943490763233829880753195251019011573834187930702154089149934884167509244761460668082264800168477411853742345442437107539077744992069551702761838606261331384583000752044933826560297606737113200709328709127443747047230696977209310141692836819025515108657463772111252389784425056953696
50 #define _MAX_IT_ 10000
52 #define _QUADRATURE_MAX_ 250
54 #define _QUADRATURE_MAX_BG_ 800
60 #define _EPSILON_ 1.e-10
62 #define _OUTPUTPRECISION_ 12
64 #define _COLUMNWIDTH_ 24
66 #define _MAXTITLESTRINGLENGTH_ 8000
68 #define _DELIMITER_ "\t"
71 #define __CLASSDIR__ "."
74 #define MIN(a,b) (((a)<(b)) ? (a) : (b) )
75 #define MAX(a,b) (((a)<(b)) ? (b) : (a) )
76 #define SIGN(a) (((a)>0) ? 1. : -1. )
77 #define NRSIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a))
78 #define index_symmetric_matrix(i1,i2,N) (((i1)<=(i2)) ? ((i2)+N*(i1)-((i1)*((i1)+1))/2) : ((i1)+N*(i2)-((i2)*((i2)+1))/2))
87 void class_protect_sprintf(
char* dest,
char* tpl, ...);
88 void class_protect_fprintf(FILE* dest,
char* tpl, ...);
89 void* class_protect_memcpy(
void* dest,
void* from,
size_t sz);
92 int get_number_of_titles(
char * titlestring);
93 int file_exists(
const char *fname);
94 int compare_doubles(
const void * a,
96 int string_begins_with(
char* thestring,
char beginchar);
108 #define class_sprintf(string, format...) do { \
109 int _buffer_size_sprintf = snprintf(NULL, 0, format); \
110 snprintf(string, _buffer_size_sprintf+1, format); \
113 #define class_build_error_string(dest,tmpl,...) { \
115 class_protect_sprintf(FMsg,tmpl,__VA_ARGS__); \
116 class_protect_sprintf(dest,"%s(L:%d) :%s",__func__,__LINE__,FMsg); \
122 #define class_call_message(err_out,extra,err_mess) \
123 class_build_error_string(err_out,"error in %s;\n=>%s",extra,err_mess);
126 #define class_call_except(function, error_message_from_function, error_message_output,list_of_commands) { \
127 if (function == _FAILURE_) { \
128 class_call_message(error_message_output,#function,error_message_from_function); \
135 #define class_call_try(function, error_message_from_function, error_message_output,list_of_commands) { \
136 if (function == _FAILURE_) { \
137 class_call_message(error_message_output,#function,error_message_from_function); \
143 #define class_call(function, error_message_from_function, error_message_output) \
144 class_call_except(function, error_message_from_function,error_message_output,)
160 #define class_alloc_message(err_out,extra,sz) \
161 class_build_error_string(err_out,"could not allocate %s with size %d",extra,sz);
164 #define class_alloc(pointer, size, error_message_output) { \
165 pointer=(__typeof__(pointer))malloc(size); \
166 if (pointer == NULL) { \
169 class_alloc_message(error_message_output,#pointer, size_int); \
190 #define class_calloc(pointer, init,size, error_message_output) { \
191 pointer=(__typeof__(pointer))calloc(init,size); \
192 if (pointer == NULL) { \
195 class_alloc_message(error_message_output,#pointer, size_int); \
201 #define class_realloc(pointer, size, error_message_output) { \
202 pointer=(__typeof__(pointer))realloc(pointer,size); \
203 if (pointer == NULL) { \
206 class_alloc_message(error_message_output,#pointer, size_int); \
213 #define class_test_message(err_out,extra,args...) { \
214 ErrorMsg Optional_arguments; \
215 class_protect_sprintf(Optional_arguments,args); \
216 class_build_error_string(err_out,"condition (%s) is true; %s",extra,Optional_arguments); \
222 #define class_test_except(condition, error_message_output,list_of_commands, args...) { \
224 class_test_message(error_message_output,#condition, args); \
230 #define class_test(condition, error_message_output, args...) { \
232 class_test_message(error_message_output,#condition, args); \
250 #define class_stop(error_message_output,args...) { \
251 ErrorMsg Optional_arguments; \
252 class_protect_sprintf(Optional_arguments,args); \
253 class_build_error_string(error_message_output,"error; %s",Optional_arguments); \
259 #define class_open(pointer, filename, mode, error_output) { \
260 pointer=fopen(filename,mode); \
261 if (pointer == NULL) { \
262 class_build_error_string(error_output,"could not open %s with name %s and mode %s",#pointer,filename,#mode); \
268 #define class_define_index(index, \
271 number_of_indices) { \
273 index = running_index; \
274 running_index += number_of_indices; \
279 #define class_fprintf_double(file, \
282 if (condition == _TRUE_) \
283 fprintf(file,"%*.*e ",_COLUMNWIDTH_,_OUTPUTPRECISION_,output); \
286 #define class_fprintf_double_or_default(file, \
290 if (condition == _TRUE_) \
291 fprintf(file,"%*.*e ",_COLUMNWIDTH_,_OUTPUTPRECISION_,output); \
293 fprintf(file,"%*.*e ",_COLUMNWIDTH_,_OUTPUTPRECISION_,defaultvalue); \
296 #define class_fprintf_int(file, \
299 if (condition == _TRUE_) \
300 fprintf(file,"%*d%*s ", \
301 MAX(0,_COLUMNWIDTH_-_OUTPUTPRECISION_-5), \
302 output, _OUTPUTPRECISION_+5," "); \
305 #define class_fprintf_columntitle(file, \
309 if (condition == _TRUE_) \
310 fprintf(file,"%*s%2d:%-*s ", \
311 MAX(0,MIN(_COLUMNWIDTH_-_OUTPUTPRECISION_-6-3,_COLUMNWIDTH_-((int) strlen(title))-3)), \
312 "",colnum++,_OUTPUTPRECISION_+6,title); \
315 #define class_store_columntitle(titlestring, \
318 if (condition == _TRUE_){ \
319 strcat(titlestring,title); \
320 strcat(titlestring,_DELIMITER_); \
325 #define class_store_double(storage, \
329 if (condition == _TRUE_) \
330 storage[dataindex++] = value; \
333 #define class_store_double_or_default(storage, \
338 if (condition == _TRUE_) \
339 storage[dataindex++] = value; \
341 storage[dataindex++] = defaultvalue; \
345 #define class_print_species(name,type) \
346 printf("-> %-30s Omega = %-15g , omega = %-15g\n",name,pba->Omega0_##type,pba->Omega0_##type*pba->h*pba->h);
349 #define EVOLVER_PROTOTYPE \
350 int (*)(double, double *, double *, void *, ErrorMsg), \
351 double, double, double *, int *, \
352 int, void *, double, double, \
353 int (*)(double, void *, double *, ErrorMsg), \
354 double, double *, int, \
355 int (*)(double, double *, double *, int, void *, ErrorMsg), \
356 int (*)(double, double *, double *, void *, ErrorMsg), \
413 #define __ALLOCATE_PRECISION_PARAMETER__
414 #include "precisions.h"
415 #undef __ALLOCATE_PRECISION_PARAMETER__
ErrorMsg error_message
Definition: common.h:429
evolver_type
Definition: common.h:376
double smallest_allowed_variation
Definition: common.h:421
pk_def
Definition: common.h:387
@ delta_bc_squared
Definition: common.h:390
@ delta_tot_from_poisson_squared
Definition: common.h:391
@ delta_tot_squared
Definition: common.h:389
@ delta_m_squared
Definition: common.h:388
file_format
Definition: common.h:397
Definition: distortions.h:35
Definition: harmonic.h:17
Definition: perturbations.h:98
Definition: primordial.h:79
Definition: background.h:44
Definition: thermodynamics.h:59
Definition: transfer.h:74