8 #include "svnversion.h"
18 #define _VERSION_ "v3.2.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))
84 void class_protect_sprintf(
char* dest,
char* tpl,...);
85 void class_protect_fprintf(FILE* dest,
char* tpl,...);
86 void* class_protect_memcpy(
void* dest,
void* from,
size_t sz);
90 int get_number_of_titles(
char * titlestring);
91 int file_exists(
const char *fname);
92 int compare_doubles(
const void * a,
94 int string_begins_with(
char* thestring,
char beginchar);
98 #define class_build_error_string(dest,tmpl,...) { \
100 class_protect_sprintf(FMsg,tmpl,__VA_ARGS__); \
101 class_protect_sprintf(dest,"%s(L:%d) :%s",__func__,__LINE__,FMsg); \
107 #define class_call_message(err_out,extra,err_mess) \
108 class_build_error_string(err_out,"error in %s;\n=>%s",extra,err_mess);
111 #define class_call_except(function, error_message_from_function, error_message_output,list_of_commands) { \
112 if (function == _FAILURE_) { \
113 class_call_message(error_message_output,#function,error_message_from_function); \
120 #define class_call_try(function, error_message_from_function, error_message_output,list_of_commands) { \
121 if (function == _FAILURE_) { \
122 class_call_message(error_message_output,#function,error_message_from_function); \
128 #define class_call(function, error_message_from_function, error_message_output) \
129 class_call_except(function, error_message_from_function,error_message_output,)
132 #define class_call_parallel(function, error_message_from_function, error_message_output) { \
133 if (abort == _FALSE_) { \
134 if (function == _FAILURE_) { \
135 class_call_message(error_message_output,#function,error_message_from_function); \
145 #define class_alloc_message(err_out,extra,sz) \
146 class_build_error_string(err_out,"could not allocate %s with size %d",extra,sz);
149 #define class_alloc(pointer, size, error_message_output) { \
150 pointer=malloc(size); \
151 if (pointer == NULL) { \
154 class_alloc_message(error_message_output,#pointer, size_int); \
160 #define class_alloc_parallel(pointer, size, error_message_output) { \
162 if (abort == _FALSE_) { \
163 pointer=malloc(size); \
164 if (pointer == NULL) { \
167 class_alloc_message(error_message_output,#pointer, size_int); \
174 #define class_calloc(pointer, init,size, error_message_output) { \
175 pointer=calloc(init,size); \
176 if (pointer == NULL) { \
179 class_alloc_message(error_message_output,#pointer, size_int); \
185 #define class_realloc(pointer, newname, size, error_message_output) { \
186 pointer=realloc(newname,size); \
187 if (pointer == NULL) { \
190 class_alloc_message(error_message_output,#pointer, size_int); \
197 #define class_test_message(err_out,extra,args...) { \
198 ErrorMsg Optional_arguments; \
199 class_protect_sprintf(Optional_arguments,args); \
200 class_build_error_string(err_out,"condition (%s) is true; %s",extra,Optional_arguments); \
206 #define class_test_except(condition, error_message_output,list_of_commands, args...) { \
208 class_test_message(error_message_output,#condition, args); \
214 #define class_test(condition, error_message_output, args...) { \
216 class_test_message(error_message_output,#condition, args); \
221 #define class_test_parallel(condition, error_message_output, args...) { \
222 if (abort == _FALSE_) { \
224 class_test_message(error_message_output,#condition, args); \
233 #define class_stop(error_message_output,args...) { \
234 ErrorMsg Optional_arguments; \
235 class_protect_sprintf(Optional_arguments,args); \
236 class_build_error_string(error_message_output,"error; %s",Optional_arguments); \
242 #define class_open(pointer, filename, mode, error_output) { \
243 pointer=fopen(filename,mode); \
244 if (pointer == NULL) { \
245 class_build_error_string(error_output,"could not open %s with name %s and mode %s",#pointer,filename,#mode); \
251 #define class_define_index(index, \
254 number_of_indices) { \
256 index = running_index; \
257 running_index += number_of_indices; \
262 #define class_fprintf_double(file, \
265 if (condition == _TRUE_) \
266 fprintf(file,"%*.*e ",_COLUMNWIDTH_,_OUTPUTPRECISION_,output); \
269 #define class_fprintf_double_or_default(file, \
273 if (condition == _TRUE_) \
274 fprintf(file,"%*.*e ",_COLUMNWIDTH_,_OUTPUTPRECISION_,output); \
276 fprintf(file,"%*.*e ",_COLUMNWIDTH_,_OUTPUTPRECISION_,defaultvalue); \
279 #define class_fprintf_int(file, \
282 if (condition == _TRUE_) \
283 fprintf(file,"%*d%*s ", \
284 MAX(0,_COLUMNWIDTH_-_OUTPUTPRECISION_-5), \
285 output, _OUTPUTPRECISION_+5," "); \
288 #define class_fprintf_columntitle(file, \
292 if (condition == _TRUE_) \
293 fprintf(file,"%*s%2d:%-*s ", \
294 MAX(0,MIN(_COLUMNWIDTH_-_OUTPUTPRECISION_-6-3,_COLUMNWIDTH_-((int) strlen(title))-3)), \
295 "",colnum++,_OUTPUTPRECISION_+6,title); \
298 #define class_store_columntitle(titlestring, \
301 if (condition == _TRUE_){ \
302 strcat(titlestring,title); \
303 strcat(titlestring,_DELIMITER_); \
308 #define class_store_double(storage, \
312 if (condition == _TRUE_) \
313 storage[dataindex++] = value; \
316 #define class_store_double_or_default(storage, \
321 if (condition == _TRUE_) \
322 storage[dataindex++] = value; \
324 storage[dataindex++] = defaultvalue; \
328 #define class_print_species(name,type) \
329 printf("-> %-30s Omega = %-15g , omega = %-15g\n",name,pba->Omega0_##type,pba->Omega0_##type*pba->h*pba->h);
385 #define __ALLOCATE_PRECISION_PARAMETER__
386 #include "precisions.h"
387 #undef __ALLOCATE_PRECISION_PARAMETER__
Definition: background.h:48
ErrorMsg error_message
Definition: common.h:401
evolver_type
Definition: common.h:348
double smallest_allowed_variation
Definition: common.h:393
pk_def
Definition: common.h:359
@ delta_bc_squared
Definition: common.h:362
@ delta_tot_from_poisson_squared
Definition: common.h:363
@ delta_tot_squared
Definition: common.h:361
@ delta_m_squared
Definition: common.h:360
file_format
Definition: common.h:369
Definition: distortions.h:35
Definition: harmonic.h:17
Definition: perturbations.h:98
Definition: primordial.h:79
Definition: thermodynamics.h:59
Definition: transfer.h:76