diff --git a/apitest/Make_fortran b/apitest/Make_fortran index d0aaa6cb8c03211268bd354505e4e8013268c391..77a00ea003d37b63ec11b5887d7ee4b6861ac903 100755 --- a/apitest/Make_fortran +++ b/apitest/Make_fortran @@ -6,16 +6,25 @@ # # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../src/ -CFLAGS="-O3" + # or for debugging #CFLAGS="-O0 -g" -CMD="gfortran -lbinary_c -I../src/ -I/usr/include -L. -L../src/ -lbinary_c -lm -lc $CFLAGS -ffree-line-length-0 apitest.f90 ../src/libbinary_c.so -lbfd -o apitest-f90" + +F77="gfortran" + + +LIBS=`../binary_c-config libs` +LIBDIRS=`../binary_c-config libdirs` +CFLAGS="-O3" +INCDIRS=`../binary_c-config incdirs` + +CMD="gfortran -lbinary_c $INCDIRS -I../src/ -L../src/ $LIBDIRS $LIBS $CFLAGS -ffree-line-length-0 apitest.f90 ../src/libbinary_c.so -o apitest-f90" echo "$CMD" `$CMD` # debug build: to run valgrind use # -# valgrind --max-stackframe=39849440 -v --log-file=/tmp/val.out --leak-check=full --show-leak-kinds=all --track-origins=yes ./apitest-f90 +#valgrind --max-stackframe=39849440 -v --log-file=/tmp/val.out --leak-check=full --show-leak-kinds=all --track-origins=yes ./apitest-f90 diff --git a/apitest/Makefile b/apitest/Makefile index 08f7080a159346367a7bf2a08aad6d8a2f0effd6..378a956bc9cfe12496614f9492d4f014b6e48f44 100644 --- a/apitest/Makefile +++ b/apitest/Makefile @@ -1,16 +1,14 @@ # Makefile for Rapid Binary Star Evolution program -CC := gcc -LD := gcc +CC := $(shell ../binary_c-config cc) +LD := $(shell ../binary_c-config ld) PROGRAM := binary_c-apitest MAKE := /usr/bin/make -SVN_REVISION := $(shell svn info|grep Revision|cut -d' ' -f2 ) -SVN_URL := $(shell svn info|grep URL|cut -d' ' -f2|sed -e 's/^http\:\/\///g') -CFLAGS := -march=native -mtune=native -fPIC -Wall -Wstrict-prototypes -O3 -DLINUX -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DCPUFREQ=2401 -DSVN_REVISION="$(SVN_REVISION)" -DSVN_URL="$(SVN_URL)" -ffunction-sections -LIBDIRS := -L -L. -L../src/ -INCDIRS := -I. -I/usr/include -# LIBS must match whatever libbinary_c.so is built with so get it -# directly from the libbinary_c Makefile. A bit crude, but it works... -LIBS := -lbinary_c $(shell grep ^LIBS ../src/Makefile | cut -c 9-) +GIT_REVISION := $(shell ../binary_c-config git_revision) +GIT_URL := $(shell ../binary_c-config git_url) +CFLAGS := $(shell ../binary_c-config cflags) +LIBDIRS := -L -L. -L../src/ $(shell ../binary_c-config libdirs) +INCDIRS := -I. -I/usr/include $(shell ../binary_c-config incdirs) +LIBS := $(shell ../binary_c-config libs) -lbinary_c C_SRC := $(wildcard *.c) $(wildcard */*.c) OBJECTS := $(C_SRC:.c=.o) MAINS := $(filter ./main/src/main.o,$(OBJECTS)) diff --git a/apitest/apitest.c b/apitest/apitest.c index dde892ed2e680c50ce43313e4e85523703ea76bc..3350b0efcf01e87d0285fc3804a8629c9a5428ac 100644 --- a/apitest/apitest.c +++ b/apitest/apitest.c @@ -26,7 +26,7 @@ * "/dev/stdout" : output is sent to stdout */ -#define APITEST_OUTPUT_STREAM "/dev/null" +#define APITEST_OUTPUT_STREAM "/dev/stderr" /* * Output lines (if not APITEST_OUTPUT_STREAM is not /dev/null): @@ -68,7 +68,7 @@ static void capture_stdout(void); static size_t getTotalSystemMemory(void); /* C macros */ -#define BINARY_C_APITEST_VERSION 0.1 +#define BINARY_C_APITEST_VERSION 2.1 #define APIprint(...) APIprintf(__VA_ARGS__); #define NO_OUTPUT @@ -99,7 +99,7 @@ int main ( int argc, char * * argv ) int n_writ = snprintf(argstring, ARGSTRING_LENGTH-1, - "binary_c M_1 %g M_2 %g eccentricity %g metallicity %g max_evolution_time %g idum -10 orbital_period %g", + "binary_c M_1 %g M_2 %g eccentricity %g metallicity %g max_evolution_time %g orbital_period %g", m1, // m2 randd(0.1,m1), // 0.1 < m2 < m1 randd(0.0,1.0), // ecc @@ -109,13 +109,13 @@ int main ( int argc, char * * argv ) ); if(n_writ<0) { - Exit_binary_c_no_stardata(WRITE_FAILED, + Exit_binary_c_no_stardata(BINARY_C_WRITE_FAILED, "snprintf into argstring failed with error %d\n", n_writ); } else if(n_writ >= ARGSTRING_LENGTH-1) { - Exit_binary_c_no_stardata(WRITE_FAILED, + Exit_binary_c_no_stardata(BINARY_C_WRITE_FAILED, "snprintf into argstring failed because buffer is full (n_writ = %d)\n", n_writ); } @@ -193,9 +193,9 @@ int main ( int argc, char * * argv ) for(i=0;i<N;i++) { char * buffer = NULL; - int nbytes = 0; + size_t nbytes = 0; binary_c_buffer_info(*(stardata+i),&buffer,&nbytes); - printf("Buffer %d contains %d bytes\n", + printf("Buffer %d contains %zu bytes\n", i, nbytes); printf("Buffer %d is\n************************************************************\n%s\n************************************************************\n", @@ -207,7 +207,7 @@ int main ( int argc, char * * argv ) */ binary_c_buffer_empty_buffer(*(stardata+i)); binary_c_buffer_info(*(stardata+i),&buffer,&nbytes); - printf("Buffer %d now contains %d bytes (should be empty, i.e. 0)\n", + printf("Buffer %d now contains %zu bytes (should be empty, i.e. 0)\n", i, nbytes); } diff --git a/apitest/apitest.f90 b/apitest/apitest.f90 index 14818b2199e1088506d7dd423389c2f6896e466c..333ead645db44d0b6c080a207a1703e0d2eba7c0 100644 --- a/apitest/apitest.f90 +++ b/apitest/apitest.f90 @@ -67,12 +67,13 @@ program apitestf ! create new stardata structure call binary_c_fortran_api_new_system(stardata_pointer,C_NULL_PTR,C_NULL_PTR,store_pointer,argstring) - + write(*,*)"have made new system" + ! loop from time 0 to maxt in 10 Myr steps dt = 10.0d0 t = 0.d0 do while (t .lt. maxt) - !write (*,*) 'Evolve at time ',t + write (*,*) 'Evolve at time ',t ! do evolution for this dt call binary_c_fortran_api_evolve_for_dt(dt,stardata_pointer) diff --git a/apitest/apitest.sh b/apitest/apitest.sh index b5bcdc96323659a2e1ac0cfa0b22eda1b906f986..7ed5076df315240f7e2803a549cdccf1390319e2 100755 --- a/apitest/apitest.sh +++ b/apitest/apitest.sh @@ -1,10 +1,9 @@ #!/bin/bash -export LD_LIBRARY_PATH=../src/:. +export LD_LIBRARY_PATH=`../binary_c-config libdirs_list | tr " " ":"`. +LD_LIBRARY_PATH="$LD_LIBRARY_PATH:../src" +echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" -#ln -s ../src/libbinary_c.so 2>/dev/null -#ln -s libbinary_c.so libbinary_c 2>/dev/null - -#gdb +#gdb ./binary_c-apitest 2>&1 diff --git a/src/API/binary_c_API_debug_fprintf.c b/src/API/binary_c_API_debug_fprintf.c index 92136c2dea4dbfe64032655c7d8f060148055316..3a027fa4b2cd67bc57e42716a759da76b7f17994 100644 --- a/src/API/binary_c_API_debug_fprintf.c +++ b/src/API/binary_c_API_debug_fprintf.c @@ -3,10 +3,10 @@ /* API debug function */ void binary_c_API_function Gnu_format_args(4,5) - binary_c_API_debug_fprintf(struct stardata_t * stardata, - char * filename , - int fileline, - char * format, + binary_c_API_debug_fprintf(struct stardata_t * const stardata, + const char * const filename , + const int fileline, + const char * const format, ...) { /* diff --git a/src/API/binary_c_API_fortran.c b/src/API/binary_c_API_fortran.c index b118f337d62b4dbcaf84bdfa2353ea67d241f292..abd303aa39e47f458acaddb4557fb523ad7a9ae5 100644 --- a/src/API/binary_c_API_fortran.c +++ b/src/API/binary_c_API_fortran.c @@ -34,18 +34,19 @@ void binary_c_API_function binary_c_fortran_api_evolve_for_dt_(double * dt, binary_c_evolve_for_dt(*s,*dt); } -void binary_c_API_function binary_c_fortran_api_new_system_(struct stardata_t **s, - struct stardata_t ***ps, - struct preferences_t **p, - struct store_t **store, - char * argv) +void binary_c_API_function binary_c_fortran_api_new_system_(struct stardata_t ** s, + struct stardata_t **** ps_p, + struct preferences_t *** p_p, + struct store_t ** store, + char * argv) { /* use API routine to allocate and set up a new system */ - printf("MAKE NEW SYSTEM with s = %p, ps = %ps, p = %p, store = %p, argv = %p\n",s,ps,p,store,&argv); - printf("ARGV = %s\n",argv); - fflush(stdout); + struct stardata_t *** ps = *ps_p; + struct preferences_t ** p = *p_p; + struct stardata_t * stardata = *s; // for debugging only + APIDebug("MAKE NEW SYSTEM with s = %p, ps = %p, p = %p, store = %p, argv = %p\n",s,ps,p,store,&argv); + APIDebug("ARGV = %s\n",argv); binary_c_new_system(s,ps,p,store,&argv,-1); - struct stardata_t * stardata = *s; APIDebug("fortran: Allocated stardata at %p (from s=%p) with preferences at %p\n",(*s),s,(*s)->preferences); } @@ -66,8 +67,8 @@ void binary_c_API_function binary_c_fortran_api_free_store_contents_(struct stor } void binary_c_API_function binary_c_fortran_api_buffer_info_(struct stardata_t ** s, - char ** buffer, - int * size) + char ** const buffer, + size_t * const size) { binary_c_buffer_info(*s,buffer,size); } diff --git a/src/API/binary_c_API_logging.c b/src/API/binary_c_API_logging.c index 7b0a63db837a01c04f086bfadafb0a6ba110e8db..4e300375d8ebe3624aca1bab01a17b4f6ecbad1f 100644 --- a/src/API/binary_c_API_logging.c +++ b/src/API/binary_c_API_logging.c @@ -5,8 +5,8 @@ * binary_c API logging functions */ -void binary_c_API_function binary_c_API_log(struct stardata_t * stardata, - int loc) +void binary_c_API_function binary_c_API_log(struct stardata_t * const stardata, + const unsigned int loc) { /* do nothing if the prefix is set to /dev/null */ @@ -41,7 +41,7 @@ void binary_c_API_function binary_c_API_log(struct stardata_t * stardata, fflush(stardata->model.api_log_fp); } -void binary_c_API_function binary_c_API_open_log(struct stardata_t * stardata) +void binary_c_API_function binary_c_API_open_log(struct stardata_t * const stardata) { /* do nothing if the prefix is set to /dev/null */ @@ -74,8 +74,8 @@ void binary_c_API_function binary_c_API_open_log(struct stardata_t * stardata) } -void binary_c_API_function binary_c_API_open_logfile(struct stardata_t * stardata, - char * filename) +void binary_c_API_function binary_c_API_open_logfile(struct stardata_t * const stardata, + const char * const filename) { if((stardata->model.api_log_fp = fopen(filename,"w"))==NULL) @@ -87,7 +87,7 @@ void binary_c_API_function binary_c_API_open_logfile(struct stardata_t * stardat } -void binary_c_API_function binary_c_API_close_logfile(struct stardata_t * stardata) +void binary_c_API_function binary_c_API_close_logfile(struct stardata_t * const stardata) { if(stardata != NULL && stardata->model.api_log_fp != NULL && diff --git a/src/API/binary_c_API_prototypes.h b/src/API/binary_c_API_prototypes.h index 2f243172f6be6a1c0dada9267ade64eac4e9e2f5..113e9263c4bd67c8445f9cdbd1a5fce616b07fa5 100644 --- a/src/API/binary_c_API_prototypes.h +++ b/src/API/binary_c_API_prototypes.h @@ -16,8 +16,8 @@ /* * Standard API functions. */ -int binary_c_API_function binary_c_evolve_for_dt(struct libbinary_c_stardata_t * stardata, - double dt); +int binary_c_API_function binary_c_evolve_for_dt(struct libbinary_c_stardata_t * const stardata, + const double dt); void binary_c_API_function binary_c_new_system(struct libbinary_c_stardata_t ** stardata, struct libbinary_c_stardata_t *** previous_stardatas, @@ -26,34 +26,35 @@ void binary_c_API_function binary_c_new_system(struct libbinary_c_stardata_t ** char ** argv, int argc); -void binary_c_API_function binary_c_free_memory(struct stardata_t ** RESTRICT stardata, - Boolean free_preferences, - Boolean free_stardata, - Boolean free_store); +void binary_c_API_function binary_c_free_memory(struct stardata_t ** RESTRICT const stardata, + const Boolean free_preferences, + const Boolean free_stardata, + const Boolean free_store); -void binary_c_API_function binary_c_free_store_contents(struct libbinary_c_store_t * RESTRICT store); +void binary_c_API_function binary_c_free_store_contents(struct libbinary_c_store_t * RESTRICT const store); -void binary_c_API_function binary_c_buffer_info(struct libbinary_c_stardata_t * RESTRICT stardata, - char ** buffer, - int * size); +void binary_c_API_function binary_c_buffer_info(struct libbinary_c_stardata_t * RESTRICT const stardata, + char ** const buffer, + size_t * size); -void binary_c_API_function binary_c_buffer_empty_buffer(struct stardata_t * RESTRICT stardata); +void binary_c_API_function binary_c_buffer_empty_buffer(struct stardata_t * RESTRICT const stardata); /* * API debugging functions */ -void binary_c_API_function binary_c_API_open_log(struct libbinary_c_stardata_t * stardata); -void binary_c_API_function binary_c_API_log(struct libbinary_c_stardata_t * stardata,int loc); -void binary_c_API_function binary_c_API_debug_fprintf(struct libbinary_c_stardata_t * stardata, - char * filename , - int fileline, - char * format, +void binary_c_API_function binary_c_API_open_log(struct libbinary_c_stardata_t * const stardata); +void binary_c_API_function binary_c_API_log(struct libbinary_c_stardata_t * const stardata, + const unsigned int loc); +void binary_c_API_function binary_c_API_debug_fprintf(struct libbinary_c_stardata_t * const stardata, + const char * const filename , + const int fileline, + const char * const format, ...) Gnu_format_args(4,5); void binary_c_API_function binary_c_API_close_logfile(struct stardata_t * stardata); -void binary_c_API_function binary_c_API_open_logfile(struct stardata_t * stardata, - char * filename); +void binary_c_API_function binary_c_API_open_logfile(struct stardata_t * const stardata, + const char * const filename); /* @@ -61,16 +62,16 @@ void binary_c_API_function binary_c_API_open_logfile(struct stardata_t * stardat */ void binary_c_API_function binary_c_version( - struct libbinary_c_stardata_t * RESTRICT stardata); + struct libbinary_c_stardata_t * RESTRICT const stardata); void binary_c_API_function binary_c_show_instant_RLOF_period_or_separation( - struct libbinary_c_stardata_t * stardata); + struct libbinary_c_stardata_t * const stardata); void binary_c_API_function binary_c_initialize_parameters( - struct libbinary_c_stardata_t * RESTRICT stardata); + struct libbinary_c_stardata_t * RESTRICT const stardata); void binary_c_API_function binary_c_list_args( - struct libbinary_c_stardata_t * RESTRICT stardata); + struct libbinary_c_stardata_t * RESTRICT const stardata); /* * FORTRAN interface @@ -79,7 +80,8 @@ void binary_c_API_function binary_c_list_args( /* input */ -#define FORTRAN_IN_VARLIST__ double *m1, \ +#define FORTRAN_IN_VARLIST__ \ + double *m1, \ double *mc1, \ double *vrot1, \ double *m2, \ @@ -94,7 +96,8 @@ void binary_c_API_function binary_c_list_args( int *stellar_type2 \ /* output */ -#define FORTRAN_OUT_VARLIST__ double *m1, \ +#define FORTRAN_OUT_VARLIST__ \ + double *m1, \ double *mc1, \ double *r1, \ double *omega1, \ @@ -128,20 +131,22 @@ void binary_c_API_function binary_c_list_args( double *maxtime, \ int *stellar_type1 -void binary_c_API_function binary_c_fortran_api_evolve_for_dt_(double *dt,struct stardata_t **s); +void binary_c_API_function binary_c_fortran_api_evolve_for_dt_(double * dt, + struct stardata_t ** s); void binary_c_API_function binary_c_fortran_api_new_system_(struct stardata_t ** s, - struct stardata_t ***ps, - struct preferences_t **p, + struct stardata_t **** ps, + struct preferences_t *** p, struct store_t ** store, char * argv); -void binary_c_API_function binary_c_fortran_api_free_memory_(struct stardata_t **s, +void binary_c_API_function binary_c_fortran_api_free_memory_(struct stardata_t ** s, Boolean free_preferences, Boolean free_stardata, Boolean free_store); -void binary_c_API_function binary_c_fortran_api_free_store_(struct store_t **store); +void binary_c_API_function binary_c_fortran_api_free_store_(struct store_t ** store); -void binary_c_API_function binary_c_fortran_api_stardata_info_(FORTRAN_OUT_VARLIST__,struct stardata_t **s); +void binary_c_API_function binary_c_fortran_api_stardata_info_(FORTRAN_OUT_VARLIST__,\ + struct stardata_t ** s); #endif // BINARY_C_API_FORTRAN diff --git a/src/API/binary_c_buffer_empty_buffer.c b/src/API/binary_c_buffer_empty_buffer.c index d1b96a4f1a049e3444db8c6e81fcbb8b75082ff5..c2b2d728b9831ad535e59de16d690da38ad63e13 100644 --- a/src/API/binary_c_buffer_empty_buffer.c +++ b/src/API/binary_c_buffer_empty_buffer.c @@ -2,7 +2,7 @@ #ifdef BINARY_C_API -void binary_c_API_function binary_c_buffer_empty_buffer(struct stardata_t * RESTRICT stardata) +void binary_c_API_function binary_c_buffer_empty_buffer(struct stardata_t * RESTRICT const stardata) { /* * API wrapper for the buffer_empty_buffer diff --git a/src/API/binary_c_buffer_info.c b/src/API/binary_c_buffer_info.c index 858856f2005e77b75379847ebbfc90cda6daf882..e76729566f06c4355097bd26bcea1041d945808f 100644 --- a/src/API/binary_c_buffer_info.c +++ b/src/API/binary_c_buffer_info.c @@ -1,9 +1,9 @@ #include "../binary_c.h" #ifdef BINARY_C_API -void binary_c_API_function binary_c_buffer_info(struct stardata_t * RESTRICT stardata, - char ** buffer, - int * size) +void binary_c_API_function binary_c_buffer_info(struct stardata_t * RESTRICT const stardata, + char ** const buffer, + size_t * const size) { /* * API function to access the binary_c buffer diff --git a/src/API/binary_c_evolve_for_dt.c b/src/API/binary_c_evolve_for_dt.c index ced3f939e2cf5fed0d6c29f9e718351f4aa58ae1..0efde4e7ea3f1f48b6977286ff222fc0f63588c3 100644 --- a/src/API/binary_c_evolve_for_dt.c +++ b/src/API/binary_c_evolve_for_dt.c @@ -2,8 +2,8 @@ #ifdef BINARY_C_API -int binary_c_API_function binary_c_evolve_for_dt(struct stardata_t * stardata, - double dt) +int binary_c_API_function binary_c_evolve_for_dt(struct stardata_t * const stardata, + const double dt) { /* * Evolve the stardata struct for time dt (Myr) @@ -92,12 +92,13 @@ int binary_c_API_function binary_c_evolve_for_dt(struct stardata_t * stardata, /* Debugging */ { char * buffer; - int size; + size_t size; buffer_info(stardata,&buffer,&size); - APIDebug("API :: post iterate t=%g, buffer = %p , buffer_size = %d\n", + APIDebug("API :: post iterate t=%g, buffer = %p , buffer_size = %zu\n", stardata->model.time, - buffer,size + buffer, + size ); binary_c_API_log(stardata,API_LOG_POST); diff --git a/src/API/binary_c_free_memory.c b/src/API/binary_c_free_memory.c index 8253583b561a348cbf3a00ed83d34c98112c9ac3..f8459466372cb9eebb383b9991d55c576a560fed 100644 --- a/src/API/binary_c_free_memory.c +++ b/src/API/binary_c_free_memory.c @@ -1,9 +1,9 @@ #include "../binary_c.h" #ifdef BINARY_C_API -void binary_c_API_function binary_c_free_memory(struct stardata_t ** RESTRICT stardata, - Boolean free_preferences, - Boolean free_stardata, - Boolean free_store) +void binary_c_API_function binary_c_free_memory(struct stardata_t ** RESTRICT const stardata, + const Boolean free_preferences, + const Boolean free_stardata, + const Boolean free_store) { /* * API wrapper for the free_memory function diff --git a/src/API/binary_c_free_store_contents.c b/src/API/binary_c_free_store_contents.c index ee9f3d647fb7690fe847059be56ad1bb39ad450d..b9bf6ded6da6748d66eb831cab72e54e74b046c9 100644 --- a/src/API/binary_c_free_store_contents.c +++ b/src/API/binary_c_free_store_contents.c @@ -2,7 +2,7 @@ #ifdef BINARY_C_API -void binary_c_API_function binary_c_free_store_contents(struct store_t * RESTRICT store) +void binary_c_API_function binary_c_free_store_contents(struct store_t * RESTRICT const store) { free_store_contents(store); } diff --git a/src/API/binary_c_initialize_parameters.c b/src/API/binary_c_initialize_parameters.c index 335cc5d75e5b3bc943ccd38fec2bc1adbaf96461..6c77dbaeb44ae13946b36f112895446ca1f94bc7 100644 --- a/src/API/binary_c_initialize_parameters.c +++ b/src/API/binary_c_initialize_parameters.c @@ -3,7 +3,7 @@ #ifdef BINARY_C_API void binary_c_API_function binary_c_initialize_parameters( - struct stardata_t * RESTRICT stardata) + struct stardata_t * RESTRICT const stardata) { initialize_parameters(stardata); } diff --git a/src/API/binary_c_list_args.c b/src/API/binary_c_list_args.c index 387afef5c1744527bf318c1940ff5bda8f609368..7cf411b821c502a7efaa8783620eba74fe83597a 100644 --- a/src/API/binary_c_list_args.c +++ b/src/API/binary_c_list_args.c @@ -10,7 +10,7 @@ * allows it to be called with only stardata */ void binary_c_API_function binary_c_list_args( - struct libbinary_c_stardata_t * RESTRICT stardata) + struct libbinary_c_stardata_t * RESTRICT const stardata) { struct cmd_line_arg_t cmd_line_args[] = { CMD_LINE_ARGS }; @@ -27,7 +27,7 @@ void binary_c_API_function binary_c_list_args( list_available_args(ARG_SUBROUTINE_ARGS); char * buffer = NULL; - int nbytes = 0; + size_t nbytes = 0; binary_c_buffer_info(stardata,&buffer,&nbytes); } diff --git a/src/API/binary_c_show_instant_RLOF_period_or_separation.c b/src/API/binary_c_show_instant_RLOF_period_or_separation.c index 1ba5cfae7f9d907dd3da33eee635bc6212479a2f..cf3c19e317df01633404d98dac6c3eabc704400d 100644 --- a/src/API/binary_c_show_instant_RLOF_period_or_separation.c +++ b/src/API/binary_c_show_instant_RLOF_period_or_separation.c @@ -2,7 +2,7 @@ #ifdef BINARY_C_API -void binary_c_API_function binary_c_show_instant_RLOF_period_or_separation(struct stardata_t * stardata) +void binary_c_API_function binary_c_show_instant_RLOF_period_or_separation(struct stardata_t * const stardata) { show_instant_RLOF_period_or_separation(stardata); } diff --git a/src/API/binary_c_version.c b/src/API/binary_c_version.c index f0996984b867244ab6080958ec09c8e4d39d33db..3a4eff65e283c5709af42fd4ab165448defdb2dd 100644 --- a/src/API/binary_c_version.c +++ b/src/API/binary_c_version.c @@ -1,7 +1,7 @@ #include "../binary_c.h" #ifdef BINARY_C_API -void binary_c_API_function binary_c_version(struct stardata_t * RESTRICT stardata) +void binary_c_API_function binary_c_version(struct stardata_t * RESTRICT const stardata) { version(stardata); } diff --git a/src/buffering/binary_c_fail_printf.c b/src/buffering/binary_c_fail_printf.c index 90f0ea01e23813f978e3eb5cdfc1a4ec3a27ef3f..053b9acf804ee110eb635892463a031a16b1f206 100644 --- a/src/buffering/binary_c_fail_printf.c +++ b/src/buffering/binary_c_fail_printf.c @@ -44,7 +44,8 @@ void Gnu_format_args(4,5) No_return va_start(args,format); /* s contains the message */ - char sid[14],s[MAX_DEBUG_PRINT_SIZE]; + char sid[14]; + char s[MAX_DEBUG_PRINT_SIZE]; vsnprintf(s,MAX_DEBUG_PRINT_SIZE,format,args); chomp(s); @@ -56,7 +57,7 @@ void Gnu_format_args(4,5) No_return else #endif // BINARY_C_API { - sid[0]=0; // empty string + sid[0] = 0; // empty string } /* make the filename, remove nan e.g. in remnant (replace with n_n) */ diff --git a/src/buffering/buffer_empty_buffer.c b/src/buffering/buffer_empty_buffer.c index f82782001c8f832cfe59ddc5c2c272e09cf45bc4..a94843753e2e052fc96f8d871be1df7c647fdc8a 100644 --- a/src/buffering/buffer_empty_buffer.c +++ b/src/buffering/buffer_empty_buffer.c @@ -5,6 +5,6 @@ void buffer_empty_buffer(struct stardata_t * RESTRICT const stardata) if(stardata && stardata->tmpstore) { Safe_free(stardata->tmpstore->raw_buffer); - stardata->tmpstore->raw_buffer_size=0; + stardata->tmpstore->raw_buffer_size = 0; } } diff --git a/src/buffering/buffer_info.c b/src/buffering/buffer_info.c index 22c64843610138956caf74ca349a8b0446254378..294c31f75d5bf83eddfff26f9fadf05dedc078c3 100644 --- a/src/buffering/buffer_info.c +++ b/src/buffering/buffer_info.c @@ -2,7 +2,7 @@ void buffer_info(const struct stardata_t * RESTRICT const stardata, char ** const buffer, - int * const size) + size_t * const size) { /* * Return the buffer location and size for external access diff --git a/src/buffering/buffer_stack_pop.c b/src/buffering/buffer_stack_pop.c index 7cb2f0e4d61e57ea299331510b80cdf859b67d43..e30e79d3616650b1ca7288797deb9c60d21b8104 100644 --- a/src/buffering/buffer_stack_pop.c +++ b/src/buffering/buffer_stack_pop.c @@ -7,7 +7,7 @@ int buffer_stack_pop(struct stardata_t * const stardata, char * const c) { if(!stardata) return 0; - int ret=0; + int ret = 0; int modewas = stardata->preferences->output_type; stardata->preferences->output_type=0; @@ -56,12 +56,12 @@ int buffer_stack_pop(struct stardata_t * const stardata, { /* stack empty : free memory */ free_buffer_stack(stardata); - ret=0; + ret = 0; } else { /* return 1 : success */ - ret=1; + ret = 1; } return ret; } diff --git a/src/buffering/buffer_stack_push.c b/src/buffering/buffer_stack_push.c index d766ee413075e76cf32dc376493eb1572d8a98da..a6515ae4d95440cc5e7e4d8cfe3f42d3bb2b6a75 100644 --- a/src/buffering/buffer_stack_push.c +++ b/src/buffering/buffer_stack_push.c @@ -19,9 +19,9 @@ int buffer_stack_push(struct stardata_t * const stardata, if((Stack_size>0) && (strrchr(Previous_stack_string, '\n')==NULL)) { /* previous string has no newline : append */ - int n=STREAM_BUFFER_LINELENGTH-strlen(Previous_stack_string); + size_t n = (size_t)STREAM_BUFFER_LINELENGTH - strlen(Previous_stack_string); char *c = Previous_stack_string+strlen(Previous_stack_string); - ret=vsnprintf(c,n,format,args); + ret = vsnprintf(c,n,format,args); #ifdef PRINTF_DEBUG fprintf(stderr,"Appended %s\n",Previous_stack_string); #endif @@ -35,7 +35,7 @@ int buffer_stack_push(struct stardata_t * const stardata, if(Stream_buffer==NULL) { fprintf(stderr,"Could not access stream buffer pointer (it's NULL!)\n"); - ret=0; + ret = 0; } #ifdef PRINTF_DEBUG @@ -46,7 +46,7 @@ int buffer_stack_push(struct stardata_t * const stardata, if(Next_stack_string == NULL) { fprintf(stderr,"Could not allocate space for Next stack string\n"); - ret=0; + ret = 0; } #ifdef PRINTF_DEBUG @@ -59,7 +59,7 @@ int buffer_stack_push(struct stardata_t * const stardata, #ifdef PRINTF_DEBUG fprintf(stderr,"Set in buffer at %d = '%s'\n",Stack_size,Next_stack_string); #endif - Stack_size++; + Stack_size ++; } return ret; diff --git a/src/buffering/buffered_printf.c b/src/buffering/buffered_printf.c index 8dabd75e6563c22f944b0452f3f5aaf683e0b058..302e754fdbc72152ea1ed1934320a740eb4e742f 100644 --- a/src/buffering/buffered_printf.c +++ b/src/buffering/buffered_printf.c @@ -38,12 +38,12 @@ int Gnu_format_args(3,4) buffered_printf(struct stardata_t * RESTRICT const star * Allocate space for the string. Keep the last * char free for a \n that might be required. */ - int dn = sizeof(char)* + size_t dn = (size_t)sizeof(char)* vsnprintf(string, MAX_BUFFERED_STRING_LENGTH, format, args); - int dnwant = dn; + size_t dnwant = dn; dn = Min(dn, MAX_BUFFERED_STRING_LENGTH-1); va_end(args); @@ -52,7 +52,7 @@ int Gnu_format_args(3,4) buffered_printf(struct stardata_t * RESTRICT const star if(dn<dnwant) { fprintf(BUFFERED_STRING_OVERRUN_WARNINGS_STREAM, - "warning : buffer overrun : got %d want %d\n", + "warning : buffer overrun : got %zu want %zu\n", dn, dnwant); } @@ -84,7 +84,7 @@ int Gnu_format_args(3,4) buffered_printf(struct stardata_t * RESTRICT const star /* fprintf(stdout, - "BUFPRINT %d (%d to %d) \"%s\" (stardata %p prefs %p internal_buffering %d)\n", + "BUFPRINT %uz (%uz to %uz) \"%s\" (stardata %p prefs %p internal_buffering %d)\n", dn, stardata->tmpstore->raw_buffer_size, stardata->tmpstore->raw_buffer_size+dn, @@ -122,7 +122,7 @@ int Gnu_format_args(3,4) buffered_printf(struct stardata_t * RESTRICT const star * If final char in the new string is a newline, require a NULL * after it just in case this is the end */ - int lastn = Max(0,dn - 1); + size_t lastn = Max(0,dn - 1); Boolean require_null = string[lastn] == '\n'; if(require_null==TRUE && dn<MAX_BUFFERED_STRING_LENGTH) dn++; @@ -241,11 +241,11 @@ int Gnu_format_args(3,4) buffered_printf(struct stardata_t * RESTRICT const star else /* no buffering: just write directly to stdout */ { - fwrite((char *)string,(int)dn/sizeof(char),1,stdout); + fwrite((char *)string,(int)(dn/sizeof(char)),1,stdout); } /* return number of characters processed */ - return dn/sizeof(char); + return (int)(dn/sizeof(char)); } else { diff --git a/src/buffering/buffering_prototypes.h b/src/buffering/buffering_prototypes.h index 4d547839fe94d1508804dbdc53bd9d0859fd5515..dc90a868502013ba2e0c2d15fb21e0fd19e6db26 100644 --- a/src/buffering/buffering_prototypes.h +++ b/src/buffering/buffering_prototypes.h @@ -10,7 +10,7 @@ int buffered_printf(struct stardata_t * RESTRICT const stardata, ...) Gnu_format_args(3,4); void buffer_info(const struct stardata_t * RESTRICT const stardata, char ** const buffer, - int * const size); + size_t * const size); void buffer_empty_buffer(struct stardata_t * RESTRICT const stardata); void buffer_dump_to_stderr(const struct stardata_t * RESTRICT const stardata); diff --git a/src/buffering/clear_printf_buffer.c b/src/buffering/clear_printf_buffer.c index b6208ac0c4c888fb099636a88f63f67e7903ae97..8f2c6c9cbeca7a0c970a77803813557dedf8ff9b 100644 --- a/src/buffering/clear_printf_buffer.c +++ b/src/buffering/clear_printf_buffer.c @@ -45,7 +45,7 @@ void clear_printf_buffer(struct stardata_t * RESTRICT const stardata) /* free buffer memory */ Safe_free(stardata->tmpstore->raw_buffer); - stardata->tmpstore->raw_buffer_size=0; + stardata->tmpstore->raw_buffer_size = 0; } #endif //BUFFERED_STACK diff --git a/src/memory/main_allocations.c b/src/memory/main_allocations.c index 59f7b45b4bbc4be3edc04468de09e84d0957a2be..626596472f58a5bd157350e9df6a3d5299af630f 100644 --- a/src/memory/main_allocations.c +++ b/src/memory/main_allocations.c @@ -58,6 +58,7 @@ void main_allocations(struct stardata_t ** const new_stardata, */ if(preferences!=NULL && *preferences==NULL) { + printf("prefs != NULL but prefs = NULL\n"); *preferences = Calloc(sizeof(struct preferences_t),1); (*new_stardata)->preferences = *preferences; } diff --git a/src/perl/modules_targz/Binning-0.03.tar.gz b/src/perl/modules_targz/Binning-0.03.tar.gz index e55234a6ee12031c84f1cd00601a1e002248b0e7..39b8575765f649c6db00636ff805902ed6140f41 100644 Binary files a/src/perl/modules_targz/Binning-0.03.tar.gz and b/src/perl/modules_targz/Binning-0.03.tar.gz differ diff --git a/src/perl/modules_targz/Data-Serializer-RobJSON-0.05.tar.gz b/src/perl/modules_targz/Data-Serializer-RobJSON-0.05.tar.gz index 010d19bb5ada1fb44a77f10cfc0fa013b5c41197..58b5048e380e5bad1322c0cf02b5b6e62c0e0cd7 100644 Binary files a/src/perl/modules_targz/Data-Serializer-RobJSON-0.05.tar.gz and b/src/perl/modules_targz/Data-Serializer-RobJSON-0.05.tar.gz differ diff --git a/src/perl/modules_targz/Hash-RobMerge-0.14.tar.gz b/src/perl/modules_targz/Hash-RobMerge-0.14.tar.gz index 8881321c28c39f7ee4c369e227f6047144435860..8b7b135695d0f35f70a7c1f63402a925d2015e18 100644 Binary files a/src/perl/modules_targz/Hash-RobMerge-0.14.tar.gz and b/src/perl/modules_targz/Hash-RobMerge-0.14.tar.gz differ diff --git a/src/perl/modules_targz/Histogram-0.01.tar.gz b/src/perl/modules_targz/Histogram-0.01.tar.gz index 0ff561020bc4d356d98c0549ed4946831bcb3204..932913ffe24514c5e3cdb13394fb5e582124da02 100644 Binary files a/src/perl/modules_targz/Histogram-0.01.tar.gz and b/src/perl/modules_targz/Histogram-0.01.tar.gz differ diff --git a/src/perl/modules_targz/IMF-0.05.tar.gz b/src/perl/modules_targz/IMF-0.05.tar.gz index 85e578644812805c94f7ca82107db5028f413080..80eaf7fe7eeaa8950a2c18f5f203e4744b4410f7 100644 Binary files a/src/perl/modules_targz/IMF-0.05.tar.gz and b/src/perl/modules_targz/IMF-0.05.tar.gz differ diff --git a/src/perl/modules_targz/Maths_Double-0.01.tar.gz b/src/perl/modules_targz/Maths_Double-0.01.tar.gz index 69e0ed204eae00a40b187d55f52632aca58a93e3..942799630b5ed1d8af53c8098ba0d1003751a02e 100644 Binary files a/src/perl/modules_targz/Maths_Double-0.01.tar.gz and b/src/perl/modules_targz/Maths_Double-0.01.tar.gz differ diff --git a/src/perl/modules_targz/RobInterpolation-0.04.tar.gz b/src/perl/modules_targz/RobInterpolation-0.04.tar.gz index 02d3167d67ad65de0839baabb070d25c46659b7b..d54bde03485137bbe8bf1811f08aaac9392c4965 100644 Binary files a/src/perl/modules_targz/RobInterpolation-0.04.tar.gz and b/src/perl/modules_targz/RobInterpolation-0.04.tar.gz differ diff --git a/src/perl/modules_targz/binary_grid-2.1.tar.gz b/src/perl/modules_targz/binary_grid-2.1.tar.gz index 185b4cca827ebf8764692c728154afb975fc4c49..7a0e0ea0568a0e95c691a2395be80c64831ff10b 100644 Binary files a/src/perl/modules_targz/binary_grid-2.1.tar.gz and b/src/perl/modules_targz/binary_grid-2.1.tar.gz differ diff --git a/src/perl/modules_targz/binary_stars-0.04.tar.gz b/src/perl/modules_targz/binary_stars-0.04.tar.gz index 41d58b13d232433fdcca60bada4701f93e447bc1..aec09728cd9c51de0d8a10a46720efb71fd323b9 100644 Binary files a/src/perl/modules_targz/binary_stars-0.04.tar.gz and b/src/perl/modules_targz/binary_stars-0.04.tar.gz differ diff --git a/src/perl/modules_targz/cosmology-0.01.tar.gz b/src/perl/modules_targz/cosmology-0.01.tar.gz index d1f204e95800061665348bb63dfe036a43790144..e53d64c3ddc230a8ab864fbfdb50eaa7ecce3091 100644 Binary files a/src/perl/modules_targz/cosmology-0.01.tar.gz and b/src/perl/modules_targz/cosmology-0.01.tar.gz differ diff --git a/src/perl/modules_targz/distribution_functions-0.05.tar.gz b/src/perl/modules_targz/distribution_functions-0.05.tar.gz index b59eeccb5c10ea39242a2db73dbed5fa624c313b..3b5185f6ff6c8ebcaa5e60ac013ab90d6112045c 100644 Binary files a/src/perl/modules_targz/distribution_functions-0.05.tar.gz and b/src/perl/modules_targz/distribution_functions-0.05.tar.gz differ diff --git a/src/perl/modules_targz/rob_misc-0.15.tar.gz b/src/perl/modules_targz/rob_misc-0.15.tar.gz index b85d62559cdf032d0c3195a6aed3159a8b3f42d4..b1b4a1621c6fe6bbe751c5be56513c9d12f303d5 100644 Binary files a/src/perl/modules_targz/rob_misc-0.15.tar.gz and b/src/perl/modules_targz/rob_misc-0.15.tar.gz differ diff --git a/src/perl/modules_targz/robqueue-0.05.tar.gz b/src/perl/modules_targz/robqueue-0.05.tar.gz index 6e3d651458ca0db979ef6bceca2f7c4a57e3ce84..0d1da623bcaf251301dba433e61c537adfa50635 100644 Binary files a/src/perl/modules_targz/robqueue-0.05.tar.gz and b/src/perl/modules_targz/robqueue-0.05.tar.gz differ diff --git a/src/perl/modules_targz/spacing_functions-0.02.tar.gz b/src/perl/modules_targz/spacing_functions-0.02.tar.gz index fb55f11dd3d0f02074797a428391174f143cbcf5..e48ee83b33f6053b23f473f99bb6404238d47644 100644 Binary files a/src/perl/modules_targz/spacing_functions-0.02.tar.gz and b/src/perl/modules_targz/spacing_functions-0.02.tar.gz differ diff --git a/src/setup/argument_setting_functions.c b/src/setup/argument_setting_functions.c index 7b1c7e28dc5e37cf1dc6f4b74913dc373eaa9203..41a674d030ebd9c629211c809885cc1814706ad8 100644 --- a/src/setup/argument_setting_functions.c +++ b/src/setup/argument_setting_functions.c @@ -208,7 +208,6 @@ void list_available_args(ARG_SUBROUTINE_DECLARATION) stardata->preferences->internal_buffering = buffering; stardata->preferences->internal_buffering_compression = buffering_compression; - *c=-1; int xint; double xdouble; @@ -232,6 +231,7 @@ void list_available_args(ARG_SUBROUTINE_DECLARATION) Printf("%g",*((double*) cmd_line_args[i].pointer)); break; case ARG_INTEGER: + case ARG_UNSIGNED_INTEGER: /* integer argument */ Printf("%d",*((int*)cmd_line_args[i].pointer)); break; diff --git a/src/setup/cmd_line_args.h b/src/setup/cmd_line_args.h index 7f60137c3c7154676b1a2d48ca8e631a5a96dca9..c30d76349bd7cbd3057e880e1f01b235859a4df1 100644 --- a/src/setup/cmd_line_args.h +++ b/src/setup/cmd_line_args.h @@ -2968,7 +2968,7 @@ struct cmd_line_arg_t { \ ARG_SECTION_OUTPUT, \ "stardata_load_filename", \ - "Location of the stardata file to load.", \ + "Location of the stardata file to load.", \ ARG_STRING , \ "", \ &(stardata->preferences->stardata_load_filename), \ diff --git a/src/setup/new_system.c b/src/setup/new_system.c index ab9a966dfd3b0814ba1ce98dfe5c7d078bfdc78c..7e9785eacde2a7f54db885ce7b1804fe77dc49c7 100644 --- a/src/setup/new_system.c +++ b/src/setup/new_system.c @@ -2,9 +2,9 @@ #define dprint(P,...) Dprint_to_pointer((P),TRUE,__VA_ARGS__); -void new_system(struct stardata_t ** new_stardata, - struct stardata_t *** previous_stardatas, - struct preferences_t ** preferences, +void new_system(struct stardata_t ** new_stardata, + struct stardata_t *** previous_stardatas, + struct preferences_t ** preferences, struct store_t ** store, char ** argv, const int argc) @@ -42,10 +42,12 @@ void new_system(struct stardata_t ** new_stardata, "call main_allocations : new_stardata=%p *new_stardata=%p\n", new_stardata, (*new_stardata)); + main_allocations(new_stardata, previous_stardatas, preferences, store); + Star_number k; Starloop(k) { @@ -70,7 +72,7 @@ void new_system(struct stardata_t ** new_stardata, allow_nan_was = (*new_stardata)->preferences->allow_debug_nan; (*new_stardata)->preferences->allow_debug_nan = TRUE; } -#endif +#endif//DEBUG_FAIL_ON_NAN #ifdef DEBUG_FAIL_ON_INF Boolean allow_inf_was MAYBE_UNUSED = FALSE; if(*new_stardata != NULL) @@ -78,7 +80,7 @@ void new_system(struct stardata_t ** new_stardata, allow_inf_was = (*new_stardata)->preferences->allow_debug_inf; (*new_stardata)->preferences->allow_debug_inf = TRUE; } -#endif +#endif//DEBUG_FAIL_ON_INF dprint(*new_stardata,"Pre-parse argc=%d argv=%p\n",argc,argv); if(argc == -1) diff --git a/src/setup/setup_prototypes.h b/src/setup/setup_prototypes.h index bd6f913913b5af835f2dc515e68cf349b243cb54..456678705f7030fa889e837b27eba5b339e3a130 100644 --- a/src/setup/setup_prototypes.h +++ b/src/setup/setup_prototypes.h @@ -81,10 +81,10 @@ char **split_commandline(const char * RESTRICT const cmdline, void split_commandline_free(char ** argv, const int argc); -void new_system(struct stardata_t ** stardata, - struct stardata_t *** previous_stardatas, - struct preferences_t ** preferences, - struct store_t ** store, +void new_system(struct stardata_t ** stardata, + struct stardata_t *** previous_stardatas, + struct preferences_t ** preferences, + struct store_t ** store, char ** argv, const int argc);