diff --git a/doc/tbse.help b/doc/tbse.help index d69c3292ebba1e504103de28a5605e0de19f2868..5999937e7e4246c5f928fed694bb5b2e25c0cce5 100644 --- a/doc/tbse.help +++ b/doc/tbse.help @@ -32,7 +32,7 @@ All other parameters will be as in the tbse script. ------------------------------------------------------------ -option flags for running binary_c +option flags for running tbse echo Outputs the arguments that would be sent to binary_c, @@ -117,3 +117,12 @@ Return value tbse, when run normally, returns the return value of binary_c ------------------------------------------------------------ + +If you want help with a specific binary_c option, run + +./binary_c <string> + +where <string> is the option about which you hold some +curiosity. + +------------------------------------------------------------ diff --git a/src/API/binary_c_API_prototypes.h b/src/API/binary_c_API_prototypes.h index c66e08cf715f91fc7c175a385139729990d13607..282da27a62bcf64fb9374af5c2fb10bc5c0ee02c 100644 --- a/src/API/binary_c_API_prototypes.h +++ b/src/API/binary_c_API_prototypes.h @@ -46,8 +46,8 @@ void binary_c_API_function binary_c_buffer_empty_buffer(struct stardata_t * REST void binary_c_API_function binary_c_help(struct stardata_t * RESTRICT const stardata, char * argstring); - +void binary_c_API_function binary_c_help_all(struct stardata_t * RESTRICT const stardata); /* * API debugging functions diff --git a/src/API/binary_c_help.c b/src/API/binary_c_help.c index daac0e82f64658a98602d3266fb246f2a59fb2c3..f28c68d8c49ac08993606aac0e6d16c32c6c96b4 100644 --- a/src/API/binary_c_help.c +++ b/src/API/binary_c_help.c @@ -25,13 +25,14 @@ void binary_c_API_function binary_c_help(struct stardata_t * RESTRICT const star if(tmpstore == NULL) { build_tmpstore_contents(tmpstore); + stardata->tmpstore = tmpstore; } binary_c_help_from_arg( - stardata->tmpstore->cmd_line_args, + tmpstore->cmd_line_args, stardata, &c, 0, // dummy var - stardata->tmpstore->arg_count, // arg_count + tmpstore->arg_count, // arg_count argv, -argc // argc ); diff --git a/src/logging/log_every_timestep.c b/src/logging/log_every_timestep.c index af24773ffa6208e6c1743b92d0264bf7d6cea022..108af9f8754356e40a6caf13552a1ce0f60a40fd 100644 --- a/src/logging/log_every_timestep.c +++ b/src/logging/log_every_timestep.c @@ -2635,8 +2635,8 @@ void log_every_timestep(struct stardata_t * RESTRICT const stardata) L, dtp, is_single == TRUE ? 0 : 1, - gaia_colour, - gaia_magnitude + gaia_magnitude, + gaia_colour ); } diff --git a/src/main.c b/src/main.c index d73c004fcc168bf17472f3c8a83cd0514c8b4800..d8c1c27f44e5a17fdc26092b2a53910377c3f8b2 100644 --- a/src/main.c +++ b/src/main.c @@ -47,7 +47,7 @@ int main (int argc, Set_stack_size; struct stardata_t * stardata Aligned = NULL; - + const int ret = binary_c_main(argc,argv,&stardata); #if !defined SEGFAULTS @@ -81,7 +81,7 @@ static int binary_c_main(int argc, &preferences, &store); *s = stardata; - + #ifdef USE_GSL /* set up GSL */ setup_GSL_handlers(stardata); @@ -99,7 +99,7 @@ static int binary_c_main(int argc, /* examine command line arguments */ set_up_variables(argc,argv,NULL,stardata); #endif - + #ifdef MAKE_BSE_TABLES make_BSE_tables(stardata); #endif @@ -107,8 +107,7 @@ static int binary_c_main(int argc, /* save argv and argc */ stardata->common.argv = argv; stardata->common.argc = argc; - - + #ifdef TEST_OPACITY struct opacity_t op; diff --git a/src/setup/argument_setting_functions.c b/src/setup/argument_setting_functions.c index 6ee3ce087cdf7d6669153f47deaa8fb74f08fdd8..eaebecf21ae98885a4537386dbbbc7ee4f506c42 100644 --- a/src/setup/argument_setting_functions.c +++ b/src/setup/argument_setting_functions.c @@ -41,8 +41,8 @@ void No_return binary_c_speedtests(ARG_SUBROUTINE_DECLARATION) { for(i=0;i<ntests;i++) { - double x=(double)rand(); - x*=1.0; + double x = (double)rand(); + x *= 1.0; } } End_test("Multiply by FLOAT_TYPE rand : %g s\n",TIME_TAKEN); @@ -152,10 +152,17 @@ void binary_c_help_from_arg(ARG_SUBROUTINE_DECLARATION) /* * Output help: either a general help statement (binary_c --help), * or per-argument help (binary_c --help <arg1> <arg2> ...) + * + * Note that stardata should not be NULL. + * + * If argc < 0 and batchmode is off, we then exit after + * showing help. */ - Boolean __exit = argc >= 0 ? TRUE : FALSE; + const Boolean exit_help = (argc >= 0 && + stardata->preferences && + Batchmode_is_off(stardata->preferences->batchmode)) ? TRUE : FALSE; if(argc < 0) argc = -argc; - + if(*c==argc-1) { /* no extra help required */ @@ -173,8 +180,8 @@ void binary_c_help_from_arg(ARG_SUBROUTINE_DECLARATION) } else { - char *next = NULL; - int head=0; + char * next = NULL; + Boolean head = FALSE; (*c)++; while(*c<argc) { @@ -220,10 +227,10 @@ void binary_c_help_from_arg(ARG_SUBROUTINE_DECLARATION) */ if(strstr(cmd_line_args[i].name,next) != NULL) { - if(head==0) + if(head == FALSE) { Printf("Did you mean :\n\n"); - head=1; + head = TRUE; } Printf(" %s\n",cmd_line_args[i].name); } @@ -234,10 +241,11 @@ void binary_c_help_from_arg(ARG_SUBROUTINE_DECLARATION) if(success==FALSE) Printf("\nBinary_c help : no help available for %s\n",next); (*c)++; } - - if(__exit) + + if(exit_help == TRUE) { - Exit_binary_c(BINARY_C_NORMAL_EXIT,"Exit after help\n"); + Exit_binary_c(BINARY_C_NORMAL_EXIT, + "Exit after help\n"); } else { @@ -247,26 +255,43 @@ void binary_c_help_from_arg(ARG_SUBROUTINE_DECLARATION) } -void No_return binary_c_help_all(ARG_SUBROUTINE_DECLARATION) +void binary_c_help_all_from_arg(ARG_SUBROUTINE_DECLARATION) { - /* show help for all arguments */ - static const char *cc[] = ARG_SECTION_STRINGS; - int j; - for(j=0;j<NUMBER_OF_ARG_SECTIONS;j++) + /* Show help for all arguments (into the buffer + * so stardata should not be NULL) + * + * If argc < 0 and batchmode is off, we then exit. + */ + if(stardata != NULL) { - Printf("\n############################################################\n##### Section %s\n############################################################\n",cc[j]); - for(i=0;i<arg_count;i++) - { - if(cmd_line_args[i].section == j) - { - Printf("%s : %s : %s\n", - cmd_line_args[i].name, - cmd_line_args[i].help, - cmd_line_args[i].wtts_string); - } - } + const Boolean exit_help_all = + (argc >= 0 && + stardata->preferences && + Batchmode_is_off(stardata->preferences->batchmode)) ? TRUE : FALSE; + static const char *cc[] = ARG_SECTION_STRINGS; + int j; + + for(j=0;j<NUMBER_OF_ARG_SECTIONS;j++) + { + Printf("\n############################################################\n##### Section %s\n############################################################\n",cc[j]); + + for(i=0;i<arg_count;i++) + { + if(cmd_line_args[i].section == j) + { + Printf("%s : %s : %s\n", + cmd_line_args[i].name, + cmd_line_args[i].help, + cmd_line_args[i].wtts_string); + } + } + } + + if(exit_help_all == TRUE) + { + Exit_binary_c(BINARY_C_NORMAL_EXIT,NULL); + } } - Exit_binary_c(BINARY_C_NORMAL_EXIT,NULL); } #ifdef BATCHMODE diff --git a/src/setup/cmd_line_args.h b/src/setup/cmd_line_args.h index b07de95c293b5eb2111798d39cda079b6cc67ef4..6cb1e8ad83ab16e09eaab2912fcc29136161d4d7 100644 --- a/src/setup/cmd_line_args.h +++ b/src/setup/cmd_line_args.h @@ -3538,7 +3538,7 @@ struct cmd_line_arg_t "Display all help pages.", \ ARG_SUBROUTINE, \ "Ignore", \ - &(binary_c_help_all) \ + &(binary_c_help_all_from_arg) \ ,1.0 \ }, \ { \ diff --git a/src/setup/parse_arguments.c b/src/setup/parse_arguments.c index 1ce6238a3e31fc29caa6dfd2548484d4c52af229..efd7190b401215fae88e6d1f0812df6d1e39d747 100644 --- a/src/setup/parse_arguments.c +++ b/src/setup/parse_arguments.c @@ -437,14 +437,14 @@ void parse_arguments(const int start, { Dprint( "Exit because given cmd line arg \"%s\" (number %d) failed to match any known argument.", - arg,c); + arg,c); Exit_binary_c( BINARY_C_SETUP_UNKNOWN_ARGUMENT, "Exit because given cmd line arg \"%s\" (number %d) failed to match any known argument (prev args are \"%s\" and \"%s\").", arg, c, - argv[c<=1?0:c-2], - argv[c<=0?1:c-1] + Batchmode_is_on(stardata) ? "N/A (in batchmode)" : argv[c<=1 ? 0 : (c-2)], + Batchmode_is_on(stardata) ? "N/A (in batchmode)" : argv[c<=0 ? 1 : (c-1)] ); } } /* loop over cmd line args */ diff --git a/src/setup/setup_prototypes.h b/src/setup/setup_prototypes.h index b5ea2703815fcb7e9ac8f0a72d8c9bc024ed8423..765374d5d661c26b5a345a27ec0c019f1d3c492e 100644 --- a/src/setup/setup_prototypes.h +++ b/src/setup/setup_prototypes.h @@ -36,7 +36,7 @@ void force_flushing(void); void binary_c_help_from_arg(ARG_SUBROUTINE_DECLARATION); -void binary_c_help_all(ARG_SUBROUTINE_DECLARATION) No_return; +void binary_c_help_all_from_arg(ARG_SUBROUTINE_DECLARATION); void binary_c_speedtests(ARG_SUBROUTINE_DECLARATION) No_return; void binary_c_warmup_cpu(ARG_SUBROUTINE_DECLARATION); void list_available_args(ARG_SUBROUTINE_DECLARATION); diff --git a/src/stellar_colours/gaia_magnitudes.c b/src/stellar_colours/gaia_magnitudes.c index ae54f2e5fd27d9a1b24191075d2b74efce2fd31e..179c628ef1b72b1204dcc5c5840619e3257d8ef1 100644 --- a/src/stellar_colours/gaia_magnitudes.c +++ b/src/stellar_colours/gaia_magnitudes.c @@ -18,8 +18,8 @@ static double crosscubic(const double x, const double h); void gaia_magnitudes(struct stardata_t * stardata, - double * RESTRICT magnitudes, - int method) + double * RESTRICT magnitudes, + int method) { /* * Given a populated magntiudes array, diff --git a/src/stellar_colours/stellar_colour_macros.h b/src/stellar_colours/stellar_colour_macros.h index bb53bf73a4edb28a27e5b12ecae8b504eaf98970..e298b1e251095ebdd67f00a086c52138901469c0 100644 --- a/src/stellar_colours/stellar_colour_macros.h +++ b/src/stellar_colours/stellar_colour_macros.h @@ -36,24 +36,32 @@ #define STELLAR_MAGNITUDE_GAIA_GRP 22 #define STELLAR_MAGNITUDE_GAIA_GRVS 23 -#define STELLAR_COLOUR_STRINGS {"U","B","V","R","I","J","H","K","u","g","r","i","z","f300w","f336w","f435w","f450w","f555w","f606w","f814w","G","GBP","GRP","GRVS"} +/* number of the above magnitudes */ +#define NUMBER_OF_STELLAR_MAGNITUDES 24 -#define STELLAR_COLOUR_STRING_LENGTH ((size_t)6) +#define STELLAR_COLOUR_STRINGS \ + { \ + "U","B","V","R","I", \ + "J","H","K","u","g", \ + "r","i","z","f300w","f336w", \ + "f435w","f450w","f555w","f606w","f814w", \ + "G","GBP","GRP","GRVS" \ + } -#define NUMBER_OF_STELLAR_MAGNITUDES 24 +/* + * STELLAR_COLOUR_STRING_LENGTH is the maximum number + * of characters in one of the above strings, +1 + */ +#define STELLAR_COLOUR_STRING_LENGTH ((size_t)(1+5)) -/* Gaia conversion methods */ +/* Gaia conversion methods */ #define GAIA_CONVERSION_USE_DEFAULT 0 #define GAIA_CONVERSION_UBVRI_SINGLE 1 #define GAIA_CONVERSION_UBVRI_DOUBLE 2 #define GAIA_CONVERSION_ugriz_SINGLE 3 -#define GAIA_CONVERSION_ugriz_DOUBLE 3 - -#define GAIA_CONVERSION_DEFAULT_METHOD GAIA_CONVERSION_UBVRI_DOUBLE - - - +#define GAIA_CONVERSION_ugriz_DOUBLE 4 +#define GAIA_CONVERSION_DEFAULT_METHOD (GAIA_CONVERSION_UBVRI_DOUBLE) #endif// COLOUR_MACROS_H diff --git a/src/stellar_structure/make_data_objects.sh b/src/stellar_structure/make_data_objects.sh index 441ecf29d6b437a03a6662b3410ce56d8a9296d8..e61d23ada9b6275deb5ecaa7afe73c99eb2784ae 100755 --- a/src/stellar_structure/make_data_objects.sh +++ b/src/stellar_structure/make_data_objects.sh @@ -4,7 +4,9 @@ # http://gareus.org/wiki/embedding_resources_in_executables : ${CC:="gcc"} -: ${OBJCOPY_OPTS:="-I binary -B i386:x86-64 -O elf64-x86-64"} +: ${OBJCOPY_ARCH:=$(objdump -f /bin/bash |grep architecture | gawk "{print \$2}" | sed s/,//)} +: ${OBJCOPY_TARGET:=$(objdump -f /bin/bash | grep format | gawk "{print \$4}")} +: ${OBJCOPY_OPTS:="-I binary -B $OBJCOPY_ARCH -O $OBJCOPY_TARGET"} # Miller Bertolami's post-AGB tables HFILE=miller_bertolami_postagb.h @@ -21,7 +23,7 @@ if [ $HFILE -nt $OBJFILE ] ; then OPTS="--rename-section .data=.rodata,alloc,load,readonly,data,contents " objcopy $OBJCOPY_OPTS $OPTS $TMPFILE $OBJFILE - # ld -r -b binary -o $OBJFILE $TMPFILE + #ld -r -b binary -o $OBJFILE $TMPFILE rm $TMPFILE rm ./double2bin