From d7406a63bd5b5ae1ea3d55f33e198de04f6adfab Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 1 Feb 2012 15:54:52 +0000 Subject: [PATCH] rewrite of most parts; handling of INT32 data added --- tools/h5pAttrib.cc | 1253 ++++++++++++-------------------------------- 1 file changed, 332 insertions(+), 921 deletions(-) diff --git a/tools/h5pAttrib.cc b/tools/h5pAttrib.cc index b690f48..c96e689 100644 --- a/tools/h5pAttrib.cc +++ b/tools/h5pAttrib.cc @@ -18,10 +18,10 @@ int get_option(int argc, const char **argv, const char *opts, const struct long_ static void print_help(); static void free_handler(struct arg_handler *hand, int len); static void print_all(H5PartFile* file); -static void print_nstep(H5PartFile* file, char * garbage); +static void print_num_steps(H5PartFile* file, char * garbage); static void print_file_attributes(H5PartFile* file, char * garbage); static void print_step_attributes(H5PartFile* file, char *attr); -static void print_dataset(H5PartFile* file, char *attr); +static void print_datasets(H5PartFile* file, char *attr); static struct arg_handler* function_assign(int argc, const char *argv[]); /* Global variables */ @@ -274,7 +274,7 @@ static struct arg_handler* function_assign(int argc, const char *argv[]) { if (!hand[i].func) { - hand[i].func = print_dataset; + hand[i].func = print_datasets; hand[i].obj = strdup(opt_arg); break; } @@ -287,7 +287,7 @@ static struct arg_handler* function_assign(int argc, const char *argv[]) { if (!hand[i].func) { - hand[i].func = print_nstep; + hand[i].func = print_num_steps; hand[i].obj = NULL; // inserting garabage value that we won't use. (For function interface compatibility) break; } @@ -305,955 +305,366 @@ static struct arg_handler* function_assign(int argc, const char *argv[]) } /* For printing help page */ -static void print_help() -{ - fflush(stdout); - fprintf(stdout, "\nusage: h5pAttrib [OPTIONS] file\n"); - fprintf(stdout, "\n"); - fprintf(stdout, " OPTIONS\n"); - fprintf(stdout, " -h, --help Print help page\n"); - fprintf(stdout, " -n, --nstep Print number of steps\n"); - fprintf(stdout, " -A, --fileA Print file attributes\n"); - fprintf(stdout, " -a n, --stepA n Print step attributes & values for time step n\n"); - fprintf(stdout, " -d n, --dataset n Print data sets names & values for time step n\n"); - fprintf(stdout, " -H, --header Print shorter version without the values\n"); - fprintf(stdout, "\n"); - fprintf(stdout, " Examples:\n"); - fprintf(stdout, "\n"); - fprintf(stdout, " 1) Show file attribute names & values of sample.h5part\n"); - fprintf(stdout, "\n"); - fprintf(stdout, " h5pAttrib -A sample.h5part\n"); - fprintf(stdout, "\t\t\tOR\n"); - fprintf(stdout, " h5pAttrib --fileA sample.h5part\n"); - fprintf(stdout, "\n"); - fprintf(stdout, " 2) Show step attribute names for time step 5 of sample.h5part\n"); - fprintf(stdout, "\n"); - fprintf(stdout, " h5pAttrib -a 5 -H sample.h5part\n"); - fprintf(stdout, "\t\t\tOR\n"); - fprintf(stdout, " h5pAttrib --stepA 5 -H sample.h5part\n"); - fprintf(stdout, "\n"); +static void +print_help () { + fflush(stdout); + fprintf(stdout, "\nusage: h5pAttrib [OPTIONS] file\n"); + fprintf(stdout, "\n"); + fprintf(stdout, " OPTIONS\n"); + fprintf(stdout, " -h, --help Print help page\n"); + fprintf(stdout, " -n, --nstep Print number of steps\n"); + fprintf(stdout, " -A, --fileA Print file attributes\n"); + fprintf(stdout, " -a n, --stepA n Print step attributes & values for time step n\n"); + fprintf(stdout, " -d n, --dataset n Print data sets names & values for time step n\n"); + fprintf(stdout, " -H, --header Print shorter version without the values\n"); + fprintf(stdout, "\n"); + fprintf(stdout, " Examples:\n"); + fprintf(stdout, "\n"); + fprintf(stdout, " 1) Show file attribute names & values of sample.h5part\n"); + fprintf(stdout, "\n"); + fprintf(stdout, " h5pAttrib -A sample.h5part\n"); + fprintf(stdout, "\t\t\tOR\n"); + fprintf(stdout, " h5pAttrib --fileA sample.h5part\n"); + fprintf(stdout, "\n"); + fprintf(stdout, " 2) Show step attribute names for time step 5 of sample.h5part\n"); + fprintf(stdout, "\n"); + fprintf(stdout, " h5pAttrib -a 5 -H sample.h5part\n"); + fprintf(stdout, "\t\t\tOR\n"); + fprintf(stdout, " h5pAttrib --stepA 5 -H sample.h5part\n"); + fprintf(stdout, "\n"); } -/* For priting everything (default option when no flags provided.) */ -static void print_all(H5PartFile* file) -{ - int nt; - char file_attrib[MAX_LEN]; - h5part_int64_t type; - h5part_int64_t num_elem; - h5part_int64_t num_attrib; - char step_attrib[MAX_LEN]; - h5part_int64_t i, j, k; - h5part_int64_t count; - void* value = NULL; - h5part_int64_t timestep_ctr; - - char data_name[MAX_LEN]; - h5part_int64_t num_dataset; - h5part_int64_t nparticles; - - fprintf(stdout, "\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - fprintf(stdout, "\n"); - nt=H5PartGetNumSteps(file); - fprintf(stdout, "There are total %d number of timesteps.\n",nt); - - fprintf(stdout, "\nDump result for \"%s\"...\n\n", global_fname); - fprintf(stdout, "FILE_ATTRIBUTES:\n"); - - - if(print_header) - { - num_attrib = H5PartGetNumFileAttribs(file); - - for(i=0; i