diff --git a/.github/workflows/cmake_release.yml b/.github/workflows/cmake_release.yml index ab95656f..37524dd0 100644 --- a/.github/workflows/cmake_release.yml +++ b/.github/workflows/cmake_release.yml @@ -49,9 +49,7 @@ jobs: # Build and test using shell script - name: Build run: | - cd .. - cp ./DynAdjust/resources/make_dynadjust_gcc.sh ./ - chmod +x ./make_dynadjust_gcc.sh - ./make_dynadjust_gcc.sh --no-install --auto --do-not-clone + chmod +x ./resources/make_dynadjust_gcc.sh + ./resources/make_dynadjust_gcc.sh --no-install --auto --do-not-clone diff --git a/.github/workflows/test_coverage.yml b/.github/workflows/test_coverage.yml index e3000fcd..eb8abd69 100644 --- a/.github/workflows/test_coverage.yml +++ b/.github/workflows/test_coverage.yml @@ -50,10 +50,8 @@ jobs: # Build and test using shell script - name: Build and test run: | - cd .. - cp ./DynAdjust/resources/make_dynadjust_gcc.sh ./ - chmod +x ./make_dynadjust_gcc.sh - ./make_dynadjust_gcc.sh --no-install --auto --do-not-clone --test + chmod +x ./resources/make_dynadjust_gcc.sh + ./resources/make_dynadjust_gcc.sh --no-install --auto --do-not-clone --test # Submit to coveralls - name: Submit coverage to Coveralls diff --git a/.travis.yml b/.travis.yml index 6c378469..38a66a35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,17 +22,13 @@ before_install: - sudo sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list' - sudo apt-get update - sudo apt-get install -y intel-mkl-64bit-2018.3-051 -# - bash resources/install_dynadjust_prerequisites.sh -m 1 script: - - cd .. - - cp ./DynAdjust/resources/make_dynadjust_gcc.sh ./ - - bash make_dynadjust_gcc.sh --no-install --auto --do-not-clone --test + - chmod +x ./resources/make_dynadjust_gcc.sh + - ./resources/make_dynadjust_gcc.sh --no-install --auto --no-clone --test after_success: - - cd ./DynAdjust/dynadjust/ -# - coveralls --root . -E ".*CMakeFiles.*" -# - coveralls --root . --verbose --exclude-pattern ".*feature_tests.*" --exclude-pattern ".*CompilerId.*" --gcov-options '\-lp' + - cd ./dynadjust/ - coveralls --gcov /usr/bin/gcov --exclude-pattern ".*feature_tests.*" diff --git a/Dockerfile b/Dockerfile index 0807e75d..619f830b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,6 +21,7 @@ RUN apt-get update &&\ apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \ sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list' && \ apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install cpio intel-mkl-64bit-2018.3-051 &&\ - chmod +x ./DynAdjust/resources/make_dynadjust_gcc.sh &&\ - ./DynAdjust/resources/make_dynadjust_gcc.sh + cd ./DynAdjust + chmod +x ./resources/make_dynadjust_gcc.sh &&\ + ./resources/make_dynadjust_gcc.sh diff --git a/dynadjust/dynadjust/dnaimport/dnaparser_pimpl.cxx b/dynadjust/dynadjust/dnaimport/dnaparser_pimpl.cxx index 3650aab2..f5254361 100644 --- a/dynadjust/dynadjust/dnaimport/dnaparser_pimpl.cxx +++ b/dynadjust/dynadjust/dnaimport/dnaparser_pimpl.cxx @@ -1137,7 +1137,7 @@ void StationCoord_pimpl::pre() void StationCoord_pimpl::Name(const ::std::string& Name) { - _parent_dnaStn->SetName(Name); + //_parent_dnaStn->SetName(Name); } void StationCoord_pimpl::XAxis(const ::std::string& XAxis) diff --git a/dynadjust/include/io/dnaiosnxread.cpp b/dynadjust/include/io/dnaiosnxread.cpp index 10ee6fd7..618819be 100644 --- a/dynadjust/include/io/dnaiosnxread.cpp +++ b/dynadjust/include/io/dnaiosnxread.cpp @@ -405,24 +405,14 @@ void dna_io_snx::format_station_names(v_discontinuity_tuple* stn_discontinuities year = _it_discont_site->date_start.year(); ss << siteOccurrence_.at(site).site_name << "_"; - if (year == DISCONT_TIME_IMMEMORIAL) - { - // format using the start epoch - // year (4 chars) - ss << siteOccurrence_.at(site).formatted_date.substr(4, 4); - // doy (3 chars) - ss << siteOccurrence_.at(site).formatted_date.substr(0, 3); - } - else - { - // format using the discontinuity date - ss << year; - if (doy < 100) - ss << "0"; - if (doy < 10) - ss << "0"; - ss << doy; - } + // format date using the start of the window defining the + // period up to which a discontinuity has been identified + ss << year; + if (doy < 100) + ss << "0"; + if (doy < 10) + ss << "0"; + ss << doy; siteOccurrence_.at(site).formatted_name = ss.str(); //TRACE("Site %s\n", siteOccurrence_.at(site).formatted_name.c_str()); diff --git a/resources/install_dynadjust_prerequisites.sh b/resources/install_dynadjust_prerequisites.sh index 98538d18..077de5a8 100755 --- a/resources/install_dynadjust_prerequisites.sh +++ b/resources/install_dynadjust_prerequisites.sh @@ -6,7 +6,14 @@ # ################################################################################# - +_distro_centos="CentOS Linux" +_distro_debian="Debian" +_distro_fedora="Fedora" +_distro_opensusel="openSUSE Leap" +_distro_opensuse="openSUSE" +_distro_rhels="Red Hat Enterprise Linux Server" +_distro_rhel="Red Hat Enterprise Linux" +_distro_ubuntu="Ubuntu" ################################################################################# # Capture system variables and set defaults @@ -27,6 +34,7 @@ _system=$(uname -sroi) _script="install_dynadjust_prerequisites.sh" _mode=0 _distribution= +_create_downloads_dir=0 ################################################################################# @@ -48,8 +56,14 @@ function help { echo "" usage echo -e "options:" - echo -e " -d [ --distro ] arg The linux distribution, e.g. \"Ubuntu\", \"Fedora\", etc. " - echo -e " If not provided, try to get from /etc/os-release." + echo -e " -d [ --distro ] arg The linux distribution. Recognised distros include:" + echo -e " - ${_distro_centos}" + echo -e " - ${_distro_debian}" + echo -e " - ${_distro_fedora}" + echo -e " - ${_distro_opensuse}" + echo -e " - ${_distro_rhel}" + echo -e " - ${_distro_ubuntu}" + echo -e " If not provided, I will try to get the distro from /etc/os-release." echo -e " -m [ --mode ] arg Mode of installing prerequisites:" echo -e " 0: interactive (default)" echo -e " 1: package manager" @@ -99,20 +113,26 @@ function args_check { if [[ ! -z $_distribution ]]; then # Set distro based on first character if [[ "$firstletter" = "C" ]]; then - _distro="CentOS Linux" + _distro=${_distro_centos} elif [[ "$firstletter" = "R" ]]; then - _distro="Red Hat Enterprise Linux Server" + _distro=${_distro_rhel} elif [[ "$firstletter" = "F" ]]; then - _distro="Fedora" + _distro=${_distro_fedora} elif [[ "$firstletter" = "O" ]]; then - _distro="openSUSE" + _distro=${_distro_opensuse} elif [[ "$firstletter" = "U" ]]; then - _distro="Ubuntu" + _distro=${_distro_ubuntu} elif [[ "$firstletter" = "D" ]]; then - _distro="Debian" + _distro=${_distro_debian} else # error - echo -e "\nUnknown value: --distro $_distribution" + echo -e "\nerror: Unknown distribution: \"$_distribution\"\n" + echo -e " If your Linux distribution is based on a distro in the supported" + echo -e " list (e.g. Mint is based on Ubuntu), try running:" + echo -e " $ ${_script} -d base-distro\n" + echo -e " If this fails to work, please submit an issue at:" + echo -e " https://github.com/icsm-au/DynAdjust/issues including this message" + echo -e " and your distribution." help exit 1 # error fi @@ -397,6 +417,13 @@ elif [[ $REPLY == 2 ]]; then sudo mkdir /opt/xerces-c/3.1.4 fi + if [[ ! -d "$DOWNLOADS_FOLDER_FULLPATH" ]]; then + mkdir "$DOWNLOADS_FOLDER_FULLPATH" + _create_downloads_dir=1 + else + #echo -e "\n ${DOWNLOADS_FOLDER} exists" + fi + # 2. download: echo "Downloading xerces-c 3.1.4..." echo " " @@ -435,6 +462,11 @@ elif [[ $REPLY == 2 ]]; then if [[ -e "$XERCES_TMP_FILE" ]]; then rm -f "$XERCES_TMP_FILE" fi + + if [[ _create_downloads_dir -eq 1 ]]; then + #echo -e "\n ${DOWNLOADS_FOLDER} removed" + rm -R "$DOWNLOADS_FOLDER_FULLPATH" + fi else echo " " @@ -513,6 +545,9 @@ elif [[ $REPLY == 2 ]]; then if [[ ! -d "$DOWNLOADS_FOLDER_FULLPATH" ]]; then mkdir "$DOWNLOADS_FOLDER_FULLPATH" + _create_downloads_dir=1 + else + #echo -e "\n ${DOWNLOADS_FOLDER} exists" fi # 2. download: @@ -550,6 +585,11 @@ elif [[ $REPLY == 2 ]]; then rm -f "$XSD_TMP_FILE" fi + if [[ _create_downloads_dir -eq 1 ]]; then + #echo -e "\n ${DOWNLOADS_FOLDER} removed" + rm -R "$DOWNLOADS_FOLDER_FULLPATH" + fi + else echo " " echo "Skipping xsd installation." diff --git a/resources/make_dynadjust_gcc.sh b/resources/make_dynadjust_gcc.sh index 80c867db..cb1a14b6 100755 --- a/resources/make_dynadjust_gcc.sh +++ b/resources/make_dynadjust_gcc.sh @@ -30,7 +30,7 @@ _binaries=(dnaimportwrapper dnaimport dnageoidwrapper dnageoid dnareftranwrapper # display example message function example { echo -e "examples:" - echo -e " $_script --auto --do-not-clone --test --no-install" + echo -e " $_script --auto --no-clone --test --no-install" } # display usage message @@ -43,15 +43,21 @@ function help { echo "" usage echo -e "options:" - echo -e " -a [ --auto ] Run automatically with no user interaction." - echo -e " -b [ --binary ] arg Build a specific binary (e.g. \"dnaimport\" or \"dnaadjustwrapper\")." - echo -e " By default, \"all\" binaries are built." - echo -e " -c [ --do-not-clone ] By default, the latest version will be cloned from GitHub." - echo -e " Set this option if a clone should not be made." - echo -e " -d [ --debug ] Compile debug version." - echo -e " -n [ --no-install ] Do not install binaries." - echo -e " -t [ --test ] Run cmake tests." - echo -e " -h [ --help ] Prints this help message.\n" + echo -e " -a [ --auto ] Run automatically with no user interaction." + echo -e " -b [ --binary ] arg Build a specific binary (e.g. \"dnaimport\" or \"dnaadjustwrapper\")." + echo -e " By default, \"all\" binaries are built." + echo -e " -c [ --no-clone ] By default, the latest version will be cloned from GitHub" + echo -e " into the current directory, using:" + echo -e " git clone https://github.com/icsm-au/DynAdjust.git" + echo -e " Provide this option if building source from a local copy, e.g.:" + echo -e " $ wget https://github.com/icsm-au/DynAdjust/archive/refs/tags/v1.1.0.tar.gz -O DynAdjust-1.1.0.tar.gz" + echo -e " $ tar xzvf DynAdjust-1.1.0.tar.gz" + echo -e " $ cd DynAdjust-1.1.0/" + echo -e " $ bash ./resources/make_dynadjust_gc.sh (this script)" + echo -e " -d [ --debug ] Compile debug version." + echo -e " -n [ --no-install ] Do not install binaries." + echo -e " -t [ --test ] Run cmake tests." + echo -e " -h [ --help ] Prints this help message.\n" example echo "" } @@ -69,7 +75,7 @@ do -d | --debug ) _debug=1 # compile debug variant ;; - -c | --do-not-clone ) + -c | --no-clone ) _clone=1 # do not clone from GitHub ;; -t | --test ) @@ -128,10 +134,20 @@ else echo -e " - run interactively (ask for user input)." fi +# get current directory +_cwd="$PWD" + if [[ $_clone -eq 1 ]]; then - echo -e " - do not clone a fresh copy from GitHub." + echo -e " - do not clone, but build from local source." + # As per help, the user is expected to be in this directory once + # a local copy has been extracted. + _clone_dir="$_cwd" + else echo -e " - clone a fresh copy from GitHub." + # set directory to which git will clone the latest + # DynAdjust repo + _clone_dir="$_cwd/DynAdjust" fi if [[ $_test -eq 1 ]]; then @@ -144,11 +160,6 @@ else echo -e " - install binaries to /opt/dynadjust/gcc/x_x_x." fi - -# get current directory -_cwd="$PWD" -# set dynadjust clone dir -_clone_dir="$_cwd/DynAdjust" # set dynadjust root dir _root_dir="$_clone_dir/dynadjust" # set dynadjust root dir @@ -165,10 +176,10 @@ eval BIN_FOLDER_FULLPATH="$BIN_FOLDER" # opt installation folder OPT_DYNADJUST_PATH=/opt/dynadjust OPT_DYNADJUST_GCC_PATH=/opt/dynadjust/gcc -DYNADJUST_INSTALL_PATH=/opt/dynadjust/gcc/1_1_0 +DYNADJUST_INSTALL_PATH=/opt/dynadjust/gcc/1_2_1 # version info -_version="1.1.0" +_version="1.2.1" echo -e "\n===========================================================================" echo -e "Build and installation of DynAdjust $_version...\n" @@ -212,22 +223,31 @@ else fi # INSTALL DYNADJUST -# 1. create install dirs: -if [[ $_install -eq 0 ]]; then - if [[ ! -d "$BIN_FOLDER_FULLPATH" ]]; then - echo " " - echo "Making $BIN_FOLDER_FULLPATH" - mkdir "$BIN_FOLDER_FULLPATH" - fi -fi - -# 2. clone from GitHub: +# 1. clone from GitHub (if required): if [[ $_clone -eq 0 ]]; then echo " " echo "Cloning DynAdjust..." git clone "$_clone_url" || echo -e "Okay, let's assume we already have a previously cloned version.\n" fi +# check if root directory exists +if [[ -d "$_root_dir" ]]; then + # Good, directory exists + echo -e "\nSuccessfully found root directory: $_root_dir\n" +else + echo -e "\nerror: can't find root directory: $_root_dir\n" + echo -e " If building from a local copy, please ensure this script is executed" + echo -e " from the parent directory containing the following directories:" + echo -e " ./dynadjust" + echo -e " ./resources" + echo -e " ./sampleData\n" + echo -e " For example:" + echo -e " $ tar xzvf DynAdjust-1.1.0.tar.gz" + echo -e " $ cd DynAdjust-1.1.0/" + echo -e " $ ./resources/make_dynadjust_gcc.sh\n" + exit 1 # error +fi + if [[ -d "$_build_dir" ]]; then echo "Cleaning out directory $_build_dir" cd "$_build_dir" @@ -279,6 +299,7 @@ esac echo -e "\n===========================================================================" + # Make! if [[ $_binary = "all" ]]; then echo -e "Building DynAdjust $_version...\n" @@ -309,26 +330,44 @@ esac # # determine if user needs prompting case ${_auto} in - 0) # install binaries - echo " " - read -r -p "Install DynAdjust to $OPT_DYNADJUST_PATH [Y/n]: " optresponse;; - *) # proceed without asking + 0) # Interactive mode (check if the user has + # already decided not to install) + if [[ $_install -eq 1 ]]; then + # user did not want to install, so don't ask + optresponse="n" + else + echo " " + read -r -p "Install DynAdjust to $OPT_DYNADJUST_PATH [Y/n]: " optresponse + fi + ;; + *) # proceed without asking. Assume installation optresponse="y" - # set install option + + # user did not want to install, so alter the + # response accordingly if [[ $_install -eq 1 ]]; then optresponse="n" fi ;; esac +_lib_ext="so" + if [[ "$optresponse" =~ ^([nN][oO]|[nN])$ ]] then echo " " else - _lib_ext="so" + # create install dirs: + if [[ $_install -eq 0 ]]; then + if [[ ! -d "$BIN_FOLDER_FULLPATH" ]]; then + echo " " + echo "Making $BIN_FOLDER_FULLPATH" + mkdir "$BIN_FOLDER_FULLPATH" + fi + fi - # 1 GET OS, DISTRO AND TOOLS + # 1 GET OS, DISTRO AND TOOLS if [[ "$OSTYPE" == "darwin"* ]]; then # Mac OSX _lib_ext="dylib" @@ -423,12 +462,53 @@ fi # return to the original "current directory" cd "$_cwd" -echo "Done." -echo " " +echo -e "Done.\n" if [[ $_install -eq 0 ]]; then echo "Don't forget to add the bin directory to path in ~/.bash_profile" echo "For example:" - echo " EXPORT PATH=$PATH:$HOME/bin" + echo -e " EXPORT PATH=$PATH:$HOME/bin\n" +else + echo "DynAdjust binaries can be located as follows:" + if [[ -e "${_build_dir}/dynadjust/dynadjust/dynadjust" ]]; then + echo " +[dynadjust]" + echo " ./dynadjust/build_gcc/dynadjust/dynadjust" + fi + if [[ -e "${_build_dir}/dynadjust/dnaadjustwrapper/dnaadjust" ]]; then + echo " +[dnaadjust]" + echo " ./dynadjust/build_gcc/dynadjust/dnaadjustwrapper/dnaadjust" + echo " ./dynadjust/build_gcc/dynadjust/dnaadjust/libdnaadjust.$_lib_ext" + fi + + if [[ -e "${_build_dir}/dynadjust/dnaimportwrapper/dnaimport" ]]; then + echo " +[dnaimport]" + echo " ./dynadjust/build_gcc/dynadjust/dnaimport/libdnaimport.$_lib_ext" + echo " ./dynadjust/build_gcc/dynadjust/dnaimportwrapper/dnaimport" + fi + + if [[ -e "${_build_dir}/dynadjust/dnareftranwrapper/dnareftran" ]]; then + echo " +[dnareftran]" + echo " ./dynadjust/build_gcc/dynadjust/dnareftranwrapper/dnareftran" + echo " ./dynadjust/build_gcc/dynadjust/dnareftran/libdnareftran.$_lib_ext" + fi + + if [[ -e "${_build_dir}/dynadjust/dnageoidwrapper/dnageoid" ]]; then + echo " +[dnageoid]" + echo " ./dynadjust/build_gcc/dynadjust/dnageoidwrapper/dnageoid" + echo " ./dynadjust/build_gcc/dynadjust/dnageoid/libdnageoid.$_lib_ext" + fi + + if [[ -e "${_build_dir}/dynadjust/dnasegmentwrapper/dnasegment" ]]; then + echo " +[dnasegment]" + echo " ./dynadjust/build_gcc/dynadjust/dnasegmentwrapper/dnasegment" + echo " ./dynadjust/build_gcc/dynadjust/dnasegment/libdnasegment.$_lib_ext" + fi + + if [[ -e "${_build_dir}/dynadjust/dnaplotwrapper/dnaplot" ]]; then + echo " +[dnaplot]" + echo " ./dynadjust/build_gcc/dynadjust/dnaplotwrapper/dnaplot" + echo " ./dynadjust/build_gcc/dynadjust/dnaplot/libdnaplot.$_lib_ext" + fi + echo " " fi