diff --git a/CHANGES b/CHANGES index 6930f5cb87599e10ea091a8f617119f25d522a56..b7f9c9b29b6f156c24e47da20f12994d1e79be3f 100644 --- a/CHANGES +++ b/CHANGES @@ -24,6 +24,10 @@ dodgy pre-event code that was supposed to do the same thing (kind of). Updated to latest binary_grid and rob_misc perl modules. +Updated API call to free_memory with a flag that allows one to +not free the raw_buffer and error_buffer : useful for logging and +the python interface (note that these have to be freed by the user). + 02/10/2019 V2.1.2 add new "overspin_algorithm" option to handle what happens diff --git a/configure b/configure index f21bf2e630b92a34df521e7002cc5d818c111e5d..70dfa03046608bb04b641645d2d7838c63474d61 100755 --- a/configure +++ b/configure @@ -322,7 +322,13 @@ sub secondary_variables $coptflags=~s/-fomit-frame-pointer// if($opt=~/\-pg/); # all warnings, normal optimization, fPIC for shared library - $cflags.=" -fPIC -std=gnu99 -Wall -Wformat-signedness -Wformat -Wstrict-prototypes -O$opt "; + $cflags.=" -fPIC -std=gnu99 -Wall -Wformat -Wstrict-prototypes -O$opt "; + + # activate extra gcc format warnings + if($cc =~/gcc/ && stripversion($compiler_version) >= 5.0) + { + $cflags .= ' -Wformat-signedness '; + } # activate gcc hints if(defined $gcc_hints && diff --git a/src/API/binary_c_API_fortran.c b/src/API/binary_c_API_fortran.c index abd303aa39e47f458acaddb4557fb523ad7a9ae5..f73f4b8fb0cf1e76be70f2f981112468457fc48c 100644 --- a/src/API/binary_c_API_fortran.c +++ b/src/API/binary_c_API_fortran.c @@ -53,12 +53,13 @@ void binary_c_API_function binary_c_fortran_api_new_system_(struct stardata_t ** void binary_c_API_function binary_c_fortran_api_free_memory_(struct stardata_t **s, Boolean free_preferences, Boolean free_stardata, - Boolean free_store) + Boolean free_store, + Boolean free_raw_buffer) { /* free binary_c memory : this is the preferences and the stardata */ struct stardata_t * stardata = *s; APIDebug("fortran: calling free_memory stardata=%p (from s=%p) with preferences at %p\n",*s,s,(*s)->preferences); - binary_c_free_memory(s,free_preferences,free_stardata,free_store); + binary_c_free_memory(s,free_preferences,free_stardata,free_store,free_raw_buffer); } void binary_c_API_function binary_c_fortran_api_free_store_contents_(struct store_t **store) diff --git a/src/API/binary_c_API_prototypes.h b/src/API/binary_c_API_prototypes.h index d0a20b30c019ec6e685f705209f9b181f9eb6d1f..a6c9b724d5411993fa84fd17a812d3bb8a16813c 100644 --- a/src/API/binary_c_API_prototypes.h +++ b/src/API/binary_c_API_prototypes.h @@ -29,7 +29,8 @@ void binary_c_API_function binary_c_new_system(struct libbinary_c_stardata_t ** 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); + const Boolean free_store, + const Boolean free_raw_buffer); void binary_c_API_function binary_c_free_store_contents(struct libbinary_c_store_t * RESTRICT const store); @@ -145,7 +146,8 @@ void binary_c_API_function binary_c_fortran_api_new_system_(struct stardata_t ** void binary_c_API_function binary_c_fortran_api_free_memory_(struct stardata_t ** s, Boolean free_preferences, Boolean free_stardata, - Boolean free_store); + Boolean free_store, + Boolean free_raw_buffer); 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__,\ diff --git a/src/API/binary_c_free_memory.c b/src/API/binary_c_free_memory.c index f8459466372cb9eebb383b9991d55c576a560fed..7adca9be1eb2e135c312ec1c203bfadaa5e2abb2 100644 --- a/src/API/binary_c_free_memory.c +++ b/src/API/binary_c_free_memory.c @@ -1,13 +1,19 @@ #include "../binary_c.h" #ifdef BINARY_C_API -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_memory( + struct stardata_t ** RESTRICT const stardata, + const Boolean free_preferences, + const Boolean free_stardata, + const Boolean free_store, + const Boolean free_raw_buffer) { /* * API wrapper for the free_memory function */ - free_memory(stardata,free_preferences,free_stardata,free_store); + free_memory(stardata, + free_preferences, + free_stardata, + free_store, + free_raw_buffer); } #endif diff --git a/src/exit_binaryc.c b/src/exit_binaryc.c index dccf08710c8abc1c69e4175b2cdb9e7f5d218682..f5240d2129ed7ed29ca23b86553f4647ae1762f5 100644 --- a/src/exit_binaryc.c +++ b/src/exit_binaryc.c @@ -194,7 +194,7 @@ static void No_return Gnu_format_args(6,0) exit_binary_c_handler(struct stardata /* * Free all allocated memory, including the preferences, store and tmpstore */ - if(stardata!=NULL) free_memory(&stardata,TRUE,TRUE,TRUE); + if(stardata!=NULL) free_memory(&stardata,TRUE,TRUE,TRUE,TRUE); #undef exit diff --git a/src/main.c b/src/main.c index ac4dac691c35e28a8eeac33b931da91586bc72f2..9f974bf38863b7ccf387aa9c8b56755f65cfe5d1 100644 --- a/src/main.c +++ b/src/main.c @@ -196,7 +196,7 @@ static int binary_c_main(int argc, Show_timers; /* free all allocated memory */ - free_memory(s,TRUE,TRUE,TRUE); + free_memory(s,TRUE,TRUE,TRUE,TRUE); fflush(stdout); return(BINARY_C_NORMAL_EXIT); diff --git a/src/memory/free_memory.c b/src/memory/free_memory.c index 8d59943c1d4add5c2fe4cc336c440225d5ca8fd2..09407feaa0a2975ed7cdccf48b2602c7fd25005d 100644 --- a/src/memory/free_memory.c +++ b/src/memory/free_memory.c @@ -18,7 +18,8 @@ void free_memory(struct stardata_t ** RESTRICT const sp, const Boolean free_preferences, const Boolean free_stardata, - const Boolean free_store) + const Boolean free_store, + const Boolean free_raw_buffer) { struct stardata_t * stardata = (sp==NULL) ? NULL : *sp; @@ -79,7 +80,8 @@ void free_memory(struct stardata_t ** RESTRICT const sp, } FMDebug("tmpstore %p\n",stardata->tmpstore); - free_tmpstore(stardata->tmpstore); + free_tmpstore(stardata->tmpstore, + free_raw_buffer); if(free_store == TRUE) { diff --git a/src/memory/free_tmpstore.c b/src/memory/free_tmpstore.c index 6b74ade55cc4eeae807724201e8b5eb826fd2fb7..29c084b92955422b5d72e67d9ab9cf5a6d9422c7 100644 --- a/src/memory/free_tmpstore.c +++ b/src/memory/free_tmpstore.c @@ -2,7 +2,8 @@ #define Tmp_free(P) Safe_free(tmpstore->P) -void free_tmpstore(struct tmpstore_t * RESTRICT const tmpstore) +void free_tmpstore(struct tmpstore_t * RESTRICT const tmpstore, + const Boolean free_raw_buffer) { /* * Free the contents of the temporary data store (tmpstore) @@ -23,8 +24,12 @@ void free_tmpstore(struct tmpstore_t * RESTRICT const tmpstore) Tmp_free(stellar_magnitudes[k]); } } - Tmp_free(error_buffer); - Tmp_free(raw_buffer); + + if(free_raw_buffer == TRUE) + { + Tmp_free(error_buffer); + Tmp_free(raw_buffer); + } Tmp_free(stellar_structure_newstar); Tmp_free(stellar_evolution_newstar); Tmp_free(buffer_string); @@ -114,7 +119,7 @@ void free_tmpstore(struct tmpstore_t * RESTRICT const tmpstore) Safe_free(tmpstore->cmd_line_args_alpha_count); } #endif//ALPHA_ARGS - + /* * Free the memory in tmpstore, but don't set it * to NULL diff --git a/src/memory/main_allocations.c b/src/memory/main_allocations.c index 91bd67a634424226d0a0df903dd950f51855e1cf..b0966dc11f22863f309eb392471dd3406242ddf6 100644 --- a/src/memory/main_allocations.c +++ b/src/memory/main_allocations.c @@ -69,11 +69,11 @@ void main_allocations(struct stardata_t ** const new_stardata, { memset(*preferences,0,sizeof(struct preferences_t)); } - fflush(NULL); + /* * The tmpstore should always be reset */ - free_tmpstore((*new_stardata)->tmpstore); + free_tmpstore((*new_stardata)->tmpstore,TRUE); (*new_stardata)->tmpstore = Calloc(sizeof(struct tmpstore_t),1); /* diff --git a/src/memory/memory_prototypes.h b/src/memory/memory_prototypes.h index 0ae753c5fed419308d95a3c6ee8b2150de84aa4f..f5b39851c5520e17e4fbfb0881486954b01b6a52 100644 --- a/src/memory/memory_prototypes.h +++ b/src/memory/memory_prototypes.h @@ -5,7 +5,8 @@ void free_memory(struct stardata_t ** RESTRICT const sp, const Boolean free_preferences, const Boolean free_stardata, - const Boolean free_store); + const Boolean free_store, + const Boolean free_raw_buffer); void free_aux_memory(void); void * aligned_memcpy(void * dest, void * src, @@ -21,7 +22,8 @@ void initialize_pointers(struct stardata_t * const stardata, void build_store_contents(struct store_t * RESTRICT const store); void build_tmpstore_contents(struct tmpstore_t * RESTRICT const tmpstore); void free_store_contents(struct store_t * RESTRICT const store); -void free_tmpstore(struct tmpstore_t * RESTRICT const tmpstore); +void free_tmpstore(struct tmpstore_t * RESTRICT const tmpstore, + const Boolean free_raw_buffer); void *check_aligned_memcpy_heap_source(void * dest, const void * src, size_t n); diff --git a/src/perl/modules_targz/Binning-0.03.tar.gz b/src/perl/modules_targz/Binning-0.03.tar.gz index 187c88a31fd56ef68745ded3bbba0756316d23c5..dc41739ae8ab02cb56e36cd2e0273f40162d0c3e 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 0e18418d5f29785f8c1435e9ae9b13768fc2cb5a..b6b5e24f96263a3e46181d1700553896e429cd9a 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 6ce9b462485ea172baa54a2d2a1f80232073a8e2..479b6cbc9e01dd807f7d765543809ba4018257d2 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 bb69199ab66294067a8679aecfa3cd7060d2ab6d..76999d49ce9e7c55a966e3a1b63e0998bf4b6e06 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 39350d82bdb41d5ef134e1feee1de536371be830..f1c5c0c08d615140fd0d384110b1d69ddf3ce188 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 a9e74292b38c5e78f88515635b546ca8d9d15e27..88173a8771e4a84cd97dde4a740e36087b01f049 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 c31627c310233e15e07cf0e54d10c3da50c3541e..4ed37b4d089a5a5fa6ad37d66a0bd38a234ed22a 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-v2.1.3.tar.gz b/src/perl/modules_targz/binary_grid-v2.1.3.tar.gz index f37076cfc9df7efc56138ecf663738c4714194df..3dc7d6f6a81453c339854bda462b6ed13501a084 100644 Binary files a/src/perl/modules_targz/binary_grid-v2.1.3.tar.gz and b/src/perl/modules_targz/binary_grid-v2.1.3.tar.gz differ diff --git a/src/perl/modules_targz/binary_stars-0.05.tar.gz b/src/perl/modules_targz/binary_stars-0.05.tar.gz index 45290f80b216d6cbb18961fb4807476893bdbbbe..506f0e5518c19fa1ba9798640b4a209c538aa354 100644 Binary files a/src/perl/modules_targz/binary_stars-0.05.tar.gz and b/src/perl/modules_targz/binary_stars-0.05.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 4e77c103cdf9eae80ef8e32ecc939d5ffb4d6bbc..6fd1f2ba5219d9b5b9c7c37c070b3ae99742fda6 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 029ecd41c2c418ad4873bac1ba0f7de4fddea527..33676132c58cf214f1adb86213fbf2cb7065e891 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.16.tar.gz b/src/perl/modules_targz/rob_misc-0.16.tar.gz index 8f0dc38f5d309dfb103788a9110c3e36535e7a0b..851580c8ca3f8b1b5c87dcd4066deaceba4c25c8 100644 Binary files a/src/perl/modules_targz/rob_misc-0.16.tar.gz and b/src/perl/modules_targz/rob_misc-0.16.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 fae2c5b93c927833ed80241e7dbad2acd0ee2c68..369d60b935b856b0d85d7bc973e8ae38f60d8162 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 9a74a93021e6e0947c8dbf03f779e2f74483fe79..ebae5f5460bf0b12d9acb76af4850f1aabe4faf0 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/perl/scripts2/check_compilers.pl b/src/perl/scripts2/check_compilers.pl index 3b388cee01f043364c27b45f9cfc30970e6614f6..e98201c25c42b0313e6674db748fcf8534da3d2e 100755 --- a/src/perl/scripts2/check_compilers.pl +++ b/src/perl/scripts2/check_compilers.pl @@ -2,27 +2,28 @@ use strict; use Sort::Versions; use rob_misc; - +use subs 'printx'; $|=1; # # Script to build binary_c with each available gcc and clang, # checking for errors and warnings # - +my $logfile = '/tmp/check_compilers.log'; +open(my $logfp,'>',$logfile)||die("cannot open $logfile"); my $args = "@ARGV"; my $vb = ($args=~/-v/) ? 1 : 0; my @compilers = ('gcc','clang'); my $compiler_regexp = join('|',@compilers); -print "Check binary_c compilers (vb = $vb)\n"; +printx "Check binary_c compilers (vb = $vb), logging to $logfile\n"; foreach my $compiler (@compilers) { my @executables = find_executables($compiler); - print "Compiler : $compiler\n"; - print "Executables : @executables\n"; + printx "Compiler : $compiler\n"; + printx "Executables : @executables\n"; foreach my $executable (@executables) { @@ -30,6 +31,7 @@ foreach my $compiler (@compilers) } } +close $logfile; exit; @@ -56,7 +58,7 @@ sub find_executables my $v = version_of($executable); if(!defined $v) { - print "Warning: $executable gave no version\n"; + printx "Warning: $executable gave no version\n"; } else { @@ -88,18 +90,18 @@ sub build my $env = "unset CC; export CC=$compiler; "; # run configure - print "Configure with $compiler (version $v)\n"; + printx "Configure with $compiler (version $v)\n"; my $cmd = "$env ./configure 2>/dev/stdout"; - print "CMD $cmd\n"if($vb); + printx "CMD $cmd\n"if($vb); my $r = `$cmd`; - print $r if($vb); + printx $r if($vb); if($r=~/Now run .\/make/) { # configure successful : do the build - print "Building\n"; + printx "Building\n"; $cmd = "$env ./make clean 2>/dev/stdout; ./make 2>/dev/stdout"; - print "CMD $cmd\n" if($vb); + printx "CMD $cmd\n" if($vb); $r = `$cmd`; # clean the results of successful statements @@ -113,17 +115,27 @@ sub build if($r) { # error or warning found - print "Found error or warning\n\n\"$r\"\n"; + printx "Found error or warning\n\n\"$r\"\n"; + close $logfile; + print "\n\n\nSee $logfile\n"; exit; } else { - print "Build was clean\n"; + printx "Build was clean\n"; } } else { - print "Configure with compiler \"$compiler\" (version $v) failed \n"; + printx "Configure with compiler \"$compiler\" (version $v) failed \n"; exit; } } + + +sub printx(@) +{ + my $s = join('',@_); + print {$logfp} $s if(defined $logfp); + print $s; +} diff --git a/src/setup/argument_setting_functions.c b/src/setup/argument_setting_functions.c index fb401308cc76226ccce46f3954fc99c966b0ea53..024554c241582698daaf3cd153b1dbc49ad621d9 100644 --- a/src/setup/argument_setting_functions.c +++ b/src/setup/argument_setting_functions.c @@ -60,7 +60,7 @@ static char * arg_variable_default_string( * * Returns "subroutine" for ARG_SUBROUTINE* types. */ - char * c; + char * c = NULL; if(a->pointer != NULL) { if(Arg_is_subroutine(a->type)) diff --git a/src/setup/cmd_line_argstring.c b/src/setup/cmd_line_argstring.c index 550930975b753e740db181d31f7feabbee1018c4..6329c7fcaebfedf1f444b3b3249e94cecef6d1b9 100644 --- a/src/setup/cmd_line_argstring.c +++ b/src/setup/cmd_line_argstring.c @@ -2,7 +2,10 @@ char * cmd_line_argstring(struct stardata_t * const stardata) { - char * s = '\0'; + /* + * Return a string containing the command line arguments + */ + char * s = NULL; int i; for(i=0;i<stardata->common.argc;i++) { diff --git a/src/setup/parse_arguments.c b/src/setup/parse_arguments.c index 76f9fd3f2c18cb154c0642fe3eb23a17cd00f658..100dd348c0a2c9d428f4f6b2a46ec7f5554de608 100644 --- a/src/setup/parse_arguments.c +++ b/src/setup/parse_arguments.c @@ -478,7 +478,7 @@ static Boolean match_scanf(const char * const arg, * pattern that is commonly used. The integer should * always be positive, however, */ - const int matching_int; + const int matching_int = 0; const int scantest = sscanf(arg, cmd_line_arg->name, &matching_int);