From 826ec5491c8810b9a3748cd8f8ed0709b14a7cc3 Mon Sep 17 00:00:00 2001 From: Andreas Adelmann Date: Fri, 12 Aug 2011 08:48:43 +0000 Subject: [PATCH] rewriting for H5hut --- tools/H5PartMerge/configure | 156 +++++++++--------------------- tools/H5PartMerge/configure.ac | 10 +- tools/H5PartMerge/src/H5merge.cpp | 73 +++++++------- 3 files changed, 94 insertions(+), 145 deletions(-) diff --git a/tools/H5PartMerge/configure b/tools/H5PartMerge/configure index 2c1760e..b5ec8c7 100755 --- a/tools/H5PartMerge/configure +++ b/tools/H5PartMerge/configure @@ -605,9 +605,9 @@ ac_includes_default="\ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS +LIBOBJS AM_LDFLAGS AM_CPPFLAGS -LIBOBJS CXXCPP EGREP GREP @@ -1947,48 +1947,6 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_type - -# ac_fn_cxx_try_run LINENO -# ------------------------ -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_cxx_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_run cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -4828,6 +4786,50 @@ else fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lH5hutC" >&5 +$as_echo_n "checking for main in -lH5hutC... " >&6; } +if ${ac_cv_lib_H5hutC_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lH5hutC $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_H5hutC_main=yes +else + ac_cv_lib_H5hutC_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_H5hutC_main" >&5 +$as_echo "$ac_cv_lib_H5hutC_main" >&6; } +if test "x$ac_cv_lib_H5hutC_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBH5HUTC 1 +_ACEOF + + LIBS="-lH5hutC $LIBS" + +else + as_fn_error $? "H5hut library not found!" "$LINENO" 5 + +fi + + + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -5211,73 +5213,7 @@ fi # Checks for library functions. -for ac_header in stdlib.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" -if test "x$ac_cv_header_stdlib_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STDLIB_H 1 -_ACEOF - -fi - -done - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 -$as_echo_n "checking for GNU libc compatible malloc... " >&6; } -if ${ac_cv_func_malloc_0_nonnull+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_malloc_0_nonnull=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include -#else -char *malloc (); -#endif - -int -main () -{ -return ! malloc (0); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_run "$LINENO"; then : - ac_cv_func_malloc_0_nonnull=yes -else - ac_cv_func_malloc_0_nonnull=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 -$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } -if test $ac_cv_func_malloc_0_nonnull = yes; then : - -$as_echo "#define HAVE_MALLOC 1" >>confdefs.h - -else - $as_echo "#define HAVE_MALLOC 0" >>confdefs.h - - case " $LIBOBJS " in - *" malloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS malloc.$ac_objext" - ;; -esac - - -$as_echo "#define malloc rpl_malloc" >>confdefs.h - -fi - - +#AC_FUNC_MALLOC CPPFLAGS=$CPPFLAGS" -m64 -mtune=k8" LDFLAGS=$LDFLAGS" -lm" diff --git a/tools/H5PartMerge/configure.ac b/tools/H5PartMerge/configure.ac index 5683b6a..fdb9d78 100644 --- a/tools/H5PartMerge/configure.ac +++ b/tools/H5PartMerge/configure.ac @@ -95,6 +95,14 @@ AC_LANG_PUSH(C) [], [AC_MSG_ERROR(H5hut library not found!)] ) + AC_CHECK_LIB( + [H5hutC], + [main], + [], + [AC_MSG_ERROR(H5hut library not found!)] + ) + + AC_LANG_POP AC_LANG(C++) @@ -139,7 +147,7 @@ AC_C_CONST AC_TYPE_SIZE_T # Checks for library functions. -AC_FUNC_MALLOC +#AC_FUNC_MALLOC CPPFLAGS=$CPPFLAGS" -m64 -mtune=k8" LDFLAGS=$LDFLAGS" -lm" diff --git a/tools/H5PartMerge/src/H5merge.cpp b/tools/H5PartMerge/src/H5merge.cpp index 571205a..5326073 100644 --- a/tools/H5PartMerge/src/H5merge.cpp +++ b/tools/H5PartMerge/src/H5merge.cpp @@ -20,6 +20,7 @@ * * \todo H5hut port */ + #include #include "H5hut.h" @@ -32,6 +33,8 @@ #include "optparse.hh" +#include + #ifdef USE_BOOST #include #endif @@ -61,17 +64,17 @@ typedef map StringAnyValueMap; typedef map StringIntMap; typedef map StringInt64Map; -h5_int64_t copyFileAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5_int64_t Type, h5_int64_t Num); -h5_int64_t copyFileToStepAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5_int64_t Type, h5_int64_t Num); +h5_int64_t copyFileAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5_int64_t Type, h5_size_t Num); +h5_int64_t copyFileToStepAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5_int64_t Type, h5_size_t Num); #ifdef USE_BOOST h5_int64_t copyFileAttribute(h5_file_t* In, h5_file_t* Out, StringAnyValueMap &FileAttributes, string AttrName, - h5_int64_t Type, h5_int64_t Num); + h5_int64_t Type, h5_size_t Num); h5_int64_t copyFileToStepAttribute(h5_file_t* In, h5_file_t* Out, StringAnyValueMap &FileAttributes, string AttrName, - h5_int64_t Type, h5_int64_t Num); + h5_int64_t Type, h5_size_t Num); #endif -h5_int64_t copyStepAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5_int64_t Type, h5_int64_t Num); +h5_int64_t copyStepAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5_int64_t Type, h5_size_t Num); h5_int64_t copyDataset(h5_file_t* In, h5_file_t* Out, string SetName, h5_int64_t Type, h5_float64_t* FloatArray, h5_int64_t* IntArray); @@ -127,6 +130,7 @@ int main(int argc, char **argv){ StringIntMap::iterator itName; StringInt64Map::iterator itType; StringInt64Map::iterator itNumType; + h5_int64_t NumParticles = 0; h5_int64_t maxNumParticles = 0; @@ -140,8 +144,9 @@ int main(int argc, char **argv){ h5_int64_t Type; h5_int64_t SetType; - h5_int64_t NumType; - h5_int64_t SetNum; + h5_size_t NumType; + + h5_size_t SetNum; int verbosity = 0; h5_int64_t rc; @@ -308,7 +313,7 @@ int main(int argc, char **argv){ for (int i = 0; i < effNumInput; ++i) { - H5InFile = H5OpenFile(InputFilenames[i].c_str(), H5_O_RDONLY, NULL); + H5InFile = H5OpenFile(InputFilenames[i].c_str(), H5_O_RDONLY, 0); /**************************************************************\ * fix range if values are negative @@ -409,7 +414,7 @@ int main(int argc, char **argv){ for (int k = from[i]; k <= to[i]; ++k) { - H5PartSetStep(H5InFile,k); + H5SetStep(H5InFile,k); if (parser.get("intersect-datasets")) { @@ -647,7 +652,7 @@ int main(int argc, char **argv){ } - H5OutFile = H5OpenFile(OutputFilename.c_str(), H5_O_WRONLY, NULL); + H5OutFile = H5OpenFile(OutputFilename.c_str(), H5_O_WRONLY, 0); if (H5OutFile == NULL) { cerr << "ABORT: could not open '" << OutputFilename << "' for writing!" << endl; @@ -659,7 +664,7 @@ int main(int argc, char **argv){ for (int i = 0; i < effNumInput; ++i) { - H5InFile = H5OpenFile(InputFilenames[i].c_str(), H5_O_RDONLY, NULL ); + H5InFile = H5OpenFile(InputFilenames[i].c_str(), H5_O_RDONLY, 0); H5SetStep(H5InFile,from[i]); H5SetStep(H5OutFile,effStep); @@ -695,7 +700,7 @@ int main(int argc, char **argv){ h5_int64_t NumFileAttr = H5GetNumFileAttribs(H5InFile); for (h5_int64_t l = 0; l < NumFileAttr; ++l) { - H5PartGetFileAttribInfo(H5InFile, l, AttrName, MAX_LEN, &Type, &NumType); + H5GetFileAttribInfo(H5InFile, l, AttrName, MAX_LEN, &Type, &NumType); if (i == 0) { #ifdef USE_BOOST @@ -770,7 +775,7 @@ int main(int argc, char **argv){ h5_int64_t NumStepAttr = H5GetNumStepAttribs(H5InFile); for (h5_int64_t m = 0; m < NumStepAttr; ++m) { - H5PartGetStepAttribInfo(H5InFile, m, StepAttrName, MAX_LEN, &Type, &NumType); + H5GetStepAttribInfo(H5InFile, m, StepAttrName, MAX_LEN, &Type, &NumType); rc = copyStepAttribute(H5InFile, H5OutFile, string(StepAttrName), Type, NumType); if (rc != H5_SUCCESS) cerr << "WARNING: could not write step attribute '" << StepAttrName << "'" << endl; @@ -816,33 +821,33 @@ int main(int argc, char **argv){ delete[] to; } -h5_int64_t copyFileAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5_int64_t Type, h5_int64_t Num) +h5_int64_t copyFileAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5_int64_t Type, h5_size_t Num) { h5_int64_t rc; if (Type == H5T_NATIVE_DOUBLE) { void *Attrib = (double*)malloc(sizeof(double)*Num); - rc = H5PartReadFileAttrib(In, AttrName.c_str(), (double*)Attrib); + rc = H5ReadFileAttribFloat64(In, AttrName.c_str(), (double*)Attrib); if (rc == H5_SUCCESS) - rc = H5PartWriteFileAttrib(Out, AttrName.c_str(), Type, (double*)Attrib, Num); + rc = H5WriteFileAttribFloat64(Out, AttrName.c_str(), (double*)Attrib, Num); free(Attrib); return rc; } else if (Type == H5T_NATIVE_CHAR) { void *Attrib = (char*)malloc(sizeof(char)*Num); - rc = H5ReadFileAttrib(In, AttrName.c_str(), (char*)Attrib); + rc = H5ReadFileAttribString(In, AttrName.c_str(), (char*)Attrib); if (rc == H5_SUCCESS) - rc = H5WriteFileAttrib(Out, AttrName.c_str(), Type, (char*)Attrib, Num); + rc = H5WriteFileAttribString(Out, AttrName.c_str(), (char*)Attrib); free(Attrib); return rc; } else if (Type == H5T_NATIVE_INT64) { void *Attrib = (h5_int64_t*)malloc(sizeof(h5_int64_t)*Num); - rc = H5PartReadFileAttrib(In, AttrName.c_str(), (h5_int64_t*)Attrib); + rc = H5ReadFileAttribInt64(In, AttrName.c_str(), (h5_int64_t*)Attrib); if (rc == H5_SUCCESS) - rc = H5PartWriteFileAttrib(Out, AttrName.c_str(), Type, (h5_int64_t*)Attrib, Num); + rc = H5WriteFileAttribInt64(Out, AttrName.c_str(), (h5_int64_t*)Attrib, Num); free(Attrib); return rc; } @@ -854,33 +859,33 @@ h5_int64_t copyFileAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5 } -h5_int64_t copyFileToStepAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5_int64_t Type, h5_int64_t Num) +h5_int64_t copyFileToStepAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5_int64_t Type, h5_size_t Num) { h5_int64_t rc; if (Type == H5T_NATIVE_DOUBLE) { void *Attrib = (double*)malloc(sizeof(double)*Num); - rc = H5PartReadFileAttrib(In, AttrName.c_str(), (double*)Attrib); + rc = H5ReadFileAttribFloat64(In, AttrName.c_str(), (double*)Attrib); if (rc == H5_SUCCESS) - rc = H5PartWriteStepAttrib(Out, AttrName.c_str(), Type, (double*)Attrib, Num); + rc = H5WriteStepAttribFloat64(Out, AttrName.c_str(), (double*)Attrib, Num); free(Attrib); return rc; } else if (Type == H5T_NATIVE_CHAR) { void *Attrib = (char*)malloc(sizeof(char)*Num); - rc = H5PartReadFileAttrib(In, AttrName.c_str(), (char*)Attrib); + rc = H5ReadFileAttribString(In, AttrName.c_str(), (char*)Attrib); if (rc == H5_SUCCESS) - rc = H5PartWriteStepAttrib(Out, AttrName.c_str(), Type, (char*)Attrib, Num); + rc = H5WriteStepAttribString(Out, AttrName.c_str(), (char*)Attrib); free(Attrib); return rc; } else if (Type == H5T_NATIVE_INT64) { void *Attrib = (h5_int64_t*)malloc(sizeof(h5_int64_t)*Num); - rc = H5PartReadFileAttrib(In, AttrName.c_str(), (h5_int64_t*)Attrib); + rc = H5ReadFileAttribInt64(In, AttrName.c_str(), (h5_int64_t*)Attrib); if (rc == H5_SUCCESS) - rc = H5PartWriteStepAttrib(Out, AttrName.c_str(), Type, (h5_int64_t*)Attrib, Num); + rc = H5WriteStepAttribInt64(Out, AttrName.c_str(), (h5_int64_t*)Attrib, Num); free(Attrib); return rc; } @@ -891,33 +896,33 @@ h5_int64_t copyFileToStepAttribute(h5_file_t* In, h5_file_t* Out, string AttrNam } } -h5_int64_t copyStepAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5_int64_t Type, h5_int64_t Num) +h5_int64_t copyStepAttribute(h5_file_t* In, h5_file_t* Out, string AttrName, h5_int64_t Type, h5_size_t Num) { h5_int64_t rc; if (Type == H5T_NATIVE_DOUBLE) { void* Attrib = (double*)malloc(sizeof(double)*Num);; - rc = H5PartReadStepAttrib(In, AttrName.c_str(), (double*)Attrib); + rc = H5ReadStepAttribFloat64(In, AttrName.c_str(), (double*)Attrib); if (rc == H5_SUCCESS) - rc = H5PartWriteStepAttrib(Out, AttrName.c_str(), Type, (double*)Attrib, Num); + rc = H5WriteStepAttribFloat64(Out, AttrName.c_str(), (double*)Attrib, Num); free(Attrib); return rc; } else if (Type == H5T_NATIVE_CHAR) { void* Attrib = (char*)malloc(sizeof(char)*Num);; - rc = H5PartReadStepAttrib(In, AttrName.c_str(), (char*)Attrib); + rc = H5ReadStepAttribString(In, AttrName.c_str(), (char*)Attrib); if (rc == H5_SUCCESS) - rc = H5PartWriteStepAttrib(Out, AttrName.c_str(), Type, (char*)Attrib, Num); + rc = H5WriteStepAttribString(Out, AttrName.c_str(), (char*)Attrib); free(Attrib); return rc; } else if (Type == H5T_NATIVE_INT64) { void* Attrib = (h5_int64_t*)malloc(sizeof(h5_int64_t)*Num); - rc = H5PartReadStepAttrib(In, AttrName.c_str(), (h5_int64_t*)Attrib); + rc = H5ReadStepAttribInt64(In, AttrName.c_str(), (h5_int64_t*)Attrib); if (rc == H5_SUCCESS) - rc = H5PartWriteStepAttrib(Out, AttrName.c_str(), Type, (h5_int64_t*)Attrib, Num); + rc = H5WriteStepAttribInt64(Out, AttrName.c_str(), (h5_int64_t*)Attrib, Num); free(Attrib); return rc; }