From bcbeec91b27bddf953726e99cb8a26d20b3e9b08 Mon Sep 17 00:00:00 2001 From: Robert Izzard <r.izzard@surrey.ac.uk> Date: Sun, 27 Oct 2019 13:38:59 +0000 Subject: [PATCH] add function to make single-string of the cmd line args (very inefficient, but who cares?) --- src/binary_c_exit_macros.h | 2 +- src/binary_c_structures.h | 1 + .../common_envelope_evolution_BSE.c | 2 +- src/disc/disc_new_zone_radii.c | 7 +++- src/disc/disc_parameters.h | 4 +-- src/main.c | 1 - src/memory/initialize_pointers.c | 2 +- src/perl/scripts2/cbdiscs.pl | 9 +++--- src/setup/cmd_line_argstring.c | 32 +++++++++++++++++++ src/setup/setup_prototypes.h | 1 + 10 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 src/setup/cmd_line_argstring.c diff --git a/src/binary_c_exit_macros.h b/src/binary_c_exit_macros.h index 744fea103..1470c45c9 100644 --- a/src/binary_c_exit_macros.h +++ b/src/binary_c_exit_macros.h @@ -44,7 +44,7 @@ } -#define MAX_EXIT_STATEMENT_PRINT_SIZE 2048 +#define MAX_EXIT_STATEMENT_PRINT_SIZE (KIBIBYTE*16) #define Exit_or_return_void(...) { \ Exit_or_return((void) 0,__VA_ARGS__); \ diff --git a/src/binary_c_structures.h b/src/binary_c_structures.h index 89e8cc0d6..50fc4d185 100644 --- a/src/binary_c_structures.h +++ b/src/binary_c_structures.h @@ -1118,6 +1118,7 @@ struct disc_loss_t { }; struct disc_t { + struct stardata_t * stardata; struct memoize_hash_t * memo; /* memoize data */ double M; // disc total mass double alpha; // disc viscosity constant (dimensionless) diff --git a/src/common_envelope/common_envelope_evolution_BSE.c b/src/common_envelope/common_envelope_evolution_BSE.c index 0333ab15f..25837166c 100644 --- a/src/common_envelope/common_envelope_evolution_BSE.c +++ b/src/common_envelope/common_envelope_evolution_BSE.c @@ -2005,7 +2005,7 @@ end_section: cbdisc = new_disc(DISC_CIRCUMBINARY, stardata, DISC_OUTER_EDGE); - + cbdisc->stardata = stardata; double discM = mass_ejected * f_M; double discJ = J_ejected * f_J; diff --git a/src/disc/disc_new_zone_radii.c b/src/disc/disc_new_zone_radii.c index 991fdeab2..27d273067 100644 --- a/src/disc/disc_new_zone_radii.c +++ b/src/disc/disc_new_zone_radii.c @@ -136,7 +136,12 @@ Boolean disc_new_zone_radii(struct disc_t * const disc) { Safe_free(P); Safe_free(Q); - printf("ihottest -1 error\n"); + struct stardata_t * const stardata = disc->stardata; + char * s = cmd_line_argstring(stardata); + Exit_binary_c(2, + "args were : %s\n", + cmd_line_argstring(stardata)); + Safe_free(s); return FALSE; } diff --git a/src/disc/disc_parameters.h b/src/disc/disc_parameters.h index deb608bd4..128fa9cca 100644 --- a/src/disc/disc_parameters.h +++ b/src/disc/disc_parameters.h @@ -9,8 +9,8 @@ /* * Logging for individual systems with discs */ -#define DISC_LOG -#define DISC_LOG_2D +//#define DISC_LOG +//#define DISC_LOG_2D /* * Disc log max sizes (0 == unlimited) diff --git a/src/main.c b/src/main.c index 8fd082f36..ac4dac691 100644 --- a/src/main.c +++ b/src/main.c @@ -26,7 +26,6 @@ * For help and other documention, please see the doc/ * directory. */ - static int binary_c_main(int argc, char ** argv, struct stardata_t ** RESTRICT s); diff --git a/src/memory/initialize_pointers.c b/src/memory/initialize_pointers.c index 5f7120706..8d4226c79 100644 --- a/src/memory/initialize_pointers.c +++ b/src/memory/initialize_pointers.c @@ -8,7 +8,7 @@ void initialize_pointers(struct stardata_t * const stardata, /* * Set up pointers to memory locations required * by binary_c structures, - * e.g. stardata, global_stardata, preferences + * e.g. stardata, preferences * * Both stardata and preferences should be defined * elsewhere, and must not be NULL diff --git a/src/perl/scripts2/cbdiscs.pl b/src/perl/scripts2/cbdiscs.pl index 5b6646667..d19779a43 100755 --- a/src/perl/scripts2/cbdiscs.pl +++ b/src/perl/scripts2/cbdiscs.pl @@ -43,7 +43,7 @@ use threads::shared; my $lockvar : shared; # number of computational threads to launch -my $nthreads = 1; # rob_misc::ncpus(); +my $nthreads = ("@ARGV"=~/nthreads=(\d+)/)[0] // 1;#rob_misc::ncpus(); # make a new stellar population my $population = binary_grid2->new( @@ -514,6 +514,8 @@ sub parse_data $r->{final_eccentricity}->{$population->rebin($final_eccentricity,0.025)} += $p; } + if(defined $initparamspace_fp) + { # output init param space lock $lockvar; @@ -528,9 +530,8 @@ sub parse_data $final_eccentricity, $p; - - print {$initparamspace_fp} $s; - #print $s; + print {$initparamspace_fp} $s; + #print $s; } } elsif($header eq 'DISC_START') diff --git a/src/setup/cmd_line_argstring.c b/src/setup/cmd_line_argstring.c new file mode 100644 index 000000000..550930975 --- /dev/null +++ b/src/setup/cmd_line_argstring.c @@ -0,0 +1,32 @@ +#include "../binary_c.h" + +char * cmd_line_argstring(struct stardata_t * const stardata) +{ + char * s = '\0'; + int i; + for(i=0;i<stardata->common.argc;i++) + { + char * s2; + int n; + if(s == NULL) + { + n = asprintf(&s,"%s",stardata->common.argv[i]); + } + else + { + n = asprintf(&s2, + "%s %s", + s, + stardata->common.argv[i]); + Safe_free(s); + s = s2; + } + + if(n<0) + { + Exit_binary_c(2, + "Could not malloc in asprintf\n"); + } + } + return s; +} diff --git a/src/setup/setup_prototypes.h b/src/setup/setup_prototypes.h index 1a0941eb7..600022c93 100644 --- a/src/setup/setup_prototypes.h +++ b/src/setup/setup_prototypes.h @@ -91,6 +91,7 @@ void set_cmd_line_macro_pairs(struct stardata_t * RESTRICT const stardata, struct cmd_line_arg_t * const cmd_line_args2, unsigned int arg_count); void set_metallicities(struct stardata_t * RESTRICT const stardata); +char * cmd_line_argstring(struct stardata_t * const stardata); #endif /* SETUP_PROTOYPES_H */ -- GitLab