diff --git a/.github/workflows/supercell-cicd.yml b/.github/workflows/supercell-cicd.yml index 0f6ae8f3..e21a3790 100644 --- a/.github/workflows/supercell-cicd.yml +++ b/.github/workflows/supercell-cicd.yml @@ -1,5 +1,5 @@ name: Build jobs -run-name: +run-name: on: push: paths: @@ -7,71 +7,88 @@ on: - 'lib/**' - '3rd_party/**' pull_request: - branches: + branches: - master release: types: [published] - + jobs: build-develop-linux: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, ubuntu-22.04] - compiler: [gcc-9, gcc-10, clang-11, clang-12, clang-13] + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04] + compiler: [gcc, gcc-9, gcc-10, gcc-11, gcc-12, gcc-13, clang] + include: + - os: ubuntu-latest + compiler: gcc + - os: ubuntu-latest + compiler: clang + - os: ubuntu-20.04 + compiler: clang-11 + - os: ubuntu-22.04 + compiler: clang-13 + - os: ubuntu-24.04 + compiler: gcc-14 + exclude: + - os: ubuntu-20.04 + compiler: gcc-12 + - os: ubuntu-20.04 + compiler: gcc-13 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - name: Setup C++ - uses: aminya/setup-cpp@v0.21.0 + uses: aminya/setup-cpp@v0.37.0 with: compiler: ${{ matrix.compiler }} cmake: true make: true - name: "Install dependencies" - run: "sudo apt update && sudo apt install -y - cmake build-essential libboost-test-dev libtinfo5 libtbb-dev - libarchive-dev libboost-program-options-dev libboost-filesystem-dev - libboost-system-dev libeigen3-dev liblzma-dev libbz2-dev zlib1g-dev zip" + run: | + sudo apt update && sudo apt install -y \ + cmake build-essential libboost-test-dev libtbb-dev \ + libarchive-dev libboost-program-options-dev libboost-filesystem-dev \ + libboost-system-dev libeigen3-dev liblzma-dev libbz2-dev zlib1g-dev zip - name: "Compile supercell." - run: cmake . -DCMAKE_BUILD_TYPE=Release && make supercell -j 2 + run: cmake . -DCMAKE_BUILD_TYPE=Release && make supercell -j 4 - name: "Check supercell" run: 'src/sc_cli/supercell -d -i ./data/examples/Ca2Al2SiO7/Ca2Al2SiO7.cif | grep -q "The total number of combinations is 6"' deploy-build-macos: strategy: fail-fast: false - runs-on: macos-latest + runs-on: macos-13 steps: - name: Set up Homebrew id: set-up-homebrew - uses: Homebrew/actions/setup-homebrew@master + uses: Homebrew/actions/setup-homebrew@master - name: "Install brew dependencies" run: | brew install boost eigen libarchive zlib - name: "Get TBB" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: oneapi-src/oneTBB - ref: v2021.7.0 + ref: v2021.13.0 path: ./tbb submodules: true - name: "Compile and install tbb" working-directory: ./tbb run: | cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DTBB_TEST=OFF - make -j 2 + make -j 4 sudo make install - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: path: ./supercell submodules: true - name: "Compile supercell." working-directory: ./supercell - run: | + run: | export PKG_CONFIG_PATH="/usr/local/opt/libarchive/lib/pkgconfig" - cmake . -DCMAKE_BUILD_TYPE=Release -DLINK_STATIC_LIBS=ON -DLibArchive_INCLUDE_DIR=/usr/local/opt/libarchive/include && make supercell -j 2 + cmake . -DCMAKE_BUILD_TYPE=Release -DLINK_STATIC_LIBS=ON -DLibArchive_INCLUDE_DIR=/usr/local/opt/libarchive/include && make supercell -j 4 - name: "Check supercell" working-directory: ./supercell run: 'src/sc_cli/supercell -d -i ./data/examples/Ca2Al2SiO7/Ca2Al2SiO7.cif | grep -q "The total number of combinations is 6"' @@ -79,96 +96,84 @@ jobs: working-directory: ./supercell run: 'otool -l src/sc_cli/supercell' - name: Upload Supercell - uses: actions/upload-artifact@v3.1.1 + uses: actions/upload-artifact@v4 with: name: macos-bin - path: ./supercell/src/sc_cli/supercell + path: ./supercell/src/sc_cli/supercell deploy-build-linux: strategy: fail-fast: false - runs-on: ubuntu-latest - container: ubuntu:18.04 + runs-on: ubuntu-20.04 steps: - - name: "Install dependencies" - run: | - apt-get update && apt-get full-upgrade -y - apt-get install -y software-properties-common wget tar cmake build-essential \ - ccache libboost-program-options-dev libboost-filesystem-dev libboost-test-dev \ - libarchive-dev liblzma-dev libbz2-dev zlib1g-dev zip libboost-system-dev - add-apt-repository ppa:git-core/ppa - add-apt-repository ppa:ubuntu-toolchain-r/test - apt-get update - apt-get install -y git gcc-9 g++-9 - - name: Cache - uses: pat-s/always-upload-cache@v3.0.11 - with: - path: /github/home/.ccache - key: linux-deploy-cache-${{ github.run_id }} # Can use time based key as well - restore-keys: | - linux-deploy-cache- - - name: "Compile and install dependencies" - run: | - ccache -s - export CC=gcc-9 - export CXX=g++-9 - export PATH="/usr/lib/ccache:$PATH" - export BASE_DIR=${PWD} - mkdir eigen && cd eigen - wget -nv https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz -O - | tar -zxf - - mkdir build && cd build - cmake ../eigen-3.4.0 - make install - cd $BASE_DIR - git clone https://github.com/oneapi-src/oneTBB.git - cd oneTBB && git checkout v2021.7.0 - mkdir cmake-build && cd cmake-build - cmake ../ -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DTBB_TEST=OFF - make -j 2 && make install - cd $BASE_DIR - wget -nv https://github.com/libarchive/libarchive/releases/download/v3.6.1/libarchive-3.6.1.tar.gz -O - | tar -zxf - - cd libarchive-3.6.1 - ./configure --without-openssl --without-libb2 --without-xml2 --without-expat --disable-bsdtar - sed -ir '/^.*#define HAVE_LZMA_STREAM_ENCODER_MT 1.*$/d' config.h - make -j 2 - make install - cd $BASE_DIR - name: "Clone supercell" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: ./supercell submodules: true - - name: "Compile and install supercell" - run: | - export CC=gcc-9 - export CXX=g++-9 - export PATH="/usr/lib/ccache:$PATH" - cd supercell - cmake . -DCMAKE_BUILD_TYPE=Release -DLINK_STATIC_LIBS=ON && make supercell -j 2 - ccache -s - - name: "Test supercell" - run: | - supercell/src/sc_cli/supercell -d -i supercell/data/examples/Ca2Al2SiO7/Ca2Al2SiO7.cif | grep -q "The total number of combinations is 6" - - name: Upload Supercell - uses: actions/upload-artifact@v3.1.1 + - name: "Clone oneTBB" + uses: actions/checkout@v4 + with: + repository: oneapi-src/oneTBB + ref: v2021.13.0 + path: ./oneTBB + submodules: true + - name: "Compile supercell with deps" + uses: addnab/docker-run-action@v3 + with: + image: ubuntu:18.04 + options: -v ${{ github.workspace }}:/work + run: | + apt-get update && apt-get full-upgrade -y + apt-get install -y software-properties-common wget tar cmake build-essential \ + libboost-program-options-dev libboost-filesystem-dev libboost-test-dev \ + libarchive-dev liblzma-dev libbz2-dev zlib1g-dev zip libboost-system-dev + add-apt-repository ppa:git-core/ppa + add-apt-repository ppa:ubuntu-toolchain-r/test + apt-get update + apt-get install -y git gcc-9 g++-9 + export CC=gcc-9 + export CXX=g++-9 + export BASE_DIR="/work" + mkdir ${BASE_DIR}/eigen && cd ${BASE_DIR}/eigen + wget -nv https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz -O - | tar -zxf - + mkdir build && cd build + cmake ../eigen-3.4.0 + make install + cd $BASE_DIR/oneTBB + mkdir cmake-build && cd cmake-build + cmake ../ -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DTBB_TEST=OFF + make -j 4 && make install + wget -nv https://github.com/libarchive/libarchive/releases/download/v3.7.4/libarchive-3.7.4.tar.gz -O - | tar -zxf - + cd libarchive-3.7.4 + ./configure --without-openssl --without-libb2 --without-xml2 --without-expat --disable-bsdtar + sed -ir '/^.*#define HAVE_LZMA_STREAM_ENCODER_MT 1.*$/d' config.h + make -j 4 + make install + cd $BASE_DIR/supercell + cmake . -DCMAKE_BUILD_TYPE=Release -DLINK_STATIC_LIBS=ON && make supercell -j 4 + $BASE_DIR/supercell/src/sc_cli/supercell -d -i $BASE_DIR/supercell/data/examples/Ca2Al2SiO7/Ca2Al2SiO7.cif | grep -q "The total number of combinations is 6" + - name: Upload Supercell + uses: actions/upload-artifact@v4 with: name: linux-bin path: ./supercell/src/sc_cli/supercell deploy-build-windows: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: "Install dependencies" run: | sudo apt update && sudo apt -y full-upgrade sudo apt install -y gcc cmake build-essential wine-stable autopoint gperf intltool libtool libtool-bin lzip p7zip-full python3 python3-mako - name: "Download MXE" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: mxe/mxe path: ./mxe submodules: true - name: Cache - uses: pat-s/always-upload-cache@v3.0.11 + uses: actions/cache@v4 with: + save-always: true path: ./mxe/.ccache key: win-cache-${{ github.run_id }} # Can use time based key as well restore-keys: | @@ -177,14 +182,14 @@ jobs: working-directory: ./mxe run: | sed -i -r 's/ nettle / /g' src/libarchive.mk && sed -i -r 's/with-nettle/without-nettle --without-openssl --without-iconv /g' src/libarchive.mk - make MXE_TARGETS=x86_64-w64-mingw32.static MXE_PLUGIN_DIRS=plugins/gcc10 ccache + make MXE_TARGETS=x86_64-w64-mingw32.static MXE_PLUGIN_DIRS=plugins/gcc13 ccache echo 'max_size = 15.0G' > .ccache/ccache/ccache.conf - .ccache/bin/ccache -s - make MXE_TARGETS=x86_64-w64-mingw32.static MXE_PLUGIN_DIRS=plugins/gcc10 ccache cc cmake intel-tbb boost eigen libarchive --jobs=4 JOBS=2 + .ccache/bin/ccache -s + make MXE_TARGETS=x86_64-w64-mingw32.static MXE_PLUGIN_DIRS=plugins/gcc13 ccache cc cmake intel-tbb boost eigen libarchive --jobs=4 JOBS=4 .ccache/bin/ccache -s echo "${PWD}/usr/bin" >> $GITHUB_PATH - name: "Clone supercell" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: ./supercell submodules: true @@ -196,15 +201,15 @@ jobs: - name: "Run supercell" working-directory: ./supercell run: 'wine64 src/sc_cli/supercell.exe -d -i ./data/examples/Ca2Al2SiO7/Ca2Al2SiO7.cif | grep -q "The total number of combinations is 6"' - - name: Upload Supercell - uses: actions/upload-artifact@v3.1.1 + - name: Upload Supercell + uses: actions/upload-artifact@v4 with: name: windows-bin path: ./supercell/src/sc_cli/supercell.exe - + deploy-to-site: if: github.event_name == 'release' - needs: [deploy-build-linux, deploy-build-macos, deploy-build-windows] + needs: [ deploy-build-linux, deploy-build-macos, deploy-build-windows ] runs-on: ubuntu-latest steps: - name: "Install dependencies" @@ -212,18 +217,18 @@ jobs: sudo apt-get update && sudo apt-get full-upgrade -y sudo apt-get update sudo apt-get install -y git wget tar openssh-client zip - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: linux-bin path: ./art/linux - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: windows-bin path: ./art/windows - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: macos-bin - path: ./art/osx + path: ./art/osx - name: "Deploy to file" env: SITE_REPO_KEY: ${{ secrets.DEPLOY_KEY }} @@ -234,11 +239,11 @@ jobs: DEPLOY_REPO="git@github.com:orex/orex.github.io.git" DEPLOY_BRANCH="master" DEPLOY_DIR="supercell/external" - # + # mkdir ~/.ssh eval `ssh-agent -s` echo "${SITE_REPO_KEY}" | ssh-add - - ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts + ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts # Clone the existing gh-pages for this repo into out/ # Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply) git clone --recurse-submodules "${DEPLOY_REPO}" --branch "${DEPLOY_BRANCH}" out && cd out @@ -249,7 +254,7 @@ jobs: #Main code mkdir -p "${REPO_PATH}/${DEPLOY_DIR}/exe/." cd `mktemp -d -t XXXXXX` - wget -nv https://github.com/orex/supercell/raw/deploy/README -O README + wget -nv https://github.com/orex/supercell/raw/deploy/README -O README for i in ${ART_DIR}/* do cp -a "${i}"/* . @@ -274,4 +279,4 @@ jobs: git status git commit -m "Deploy to GitHub Pages: ${GITHUB_SHA}" # Now that we're all set up, we can push. - git push $DEPLOY_REPO $DEPLOY_BRANCH + git push $DEPLOY_REPO $DEPLOY_BRANCH diff --git a/3rd_party/gemmi b/3rd_party/gemmi index 6830e4c1..0b23c060 160000 --- a/3rd_party/gemmi +++ b/3rd_party/gemmi @@ -1 +1 @@ -Subproject commit 6830e4c1e80ae6cf2a48366ced2c0d196dd18f23 +Subproject commit 0b23c060950f06d214037af38727b0e04f15c9f1 diff --git a/3rd_party/xxHash b/3rd_party/xxHash index 35b0373c..bbb27a5e 160000 --- a/3rd_party/xxHash +++ b/3rd_party/xxHash @@ -1 +1 @@ -Subproject commit 35b0373c697b5f160d3db26b1cbb45a0d5ba788c +Subproject commit bbb27a5efb85b92a0486cf361a8635715a53f6ba diff --git a/src/core/archive_extent_patch.h b/src/core/archive_extent_patch.h deleted file mode 100644 index cf316cc5..00000000 --- a/src/core/archive_extent_patch.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * File: archive_extent_patch.h - * Author: kirill - * - * Created on February 5, 2015, 2:48 PM - */ - -static -int cmpsuff(const char *str, const char *suffix) -{ - size_t length_str, length_suffix; - - if ((str == NULL) || (suffix == NULL)) - return -1; - - length_str = strlen(str); - length_suffix = strlen(suffix); - - if (length_str >= length_suffix) { - return strcmp(str + (length_str - length_suffix), suffix); - } else { - return -1; - } -} - -static const -struct { const char *name; int (*format)(struct archive *); int (*filter)(struct archive *); } names[] = - { - { ".7z", archive_write_set_format_7zip, archive_write_add_filter_none}, - { ".zip", archive_write_set_format_zip, archive_write_add_filter_none}, - { ".jar", archive_write_set_format_zip, archive_write_add_filter_none}, - { ".cpio", archive_write_set_format_cpio, archive_write_add_filter_none}, - { ".iso", archive_write_set_format_iso9660, archive_write_add_filter_none}, - { ".a", archive_write_set_format_ar_svr4, archive_write_add_filter_none}, - { ".ar", archive_write_set_format_ar_svr4, archive_write_add_filter_none}, - { ".tar", archive_write_set_format_pax_restricted, archive_write_add_filter_none}, - { ".tgz", archive_write_set_format_pax_restricted, archive_write_add_filter_gzip}, - { ".tar.gz", archive_write_set_format_pax_restricted, archive_write_add_filter_gzip}, - { ".tar.bz2", archive_write_set_format_pax_restricted, archive_write_add_filter_bzip2}, - { ".tar.xz", archive_write_set_format_pax_restricted, archive_write_add_filter_xz}, - { NULL, NULL, NULL } - }; - -static int get_array_index(const char *name) -{ - int i; - - for (i = 0; names[i].name != NULL; i++) - { - if (cmpsuff(name, names[i].name) == 0) - return i; - } - return -1; - -} - -int -archive_write_set_format_filter_by_ext(struct archive *a, const char *filename) -{ - int names_index = get_array_index(filename); - - if (names_index >= 0) - { - int format_state = (names[names_index].format)(a); - if (format_state == ARCHIVE_OK) - return ((names[names_index].filter)(a)); - else - return format_state; - } - - archive_set_error(a, EINVAL, "No such format '%s'", filename); - //a->state = ARCHIVE_STATE_FATAL; - return (ARCHIVE_FATAL); -} - diff --git a/src/core/cif_io.cpp b/src/core/cif_io.cpp index ff75512a..8ccda194 100644 --- a/src/core/cif_io.cpp +++ b/src/core/cif_io.cpp @@ -76,12 +76,15 @@ void cif_output::add_atom(int el_num, const std::string &label, const Eigen::Vec v[i] = 0.0; } - snprintf(buffer, sizeof(buffer), " %-8s%-5s%.5f%10.5f%10.5f%8.3f\n", + int spnr = snprintf(buffer, sizeof(buffer), " %-8s%-5s%.5f%10.5f%10.5f%8.3f\n", label.c_str(), gemmi::Element(el_num).name(), v.x(), v.y(), v.z(), occupancy); - so << buffer; - + if( spnr > 0 || spnr < sizeof(buffer) ) { + so << buffer; + } else { + so << "ERROR data write!!!"; + } } static diff --git a/src/core/d2o_main_class.cpp b/src/core/d2o_main_class.cpp index e6d2ada6..ae578ad3 100644 --- a/src/core/d2o_main_class.cpp +++ b/src/core/d2o_main_class.cpp @@ -44,10 +44,6 @@ #define PT_GETSYMBOL(atomic_num) gemmi::Element(atomic_num).name() using namespace std; -#if defined(LIBARCHIVE_ENABLED) && (!defined(LIBARCHIVE_PATCH_DISABLE)) -#include "archive_extent_patch.h" -#endif - bool d2o_main_class::create_tar_container(const std::string &fname) { bool result = true; @@ -1638,6 +1634,8 @@ bool d2o_main_class::show_groups_information() bool d2o_main_class::create_super_cell(int a, int b, int c) { + supercell_cst.block_name = orig_cst.block_name; + supercell_cst.chem_name = orig_cst.chem_name; supercell_cst.unit_cell.set(orig_cst.unit_cell.cell() * Eigen::DiagonalMatrix(a, b, c)); supercell_cst.atoms.clear(); supercell_cst.atoms.reserve(orig_cst.atoms.size() * a * b *c); @@ -1864,8 +1862,13 @@ bool d2o_main_class::process(std::string input_file_name, bool dry_run, return false; } - if(!dry_run) + if(!dry_run) { + if(f_q_calc.is_open()) + f_q_calc.close(); + close_tar_container(); + } return true; } + diff --git a/src/core/d2o_main_class.h b/src/core/d2o_main_class.h index 988810bf..f5ed767b 100644 --- a/src/core/d2o_main_class.h +++ b/src/core/d2o_main_class.h @@ -310,7 +310,7 @@ class d2o_main_class static inline double symm_tol() { return 1E-2; }; public: d2o_main_class() = delete; - d2o_main_class(std::random_device::result_type seed) : ss_p(seed), charge_balancing(false) {}; + d2o_main_class(std::random_device::result_type seed) : charge_balancing(false), ss_p(seed) {}; void set_verbosity(int vb) { verbose_level = vb; }; bool process(std::string input_file_name, bool dry_run, diff --git a/src/core/permut_process_t.h b/src/core/permut_process_t.h index 75f8fed8..ec80f658 100644 --- a/src/core/permut_process_t.h +++ b/src/core/permut_process_t.h @@ -124,8 +124,8 @@ class permut_process_t { int max_proc_struct) : syms(symmetries), permi(perm_indexes), allcmb(symmetries.rows(), symmetries.cols()), - ps_size(0), ps(max_proc_struct), min_weight(0), - hs(symmetries.rows(), hash_comb(symmetries.cols()), eq_comb(symmetries.cols())) + hs(symmetries.rows(), hash_comb(symmetries.cols()), eq_comb(symmetries.cols())), + ps_size(0), ps(max_proc_struct), min_weight(0) { assert(perm_indexes.back() == symmetries.cols()); }; diff --git a/src/sc_cli/CMakeLists.txt b/src/sc_cli/CMakeLists.txt index f7b16d11..48bed7f2 100644 --- a/src/sc_cli/CMakeLists.txt +++ b/src/sc_cli/CMakeLists.txt @@ -51,11 +51,6 @@ if( ${LibArchive_FOUND} ) find_package(ZLIB REQUIRED) set(LibArchive_LIBRARIES ${LibArchive_LIBRARIES} ${LIBLZMA_LIBRARIES} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARIES}) endif() - include(CheckFunctionExists) - CHECK_FUNCTION_EXISTS(archive_write_set_format_filter_by_ext LibArchive_format_filter_by_ext) - if( ${LibArchive_format_filter_by_ext} ) - add_definitions(-DLIBARCHIVE_PATCH_DISABLE ) - endif() else() message(WARNING "libarchive is not found. Packed output will be disabled.") endif() diff --git a/src/sc_cli/main.cpp b/src/sc_cli/main.cpp index 8708887f..5e57dcdd 100644 --- a/src/sc_cli/main.cpp +++ b/src/sc_cli/main.cpp @@ -141,7 +141,7 @@ int main(int argc, char** argv) if(verb_level > 0) { cout << "-----------------------------------------------------" << endl; - cout << "- Supercell program (v2.1) -" << endl; + cout << "- Supercell program (v2.1.1) -" << endl; cout << "- https://orex.github.io/supercell/ -" << endl; cout << "-----------------------------------------------------" << endl; cout << "- Authors: * Kirill Okhotnikov -" << endl;