From 54bd9df25e54e3f2e1657f9f9642cf2ba7d30f0e Mon Sep 17 00:00:00 2001 From: Gerber van der Graaf Date: Mon, 28 Jan 2013 10:27:22 +0100 Subject: [PATCH] libgpiv so version 4: GpivFt. Show git hash (if available) in output and error messages --- CMakeLists.txt | 4 ++-- src/evaluate/rr.c | 27 +++++++++--------------- src/image/t-avg-img.c | 56 +++++++++++++++++++++++++++++++++----------------- src/misc/hdf2piv.c | 2 +- src/misc/suta.c | 2 -- src/post/aint.c | 6 ++++-- src/post/manipiv.c | 12 +++++++---- src/post/s-avg.c | 24 ++++++++++++++-------- src/post/scale.c | 12 +++++++---- src/post/vorstra.c | 23 +++++++++++++-------- src/validate/errvec.c | 44 +++++++++++++++++++++++++++++++-------- src/validate/peaklck.c | 6 ++++-- 12 files changed, 140 insertions(+), 78 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f195f16..0c9a593 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,12 +43,12 @@ set(EXE_PREFIX "${_DEFAULT_EXE_PREFIX}" mark_as_advanced(EXE_PREFIX) # --enable-mpi enable Message Protocol Interface (MPI) -include_directories( ${MPI_INCLUDE_PATH} ) -set( LIBS ${LIBS} ${MPI_LIBRARY} ) option( USE_MPI "Parallel processing on distributed memory systems" OFF ) if(USE_MPI) add_definitions(-DENABLE_MPI) find_package( MPI ) + include_directories( ${MPI_INCLUDE_PATH} ) + set( LIBS ${LIBS} ${MPI_LIBRARY} ) endif() # --enable-cam enable (IEEE-1394) camera diff --git a/src/evaluate/rr.c b/src/evaluate/rr.c index 6fa5840..7a9fd1d 100644 --- a/src/evaluate/rr.c +++ b/src/evaluate/rr.c @@ -631,10 +631,6 @@ main (int argc, GpivPivPar *piv_par = g_new0 (GpivPivPar, 1); GpivValidPar *valid_par = g_new0 (GpivValidPar, 1); -#ifdef _OPENMP - int np, num_threads; -#endif /* _OPENMP */ - #ifdef ENABLE_MPI /* gint argc_mpi; */ /* gchar *argv_mpi[10]; */ @@ -665,15 +661,6 @@ main (int argc, gpiv_piv_parameters_set (piv_par, FALSE); gpiv_valid_parameters_set (valid_par, FALSE); -#ifdef _OPENMP - /* - * Initializing OMP - */ - np = omp_get_num_procs(); - omp_set_num_threads(np); - num_threads = omp_get_max_threads(); -#endif /* _OPENMP */ - #ifdef ENABLE_MPI if (rank == 0) { #endif /* ENABLE_MPI */ @@ -686,9 +673,11 @@ main (int argc, if (verbose) { #ifdef GIT_HASH - printf ("\n# %s\n# Command line options:\n", GIT_REV); + printf ("\n# Software: %s\n# git hash: %s\n# Command line options:\n", + argv[0], GIT_REV); #else - printf ("\n# %s\n# Command line options:\n", GPIVTOOLS_VERSION); + printf ("\n# Software: %s\n# version: %s\n# Command line options:\n", + argv[0], GPIVTOOLS_VERSION); #endif gpiv_piv_print_parameters (stdout, piv_par); gpiv_valid_print_parameters (stdout, valid_par); @@ -816,9 +805,13 @@ main (int argc, * Add comments to PIV data and saving */ #ifdef GIT_HASH - piv_data->comment = g_strdup_printf ("# Software: %s\n", GIT_REV); + piv_data->comment = + g_strdup_printf ("# Software: %s\n# git hash: %s\n# Command line options:\n", + argv[0], GIT_REV); #else - piv_data->comment = g_strdup_printf ("# Software: %s\n", GPIVTOOLS_VERSION); + piv_data->comment = + g_strdup_printf ("# Software: %s\n# version: %s\n# Command line options:\n", + argv[0], GPIVTOOLS_VERSION); #endif piv_data->comment = gpiv_add_datetime_to_comment (piv_data->comment); piv_data->comment = g_strconcat (piv_data->comment, diff --git a/src/image/t-avg-img.c b/src/image/t-avg-img.c index 5cb2ab3..8342993 100644 --- a/src/image/t-avg-img.c +++ b/src/image/t-avg-img.c @@ -192,7 +192,8 @@ command_args (int argc, char *argv[], void -make_fname_out (gchar *fname_base, +make_fname_out (char *argv[], + gchar *fname_base, gchar *fname_header, gchar *fname_parameter, gchar *fname_out @@ -204,9 +205,13 @@ make_fname_out (gchar *fname_base, char f_dum[GPIV_MAX_CHARS]; #ifdef GIT_HASH - if (fname__set == FALSE) gpiv_error("%s: File basename has to be set", GIT_REV); + if (fname__set == FALSE) + gpiv_error("Software: %s git hash: %s: File basename has to be set", + argv[0], GIT_REV); #else - if (fname__set == FALSE) gpiv_error("%s: File basename has to be set", GPIVTOOLS_VERSION); + if (fname__set == FALSE) + gpiv_error("Software: %s version: %s: File basename has to be set", + argv[0], GPIVTOOLS_VERSION); #endif gpiv_io_make_fname(fname_base, GPIV_EXT_HEADER, fname_header); @@ -224,7 +229,8 @@ make_fname_out (gchar *fname_base, void -make_fname_in (GpivGenPar *gen_par, +make_fname_in (char *argv[], + GpivGenPar *gen_par, gchar *fname_base, int f_number, gchar *fname_in @@ -235,9 +241,13 @@ make_fname_in (GpivGenPar *gen_par, { char f_dum[GPIV_MAX_CHARS]; #ifdef GIT_HASH - if (fname__set == FALSE) gpiv_error("%s: File basename has to be set", GIT_REV); + if (fname__set == FALSE) + gpiv_error("Software: %s git hash: %s: File basename has to be set", + argv[0], GIT_REV); #else - if (fname__set == FALSE) gpiv_error("%s: File basename has to be set", GPIVTOOLS_VERSION); + if (fname__set == FALSE) + gpiv_error("Software: %s version: %s: File basename has to be set", + argv[0], GPIVTOOLS_VERSION); #endif if (gen_par->file_prefix) { @@ -256,7 +266,8 @@ make_fname_in (GpivGenPar *gen_par, GpivImage * -imgproc_mean (GpivGenPar *gen_par, +imgproc_mean (char *argv[], + GpivGenPar *gen_par, GpivImageProcPar *image_proc_par, gchar *fname_base ) @@ -275,7 +286,7 @@ imgproc_mean (GpivGenPar *gen_par, if (verbose) printf ("# Calculating mean from input data\n"); for (j = first_file; j <= last_file; j++) { - make_fname_in (gen_par, fname_base, j, fname_in); + make_fname_in (argv, gen_par, fname_base, j, fname_in); if ((image_in = gpiv_fread_image (fname_in)) == NULL) { gpiv_error ("local_image_mean: failing gpiv_fread_image %s", fname_in); @@ -349,7 +360,8 @@ imgproc_mean (GpivGenPar *gen_par, static gchar * -imgproc_subtract (GpivGenPar *gen_par, +imgproc_subtract (char *argv[], + GpivGenPar *gen_par, gchar *fname_base, GpivImage *image_subtr ) @@ -379,7 +391,7 @@ imgproc_subtract (GpivGenPar *gen_par, for (j = first_file; j <= last_file; j++) { if (fname__set == TRUE) { - make_fname_in (gen_par, fname_base, j, fname_in); + make_fname_in (argv, gen_par, fname_base, j, fname_in); if ((image_in = gpiv_fread_image (fname_in)) == NULL) { err_msg = "imgproc_subtract: failing gpiv_fread_image"; return (err_msg); @@ -450,9 +462,11 @@ main (int argc, command_args (argc, argv, fname_base, gen_par, image_proc_par); if (verbose) { #ifdef GIT_HASH - printf ("# %s\n# Command line options:\n", GIT_REV); + printf ("# Software: %s\n# git hash: %s\n# Command line options:\n", + argv[0], GIT_REV); #else - printf ("# %s\n# Command line options:\n", GPIVTOOLS_VERSION); + printf ("# Software: %s\n# version: %s\n# Command line options:\n", + argv[0], GPIVTOOLS_VERSION); #endif gpiv_genpar_print_parameters (stdout, gen_par); gpiv_imgproc_print_parameters (stdout, image_proc_par); @@ -463,7 +477,7 @@ main (int argc, /* * Generating proper filenames */ - make_fname_out (fname_base, fname_header, fname_parameter, fname_out); + make_fname_out (argv, fname_base, fname_header, fname_parameter, fname_out); if (verbose) printf ("\n# Parameters written to: %s", fname_parameter); @@ -495,9 +509,11 @@ main (int argc, } else { #ifdef GIT_HASH - gpiv_error("%s: File basename has to be set", GIT_REV); + gpiv_error("Software: %s git hash: %s: File basename has to be set", + argv[0], GIT_REV); #else - gpiv_error("%s: File basename has to be set", GPIVTOOLS_VERSION); + gpiv_error("Software: %s version: %s: File basename has to be set", + argv[0], GPIVTOOLS_VERSION); #endif } @@ -511,13 +527,13 @@ main (int argc, /* * Here the function calls of imgproc_mean and imgproc_subtract */ - if ((image_mean = imgproc_mean (gen_par, image_proc_par, fname_base)) + if ((image_mean = imgproc_mean (argv, gen_par, image_proc_par, fname_base)) == NULL) { gpiv_error ("%s: failing img_mean", argv[0]); } if (image_proc_par->smooth_operator == GPIV_IMGOP_SUBTRACT) - imgproc_subtract (gen_par, fname_base, image_mean); + imgproc_subtract (argv, gen_par, fname_base, image_mean); /* @@ -531,9 +547,11 @@ main (int argc, fclose (fp); } else { #ifdef GIT_HASH - gpiv_error("%s: File basename has to be set", GIT_REV); + gpiv_error("Software: %s git hash: %s: File basename has to be set", + argv[0], GIT_REV); #else - gpiv_error("%s: File basename has to be set", GPIVTOOLS_VERSION); + gpiv_error("Software: %s version: %s: File basename has to be set", + argv[0], GPIVTOOLS_VERSION); #endif } diff --git a/src/misc/hdf2piv.c b/src/misc/hdf2piv.c index 8f7dad9..20ed167 100644 --- a/src/misc/hdf2piv.c +++ b/src/misc/hdf2piv.c @@ -41,7 +41,7 @@ keys: \n\ -h | --help: this on-line help \n\ -p | --print: print parameters to stdout \n\ -v | --version: version number \n\ --V | --verbose: version number \n\ +-V | --verbose: verbose behaviour \n\ filename: input file, hdf formatted (including .hdf extension) \n\ " diff --git a/src/misc/suta.c b/src/misc/suta.c index c7474d9..0d2ba38 100644 --- a/src/misc/suta.c +++ b/src/misc/suta.c @@ -1,5 +1,3 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 c-style: "K&R" -*- */ - /*----------------------------------------------------------------------------- suta - subtracts time-avaraged velocities (local mean velocities) from diff --git a/src/post/aint.c b/src/post/aint.c index bc9780c..8c86978 100644 --- a/src/post/aint.c +++ b/src/post/aint.c @@ -680,9 +680,11 @@ main (int argc, argv[0], fname_par); } #ifdef GIT_HASH - fprintf (fp_par, "\n\n# %s\n# Command line options:\n", GIT_REV); + fprintf (fp_par, "\n\n# Software: %s\n# git hash: %s\n# Command line options:\n", + argv[0], GIT_REV); #else - fprintf (fp_par, "\n\n# %s\n# Command line options:\n", GPIVTOOLS_VERSION); + fprintf (fp_par, "\n\n# Software: %s\n# version: %s\n# Command line options:\n", + argv[0], GPIVTOOLS_VERSION); #endif /* diff --git a/src/post/manipiv.c b/src/post/manipiv.c index a70b104..3a7b85f 100644 --- a/src/post/manipiv.c +++ b/src/post/manipiv.c @@ -380,9 +380,11 @@ main(int argc, command_args(argc, argv, fname_in_piv, piv_post_par); if (verbose) { #ifdef GIT_HASH - printf("# %s\n# Command line options:\n", GIT_REV); + printf("# Software: %s\n# git hash: %s\n# Command line options:\n", + argv[0], GIT_REV); #else - printf("# %s\n# Command line options:\n", GPIVTOOLS_VERSION); + printf("# Software: %s\n# version: %s\n# Command line options:\n", + argv[0], GPIVTOOLS_VERSION); #endif gpiv_post_print_parameters (NULL, piv_post_par); } @@ -469,9 +471,11 @@ main(int argc, */ g_free (piv_data->comment); #ifdef GIT_HASH - piv_data->comment = g_strdup_printf ("# Software: %s\n", GIT_REV); + piv_data->comment = g_strdup_printf ("# Software: %s\n# git hash: %s\n", + argv[0], GIT_REV); #else - piv_data->comment = g_strdup_printf ("# Software: %s\n", GPIVTOOLS_VERSION); + piv_data->comment = g_strdup_printf ("# Software: %s\n# version: %s\n", + argv[0], GPIVTOOLS_VERSION); #endif piv_data->comment = gpiv_add_datetime_to_comment (piv_data->comment); diff --git a/src/post/s-avg.c b/src/post/s-avg.c index 76e2744..8647522 100644 --- a/src/post/s-avg.c +++ b/src/post/s-avg.c @@ -280,9 +280,11 @@ main (int argc, command_args (argc, argv, fname_in, piv_post_par); if (verbose) { #ifdef GIT_HASH - printf ("# %s\n# Command line options:\n", GIT_REV); + printf ("# Software: %s\n# git hash: %s\n# Command line options:\n", + argv[0], GIT_REV); #else - printf ("# %s\n# Command line options:\n", GPIVTOOLS_VERSION); + printf ("# Software: %s\n# version: %s\n# Command line options:\n", + argv[0], GPIVTOOLS_VERSION); #endif gpiv_post_print_parameters (NULL, piv_post_par); } @@ -357,9 +359,11 @@ main (int argc, */ g_free (piv_data->comment); #ifdef GIT_HASH - piv_data->comment = g_strdup_printf ("# Software: %s\n", GIT_REV); + piv_data->comment = g_strdup_printf ("# Software: %s\n# git hash: %s\n", + argv[0], GIT_REV); #else - piv_data->comment = g_strdup_printf ("# Software: %s\n", GPIVTOOLS_VERSION); + piv_data->comment = g_strdup_printf ("# Software: %s\n# version: %s\n", + argv[0], GPIVTOOLS_VERSION); #endif piv_data->comment = gpiv_add_datetime_to_comment (piv_data->comment); @@ -382,9 +386,11 @@ main (int argc, } else { if (use_stdin_stdout == TRUE) { #ifdef GIT_HASH - printf ("# Software: %s\n", GIT_REV); + printf ("# Software: %s\n# git hash: %s\n", + argv[0], GIT_REV); #else - printf ("# Software: %s\n", GPIVTOOLS_VERSION); + printf ("# Software: %s\n# version: %s\n", + argv[0], GPIVTOOLS_VERSION); #endif printf ("# %s\n", gpiv_add_datetime_to_comment (NULL)); printf ("# ndata = %d\n", piv_data->count); @@ -406,9 +412,11 @@ main (int argc, } #ifdef GIT_HASH - fprintf (fp, "# Software: %s\n", GIT_REV); + fprintf (fp, "# Software: %s\n# git hash: %s\n", + argv[0], GIT_REV); #else - fprintf (fp, "# Software: %s\n", GPIVTOOLS_VERSION); + fprintf (fp, "# Software: %s\n# version: %s\n", + argv[0], GPIVTOOLS_VERSION); #endif fprintf (fp, "# %s\n", gpiv_add_datetime_to_comment (NULL)); fprintf (fp, "# ndata = %d\n", piv_data->count); diff --git a/src/post/scale.c b/src/post/scale.c index 92c4dce..ccadd74 100644 --- a/src/post/scale.c +++ b/src/post/scale.c @@ -305,9 +305,11 @@ main (int argc, command_args(argc, argv, fname_in, image_par, post_par); if (verbose) { #ifdef GIT_HASH - printf("# %s\n# Command line options:\n", GIT_REV); + printf("# Software: %s\n# git hash: %s\n# Command line options:\n", + argv[0], GIT_REV); #else - printf("# %s\n# Command line options:\n", GPIVTOOLS_VERSION); + printf("# Software: %s\n# version: %s\n# Command line options:\n", + argv[0], GPIVTOOLS_VERSION); #endif gpiv_img_print_parameters (NULL, image_par); gpiv_post_print_parameters (NULL, post_par); @@ -408,9 +410,11 @@ main (int argc, */ g_free (piv_data->comment); #ifdef GIT_HASH - piv_data->comment = g_strdup_printf ("# Software: %s\n", GIT_REV); + piv_data->comment = g_strdup_printf ("# Software: %s\n# git hash: %s\n", + argv[0], GIT_REV); #else - piv_data->comment = g_strdup_printf ("# Software: %s\n", GPIVTOOLS_VERSION); + piv_data->comment = g_strdup_printf ("# Software: %s\n# version: %s\n", + argv[0], GPIVTOOLS_VERSION); #endif piv_data->comment = gpiv_add_datetime_to_comment (piv_data->comment); diff --git a/src/post/vorstra.c b/src/post/vorstra.c index 3bb8121..37fd103 100644 --- a/src/post/vorstra.c +++ b/src/post/vorstra.c @@ -250,7 +250,8 @@ command_args(int argc, static gchar * -make_fname(char *fname_in, +make_fname(char *argv[], + char *fname_in, char *fname_parameter, char *fname_out, GpivPostPar *piv_post_par @@ -288,9 +289,11 @@ make_fname(char *fname_in, gpiv_io_make_fname (fname_base, GPIV_EXT_NSTR, fname_out); } else { #ifdef GIT_HASH - gpiv_error("%s: non valid operation", GIT_REV); + gpiv_error("Software: %s\n# git hash: %s: non valid operation", + argv[0], GIT_REV); #else - gpiv_error("%s: non valid operation", GPIVTOOLS_VERSION); + gpiv_error("Software: %s\n# version: %s: non valid operation", + argv[0], GPIVTOOLS_VERSION); #endif } if (verbose) @@ -351,16 +354,18 @@ main(int argc, command_args (argc, argv, fname_in, piv_post_par); if (verbose) { #ifdef GIT_HASH - printf("# %s\n# Command line options:\n", GIT_REV); + printf("# Software: %s\n# git hash: %s\n# Command line options:\n", + argv[0], GIT_REV); #else - printf("# %s\n# Command line options:\n", GPIVTOOLS_VERSION); + printf("# Software: %s\n# version: %s\n# Command line options:\n", + argv[0], GPIVTOOLS_VERSION); #endif gpiv_post_print_parameters (NULL, piv_post_par); } if (use_stdin_stdout == FALSE) { - make_fname(fname_in, fname_parameter, fname_out, piv_post_par); + make_fname(argv, fname_in, fname_parameter, fname_out, piv_post_par); /* * Prints command line parameters to par-file @@ -448,9 +453,11 @@ main(int argc, */ g_free (out_data->comment); #ifdef GIT_HASH - out_data->comment = g_strdup_printf ("# Software: %s\n", GIT_REV); + out_data->comment = g_strdup_printf ("# Software: %s\n# git hash: %s\n", + argv[0], GIT_REV); #else - out_data->comment = g_strdup_printf ("# Software: %s\n", GPIVTOOLS_VERSION); + out_data->comment = g_strdup_printf ("# Software: %s\n# version: %s\n", + argv[0], GPIVTOOLS_VERSION); #endif out_data->comment = gpiv_add_datetime_to_comment (out_data->comment); if (piv_post_par->operator_vorstra == GPIV_VORTICITY) { diff --git a/src/validate/errvec.c b/src/validate/errvec.c index d74c0d8..2a69559 100644 --- a/src/validate/errvec.c +++ b/src/validate/errvec.c @@ -359,6 +359,7 @@ main (int argc, GpivBinData *klass = NULL; GpivLinRegData *linreg = g_new0 (GpivLinRegData, 1); + GpivFt *ft = NULL; gpiv_valid_parameters_set (valid_par, FALSE); @@ -376,9 +377,11 @@ main (int argc, command_args (argc, argv, fname_in_piv, valid_par); if (verbose) { #ifdef GIT_HASH - printf ("# %s\n# Command line options:\n", GIT_REV); + printf ("\n# %s git hash: %s\n# Command line options:\n", + argv[0], GIT_REV); #else - printf ("# %s\n# Command line options:\n", GPIVTOOLS_VERSION); + printf ("\n# %s version: %s\n# Command line options:\n", + argv[0], GPIVTOOLS_VERSION); #endif gpiv_valid_print_parameters (NULL, valid_par); } @@ -537,9 +540,28 @@ main (int argc, * Validating PIV data on outliers and substituting * or calculating residu histogram */ - if ((err_msg = - gpiv_valid_errvec (in_data, image, piv_par, valid_par, FALSE)) - != NULL) gpiv_error ("%s: %s", argv[0], err_msg); + + if ((err_msg = + ft = gpiv_alloc_ft (GPIV_ZEROPAD_FACT * piv_par->int_size_i)) + == NULL) gpiv_error ("%s: %s", argv[0], err_msg); + + ft->plan_forwardFFT = + fftw_plan_dft_r2c_2d (ft->size, ft->size, (double *) &ft->re[0][0], + (fftw_complex *) &ft->co[0][0], + FFTW_MEASURE); + ft->plan_reverseFFT = + fftw_plan_dft_c2r_2d (ft->size, ft->size, (fftw_complex *) &ft->co[0][0], + (double *)&ft->re[0][0], + FFTW_MEASURE); + + if ((err_msg = + gpiv_valid_errvec (in_data, image, piv_par, valid_par, ft, FALSE)) + != NULL) gpiv_error ("%s: %s", argv[0], err_msg); + + + fftw_destroy_plan(ft->plan_forwardFFT); + fftw_destroy_plan(ft->plan_reverseFFT); + gpiv_free_ft (ft); } out_data = gpiv_cp_pivdata (in_data); /* @@ -548,9 +570,11 @@ main (int argc, */ if (res_stats == FALSE) { #ifdef GIT_HASH - out_data->comment = g_strdup_printf ("# Software: %s\n", GIT_REV); + out_data->comment = g_strdup_printf ("# Software: %s\n# git hash: %s\n# Command line options:\n", + argv[0], GIT_REV); #else - out_data->comment = g_strdup_printf ("# Software: %s\n", GPIVTOOLS_VERSION); + out_data->comment = g_strdup_printf ("# Software: %s\n# version: %s\n# Command line options:\n", + argv[0], GPIVTOOLS_VERSION); #endif out_data->comment = gpiv_add_datetime_to_comment (out_data->comment); @@ -588,9 +612,11 @@ main (int argc, } #ifdef GIT_HASH - klass->comment = g_strdup_printf ("# Software: %s\n", GIT_REV); + klass->comment = g_strdup_printf ("# Software: %s\n# git hash: %s\n", + argv[0], GIT_REV); #else - klass->comment = g_strdup_printf ("# Software: %s\n", GPIVTOOLS_VERSION); + klass->comment = g_strdup_printf ("# Software: %s\n# version: %s\n", + argv[0], GPIVTOOLS_VERSION); #endif klass->comment = gpiv_add_datetime_to_comment (out_data->comment); klass->comment = g_strconcat (klass->comment, diff --git a/src/validate/peaklck.c b/src/validate/peaklck.c index 4928c99..36a9314 100644 --- a/src/validate/peaklck.c +++ b/src/validate/peaklck.c @@ -283,9 +283,11 @@ int main (int argc, char *argv[]) argv[0], fname_parameter); } #ifdef GIT_HASH - fprintf (fp_par_dat, "\n\n# %s\n# Command line options:\n", GIT_REV); + fprintf (fp_par_dat, "\n\n# Software: %s\n# git hash: %s\n# Command line options:\n", + argv[0], GIT_REV); #else - fprintf (fp_par_dat, "\n\n# %s\n# Command line options:\n", GPIVTOOLS_VERSION); + fprintf (fp_par_dat, "\n\n# Software: %s\n# version: %s\n# Command line options:\n", + argv[0], GPIVTOOLS_VERSION); #endif gpiv_valid_print_parameters (fp_par_dat, valid_par); fclose (fp_par_dat); -- 2.11.4.GIT