Possibility to dump/retrieve tree on disk. Dump voids particle positions correctly

This commit is contained in:
Guilhem Lavaux 2010-09-23 10:19:48 -04:00
parent 3088bb5733
commit 8bf13dfb8b
4 changed files with 168 additions and 28 deletions

View file

@ -1,5 +1,5 @@
/*
File autogenerated by gengetopt version 2.22
File autogenerated by gengetopt version 2.22.2
generated with the following command:
gengetopt -i buildObservedVoids.ggo -f buildObservedVoids_conf -a buildObservedVoids_info -F buildObservedVoids_conf -C
@ -17,6 +17,10 @@
#include <stdlib.h>
#include <string.h>
#ifndef FIX_UNUSED
#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
#endif
#include "getopt.h"
#include "buildObservedVoids_conf.h"
@ -40,8 +44,11 @@ const char *buildObservedVoids_info_help[] = {
" -g, --gridOutput=STRING 3d grid output of voids \n (default=`all_voids.nc')",
" -q, --quiet Quiet output (default=off)",
" --dumpVoids=STRING Dump the particles in void in a file",
" --dumpIds Dump particle ids (default=off)",
" --ramsesBase=STRING Base directory for ramses",
" --ramsesId=INT Ramses snapshot id",
" --dumpTree Dump the void tree (default=off)",
" --getTree Restore tree from file (default=off)",
0
};
@ -106,13 +113,17 @@ void clear_given (struct buildObservedVoids_info *args_info)
args_info->gridOutput_given = 0 ;
args_info->quiet_given = 0 ;
args_info->dumpVoids_given = 0 ;
args_info->dumpIds_given = 0 ;
args_info->ramsesBase_given = 0 ;
args_info->ramsesId_given = 0 ;
args_info->dumpTree_given = 0 ;
args_info->getTree_given = 0 ;
}
static
void clear_args (struct buildObservedVoids_info *args_info)
{
FIX_UNUSED (args_info);
args_info->desc_arg = NULL;
args_info->desc_orig = NULL;
args_info->partzone_arg = NULL;
@ -132,9 +143,12 @@ void clear_args (struct buildObservedVoids_info *args_info)
args_info->quiet_flag = 0;
args_info->dumpVoids_arg = NULL;
args_info->dumpVoids_orig = NULL;
args_info->dumpIds_flag = 0;
args_info->ramsesBase_arg = NULL;
args_info->ramsesBase_orig = NULL;
args_info->ramsesId_orig = NULL;
args_info->dumpTree_flag = 0;
args_info->getTree_flag = 0;
}
@ -155,15 +169,20 @@ void init_args_info(struct buildObservedVoids_info *args_info)
args_info->gridOutput_help = buildObservedVoids_info_help[9] ;
args_info->quiet_help = buildObservedVoids_info_help[10] ;
args_info->dumpVoids_help = buildObservedVoids_info_help[11] ;
args_info->ramsesBase_help = buildObservedVoids_info_help[12] ;
args_info->ramsesId_help = buildObservedVoids_info_help[13] ;
args_info->dumpIds_help = buildObservedVoids_info_help[12] ;
args_info->ramsesBase_help = buildObservedVoids_info_help[13] ;
args_info->ramsesId_help = buildObservedVoids_info_help[14] ;
args_info->dumpTree_help = buildObservedVoids_info_help[15] ;
args_info->getTree_help = buildObservedVoids_info_help[16] ;
}
void
buildObservedVoids_conf_print_version (void)
{
printf ("%s %s\n", BUILDOBSERVEDVOIDS_CONF_PACKAGE, BUILDOBSERVEDVOIDS_CONF_VERSION);
printf ("%s %s\n",
(strlen(BUILDOBSERVEDVOIDS_CONF_PACKAGE_NAME) ? BUILDOBSERVEDVOIDS_CONF_PACKAGE_NAME : BUILDOBSERVEDVOIDS_CONF_PACKAGE),
BUILDOBSERVEDVOIDS_CONF_VERSION);
}
static void print_help_common(void) {
@ -178,7 +197,7 @@ static void print_help_common(void) {
printf("\n");
if (strlen(buildObservedVoids_info_description) > 0)
printf("%s\n", buildObservedVoids_info_description);
printf("%s\n\n", buildObservedVoids_info_description);
}
void
@ -262,8 +281,9 @@ buildObservedVoids_conf_release (struct buildObservedVoids_info *args_info)
static void
write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
{
FIX_UNUSED (values);
if (arg) {
fprintf(outfile, "%s=\"%s\"\n", opt, arg);
} else {
@ -307,10 +327,16 @@ buildObservedVoids_conf_dump(FILE *outfile, struct buildObservedVoids_info *args
write_into_file(outfile, "quiet", 0, 0 );
if (args_info->dumpVoids_given)
write_into_file(outfile, "dumpVoids", args_info->dumpVoids_orig, 0);
if (args_info->dumpIds_given)
write_into_file(outfile, "dumpIds", 0, 0 );
if (args_info->ramsesBase_given)
write_into_file(outfile, "ramsesBase", args_info->ramsesBase_orig, 0);
if (args_info->ramsesId_given)
write_into_file(outfile, "ramsesId", args_info->ramsesId_orig, 0);
if (args_info->dumpTree_given)
write_into_file(outfile, "dumpTree", 0, 0 );
if (args_info->getTree_given)
write_into_file(outfile, "getTree", 0, 0 );
i = EXIT_SUCCESS;
@ -347,7 +373,7 @@ buildObservedVoids_conf_free (struct buildObservedVoids_info *args_info)
char *
gengetopt_strdup (const char *s)
{
char *result = NULL;
char *result = 0;
if (!s)
return result;
@ -369,7 +395,7 @@ buildObservedVoids_conf_ext (int argc, char * const *argv, struct buildObservedV
struct buildObservedVoids_conf_params *params)
{
int result;
result = buildObservedVoids_conf_internal (argc, argv, args_info, params, NULL);
result = buildObservedVoids_conf_internal (argc, argv, args_info, params, 0);
if (result == EXIT_FAILURE)
{
@ -392,7 +418,7 @@ buildObservedVoids_conf2 (int argc, char * const *argv, struct buildObservedVoid
params.check_ambiguity = 0;
params.print_errors = 1;
result = buildObservedVoids_conf_internal (argc, argv, args_info, &params, NULL);
result = buildObservedVoids_conf_internal (argc, argv, args_info, &params, 0);
if (result == EXIT_FAILURE)
{
@ -408,7 +434,7 @@ buildObservedVoids_conf_required (struct buildObservedVoids_info *args_info, con
{
int result = EXIT_SUCCESS;
if (buildObservedVoids_conf_required2(args_info, prog_name, NULL) > 0)
if (buildObservedVoids_conf_required2(args_info, prog_name, 0) > 0)
result = EXIT_FAILURE;
if (result == EXIT_FAILURE)
@ -423,6 +449,7 @@ buildObservedVoids_conf_required (struct buildObservedVoids_info *args_info, con
int
buildObservedVoids_conf_required2 (struct buildObservedVoids_info *args_info, const char *prog_name, const char *additional_error)
{
FIX_UNUSED (additional_error);
int error = 0;
/* checks for required options */
@ -474,13 +501,15 @@ static char *package_name = 0;
static
int update_arg(void *field, char **orig_field,
unsigned int *field_given, unsigned int *prev_given,
char *value, char *possible_values[], const char *default_value,
char *value, const char *possible_values[],
const char *default_value,
buildObservedVoids_conf_arg_type arg_type,
int check_ambiguity, int override,
int no_free, int multiple_option,
const char *long_opt, char short_opt,
const char *additional_error)
{
FIX_UNUSED (field);
char *stop_char = 0;
const char *val = value;
int found;
@ -502,6 +531,7 @@ int update_arg(void *field, char **orig_field,
return 1; /* failure */
}
FIX_UNUSED (default_value);
if (field_given && *field_given && ! override)
return 0;
@ -569,7 +599,8 @@ int update_arg(void *field, char **orig_field,
int
buildObservedVoids_conf_internal (int argc, char * const *argv, struct buildObservedVoids_info *args_info,
buildObservedVoids_conf_internal (
int argc, char * const *argv, struct buildObservedVoids_info *args_info,
struct buildObservedVoids_conf_params *params, const char *additional_error)
{
int c; /* Character of the parsed option. */
@ -616,9 +647,12 @@ buildObservedVoids_conf_internal (int argc, char * const *argv, struct buildObse
{ "gridOutput", 1, NULL, 'g' },
{ "quiet", 0, NULL, 'q' },
{ "dumpVoids", 1, NULL, 0 },
{ "dumpIds", 0, NULL, 0 },
{ "ramsesBase", 1, NULL, 0 },
{ "ramsesId", 1, NULL, 0 },
{ NULL, 0, NULL, 0 }
{ "dumpTree", 0, NULL, 0 },
{ "getTree", 0, NULL, 0 },
{ 0, 0, 0, 0 }
};
c = getopt_long (argc, argv, "hVd:p:v:m:f:o:g:q", long_options, &option_index);
@ -760,6 +794,18 @@ buildObservedVoids_conf_internal (int argc, char * const *argv, struct buildObse
additional_error))
goto failure;
}
/* Dump particle ids. */
else if (strcmp (long_options[option_index].name, "dumpIds") == 0)
{
if (update_arg((void *)&(args_info->dumpIds_flag), 0, &(args_info->dumpIds_given),
&(local_args_info.dumpIds_given), optarg, 0, 0, ARG_FLAG,
check_ambiguity, override, 1, 0, "dumpIds", '-',
additional_error))
goto failure;
}
/* Base directory for ramses. */
else if (strcmp (long_options[option_index].name, "ramsesBase") == 0)
@ -788,6 +834,30 @@ buildObservedVoids_conf_internal (int argc, char * const *argv, struct buildObse
additional_error))
goto failure;
}
/* Dump the void tree. */
else if (strcmp (long_options[option_index].name, "dumpTree") == 0)
{
if (update_arg((void *)&(args_info->dumpTree_flag), 0, &(args_info->dumpTree_given),
&(local_args_info.dumpTree_given), optarg, 0, 0, ARG_FLAG,
check_ambiguity, override, 1, 0, "dumpTree", '-',
additional_error))
goto failure;
}
/* Restore tree from file. */
else if (strcmp (long_options[option_index].name, "getTree") == 0)
{
if (update_arg((void *)&(args_info->getTree_flag), 0, &(args_info->getTree_given),
&(local_args_info.getTree_given), optarg, 0, 0, ARG_FLAG,
check_ambiguity, override, 1, 0, "getTree", '-',
additional_error))
goto failure;
}
break;
@ -830,7 +900,7 @@ failure:
/* 3 is for "--" and "=" */
static int
_buildObservedVoids_conf_configfile (char * const filename, int *my_argc)
_buildObservedVoids_conf_configfile (const char *filename, int *my_argc)
{
FILE* file;
char my_argv[CONFIG_FILE_LINE_BUFFER_SIZE+1];
@ -842,14 +912,14 @@ _buildObservedVoids_conf_configfile (char * const filename, int *my_argc)
size_t len, next_token;
char delimiter;
if ((file = fopen(filename, "r")) == NULL)
if ((file = fopen(filename, "r")) == 0)
{
fprintf (stderr, "%s: Error opening configuration file '%s'\n",
BUILDOBSERVEDVOIDS_CONF_PACKAGE, filename);
return EXIT_FAILURE;
}
while ((fgets(linebuf, CONFIG_FILE_LINE_SIZE, file)) != NULL)
while ((fgets(linebuf, CONFIG_FILE_LINE_SIZE, file)) != 0)
{
++line_num;
my_argv[0] = '\0';
@ -876,7 +946,7 @@ _buildObservedVoids_conf_configfile (char * const filename, int *my_argc)
if (fopt[next_token] == '\0') /* the line is over */
{
farg = NULL;
farg = 0;
equal = 0;
goto noarg;
}
@ -967,7 +1037,8 @@ _buildObservedVoids_conf_configfile (char * const filename, int *my_argc)
}
int
buildObservedVoids_conf_configfile (char * const filename,
buildObservedVoids_conf_configfile (
const char *filename,
struct buildObservedVoids_info *args_info,
int override, int initialize, int check_required)
{
@ -983,7 +1054,7 @@ buildObservedVoids_conf_configfile (char * const filename,
}
int
buildObservedVoids_conf_config_file (char * const filename,
buildObservedVoids_conf_config_file (const char *filename,
struct buildObservedVoids_info *args_info,
struct buildObservedVoids_conf_params *params)
{