From d7ab8e37cd4a8247b28afdd8be8442eeee49ab79 Mon Sep 17 00:00:00 2001 From: SY Wang Date: Mon, 9 Nov 2026 06:03:14 +0800 Subject: [PATCH 1/2] Precommit: Enable space-redirects in shfmt --- .pre-commit-config.yaml | 2 +- examples/13_dos/01_pw_Al/run.sh | 27 ++-- examples/13_dos/02_lcao_Si2/run.sh | 27 ++-- examples/32_bsse/01_water/run.sh | 10 +- generate_build_info.sh | 26 ++-- .../ShengBTE_interface/01_pw/3rd/run_stru.sh | 4 +- .../02_lcao/3rd/run_stru.sh | 4 +- .../source_basis/module_pw/test/test_gnu.sh | 8 +- .../source_basis/module_pw/test/test_intel.sh | 18 +-- tests/17_DS_DFTU/run_scf_nscf.sh | 22 +-- tests/integrate/Autotest.sh | 42 +++--- .../integrate/validation_tools/props_basic.sh | 42 +++--- .../validation_tools/props_common.sh | 8 +- .../integrate/validation_tools/props_cube.sh | 38 +++--- .../validation_tools/props_deepks.sh | 10 +- tests/integrate/validation_tools/props_lr.sh | 12 +- tests/integrate/validation_tools/props_mat.sh | 92 ++++++------- tests/integrate/validation_tools/props_ml.sh | 32 ++--- .../integrate/validation_tools/props_tddft.sh | 4 +- tests/integrate/validation_tools/run_check.sh | 6 +- .../validation_tools/run_librpa_producer.sh | 2 +- tests/performance/catch_properties.sh | 129 +++++++++--------- tests/performance/run.sh | 68 ++++----- toolchain/build_abacus_aocc-aocl.sh | 4 +- toolchain/build_abacus_gcc-aocl.sh | 4 +- toolchain/build_abacus_gcc-mkl.sh | 4 +- toolchain/build_abacus_gnu.sh | 4 +- toolchain/build_abacus_intel.sh | 4 +- toolchain/build_abacus_windows.sh | 10 +- toolchain/install_abacus_toolchain_new.sh | 8 +- toolchain/scripts/lib/config_manager.sh | 24 ++-- toolchain/scripts/lib/config_validator.sh | 26 ++-- toolchain/scripts/lib/package_manager.sh | 42 +++--- toolchain/scripts/lib/user_interface.sh | 58 ++++---- toolchain/scripts/lib/version_helper.sh | 2 +- toolchain/scripts/stage0/install_amd.sh | 4 +- toolchain/scripts/stage0/install_cmake.sh | 4 +- toolchain/scripts/stage0/install_gcc.sh | 36 ++--- toolchain/scripts/stage0/install_intel.sh | 4 +- toolchain/scripts/stage1/install_intelmpi.sh | 2 +- toolchain/scripts/stage1/install_mpich.sh | 14 +- toolchain/scripts/stage1/install_openmpi.sh | 14 +- toolchain/scripts/stage2/install_aocl.sh | 2 +- toolchain/scripts/stage2/install_mkl.sh | 6 +- toolchain/scripts/stage2/install_openblas.sh | 18 +-- toolchain/scripts/stage3/install_elpa.sh | 38 +++--- toolchain/scripts/stage3/install_fftw.sh | 26 ++-- toolchain/scripts/stage3/install_libxc.sh | 10 +- toolchain/scripts/stage3/install_scalapack.sh | 16 +-- toolchain/scripts/stage4/install_cereal.sh | 8 +- toolchain/scripts/stage4/install_dftd4.sh | 8 +- toolchain/scripts/stage4/install_json.sh | 6 +- toolchain/scripts/stage4/install_libcomm.sh | 4 +- toolchain/scripts/stage4/install_libnpy.sh | 4 +- toolchain/scripts/stage4/install_libri.sh | 4 +- toolchain/scripts/stage4/install_libtorch.sh | 8 +- toolchain/scripts/stage4/install_nep.sh | 10 +- toolchain/scripts/tool_kit.sh | 50 +++---- .../tests/test_installer_argument_failures.sh | 2 +- .../test_openmpi_binding_policy_setup.sh | 12 +- toolchain/toolchain_windows.sh | 6 +- .../Generate_Orbital_AllInOne.sh | 90 ++++++------ .../generate_orbital_mixstru.sh | 30 ++-- .../example_opt_lcao_bash/opt_orb/sub.sh | 2 +- .../examples/example_opt_lcao_bash/pre_run.sh | 4 +- tools/04_windows_installation/provision.sh | 6 +- 66 files changed, 633 insertions(+), 638 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4bc17df66d0..a06159a5077 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: rev: v3.14.1-1 hooks: - id: shfmt - args: [--write, --language-dialect=bash, --indent=2, --case-indent] + args: [--write, --language-dialect=bash, --indent=2, --case-indent, --space-redirects] - repo: local hooks: - id: abacus-agent-governance diff --git a/examples/13_dos/01_pw_Al/run.sh b/examples/13_dos/01_pw_Al/run.sh index f77dcf51942..143e9e296c1 100755 --- a/examples/13_dos/01_pw_Al/run.sh +++ b/examples/13_dos/01_pw_Al/run.sh @@ -14,18 +14,17 @@ OMP_NUM_THREADS=${ABACUS_THREADS} mpirun -np ${ABACUS_NPROCS} ${ABACUS_PATH} | t rm INPUT KPT -if [[ ! -f scf.output ]] || - [[ ! -f nscf.output ]] || - [[ ! -f OUT.ABACUS/running_scf.log ]] || - [[ ! -f OUT.ABACUS/running_nscf.log ]] || - [[ ! -f OUT.ABACUS/doss1.txt ]] || - [[ ! -f OUT.ABACUS/chg.cube ]] || - [[ ! ( "$(tail -1 OUT.ABACUS/running_scf.log)" == " Total Time :"* ) ]] || - [[ ! ( "$(tail -1 OUT.ABACUS/running_nscf.log)" == " Total Time :"* ) ]] -then - echo "job failed!" - exit 1 +if [[ ! -f scf.output ]] || + [[ ! -f nscf.output ]] || + [[ ! -f OUT.ABACUS/running_scf.log ]] || + [[ ! -f OUT.ABACUS/running_nscf.log ]] || + [[ ! -f OUT.ABACUS/doss1.txt ]] || + [[ ! -f OUT.ABACUS/chg.cube ]] || + [[ ! ("$(tail -1 OUT.ABACUS/running_scf.log)" == " Total Time :"*) ]] || + [[ ! ("$(tail -1 OUT.ABACUS/running_nscf.log)" == " Total Time :"*) ]]; then + echo "job failed!" + exit 1 else - echo "job succeeded!" - exit 0 -fi \ No newline at end of file + echo "job succeeded!" + exit 0 +fi diff --git a/examples/13_dos/02_lcao_Si2/run.sh b/examples/13_dos/02_lcao_Si2/run.sh index f77dcf51942..143e9e296c1 100755 --- a/examples/13_dos/02_lcao_Si2/run.sh +++ b/examples/13_dos/02_lcao_Si2/run.sh @@ -14,18 +14,17 @@ OMP_NUM_THREADS=${ABACUS_THREADS} mpirun -np ${ABACUS_NPROCS} ${ABACUS_PATH} | t rm INPUT KPT -if [[ ! -f scf.output ]] || - [[ ! -f nscf.output ]] || - [[ ! -f OUT.ABACUS/running_scf.log ]] || - [[ ! -f OUT.ABACUS/running_nscf.log ]] || - [[ ! -f OUT.ABACUS/doss1.txt ]] || - [[ ! -f OUT.ABACUS/chg.cube ]] || - [[ ! ( "$(tail -1 OUT.ABACUS/running_scf.log)" == " Total Time :"* ) ]] || - [[ ! ( "$(tail -1 OUT.ABACUS/running_nscf.log)" == " Total Time :"* ) ]] -then - echo "job failed!" - exit 1 +if [[ ! -f scf.output ]] || + [[ ! -f nscf.output ]] || + [[ ! -f OUT.ABACUS/running_scf.log ]] || + [[ ! -f OUT.ABACUS/running_nscf.log ]] || + [[ ! -f OUT.ABACUS/doss1.txt ]] || + [[ ! -f OUT.ABACUS/chg.cube ]] || + [[ ! ("$(tail -1 OUT.ABACUS/running_scf.log)" == " Total Time :"*) ]] || + [[ ! ("$(tail -1 OUT.ABACUS/running_nscf.log)" == " Total Time :"*) ]]; then + echo "job failed!" + exit 1 else - echo "job succeeded!" - exit 0 -fi \ No newline at end of file + echo "job succeeded!" + exit 0 +fi diff --git a/examples/32_bsse/01_water/run.sh b/examples/32_bsse/01_water/run.sh index c0b25704b5b..99701520931 100755 --- a/examples/32_bsse/01_water/run.sh +++ b/examples/32_bsse/01_water/run.sh @@ -28,11 +28,11 @@ E_O=$(grep FINAL_ETOT_IS OUT.ABACUS/running_scf_O.log | awk '{printf $2}') E_H1=$(grep FINAL_ETOT_IS OUT.ABACUS/running_scf_H1.log | awk '{printf $2}') E_H2=$(grep FINAL_ETOT_IS OUT.ABACUS/running_scf_H2.log | awk '{printf $2}') result=$(echo "scale=12; ${E_H2O} - ${E_O} - ${E_H1} - ${E_H2}" | bc -l) -echo $result >result.out -echo "E_H2O: $E_H2O" >>result.out -echo "E_O: $E_O" >>result.out -echo "E_H1: $E_H1" >>result.out -echo "E_H2: $E_H2" >>result.out +echo $result > result.out +echo "E_H2O: $E_H2O" >> result.out +echo "E_O: $E_O" >> result.out +echo "E_H1: $E_H1" >> result.out +echo "E_H2: $E_H2" >> result.out result_ref=$(cat result.ref | head -1) difference=$(echo "scale=12; $result - $result_ref" | bc -l) abs_difference=$(echo "scale=12; if ($difference < 0) $difference * -1 else $difference" | bc) diff --git a/generate_build_info.sh b/generate_build_info.sh index 6b87ce6fbbb..3aeb8171988 100755 --- a/generate_build_info.sh +++ b/generate_build_info.sh @@ -23,7 +23,7 @@ OUTPUT_FILE=$1 get_version_from_command() { local cmd="$1" local regex="$2" - if command -v "$cmd" >/dev/null; then + if command -v "$cmd" > /dev/null; then local output=$($cmd 2>&1) if [[ $output =~ $regex ]]; then echo "${BASH_REMATCH[1]}" @@ -71,7 +71,7 @@ MPI_VERSION="no" if [ "${ENABLE_MPI}" == "ON" ]; then MPI_IMPLEMENTATION="Unknown" MPI_COMPILER="${MPI_CXX_COMPILER:-mpicxx}" - if command -v "$MPI_COMPILER" >/dev/null; then + if command -v "$MPI_COMPILER" > /dev/null; then # Intel MPI (oneAPI) version=$(get_version_from_command "$MPI_COMPILER --version" "Intel\(R\) oneAPI DPC\+\+/C\+\+ Compiler ([0-9]+\.[0-9]+\.[0-9]+)") if [ -n "$version" ]; then @@ -103,7 +103,7 @@ if [ "${ENABLE_MPI}" == "ON" ]; then fi fi # Fallback via mpirun - if [ -z "$version" ] && command -v mpirun >/dev/null; then + if [ -z "$version" ] && command -v mpirun > /dev/null; then mr_out=$(mpirun --version 2>&1) if [[ $mr_out =~ Open\ MPI\ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then MPI_IMPLEMENTATION="OpenMPI" @@ -125,8 +125,8 @@ OPENMP_VERSION="no" if [[ "$CXX_FLAGS" == *"-fopenmp"* ]]; then OPENMP_VERSION="yes (version unknown)" # Try to get version from compiler - if command -v "$CXX_COMPILER_PATH" >/dev/null; then - version=$($CXX_COMPILER_PATH -dM -E - &1 | grep '#define _OPENMP ' | awk '{print $3}') + if command -v "$CXX_COMPILER_PATH" > /dev/null; then + version=$($CXX_COMPILER_PATH -dM -E - < /dev/null 2>&1 | grep '#define _OPENMP ' | awk '{print $3}') if [ -n "$version" ]; then # Convert YYYYMM to a more readable format if possible year=$((version / 10000)) @@ -154,8 +154,8 @@ LIBXC_VERSION="no" if [ "${ENABLE_LIBXC}" == "ON" ]; then LIBXC_VERSION="yes (version unknown)" # Try pkg-config first - if command -v pkg-config >/dev/null; then - version=$(pkg-config --modversion libxc 2>/dev/null) + if command -v pkg-config > /dev/null; then + version=$(pkg-config --modversion libxc 2> /dev/null) if [ -n "$version" ]; then LIBXC_VERSION="yes (v$version)"; fi fi # Fallback to header @@ -173,7 +173,7 @@ if [ "${USE_CUDA}" == "ON" ]; then if [ -n "$CUDA_HOME" ]; then version=$(get_version_from_command "$CUDA_HOME/bin/nvcc --version" "release ([0-9]+\.[0-9]+)") if [ -n "$version" ]; then CUDA_VERSION="yes (v$version)"; fi - elif command -v nvcc >/dev/null; then + elif command -v nvcc > /dev/null; then version=$(get_version_from_command "nvcc --version" "release ([0-9]+\.[0-9]+)") if [ -n "$version" ]; then CUDA_VERSION="yes (v$version)"; fi fi @@ -186,7 +186,7 @@ if [ "${USE_ROCM}" == "ON" ]; then if [ -n "$ROCM_PATH" ]; then version=$(get_version_from_command "$ROCM_PATH/bin/hipcc --version" "HIP version: ([0-9]+\.[0-9]+\.[0-9]+)") if [ -n "$version" ]; then ROCM_VERSION="yes (v$version)"; fi - elif command -v hipcc >/dev/null; then + elif command -v hipcc > /dev/null; then version=$(get_version_from_command "hipcc --version" "HIP version: ([0-9]+\.[0-9]+\.[0-9]+)") if [ -n "$version" ]; then ROCM_VERSION="yes (v$version)"; fi fi @@ -205,7 +205,7 @@ ELPA_VERSION="no" if [ "${ENABLE_ELPA}" == "ON" ] && [ -n "$ELPA_DIR" ]; then ELPA_VERSION="yes (version unknown)" if [ -f "$ELPA_DIR/bin/elpa2_print_version" ]; then - version=$("$ELPA_DIR/bin/elpa2_print_version" 2>/dev/null) + version=$("$ELPA_DIR/bin/elpa2_print_version" 2> /dev/null) if [ -n "$version" ]; then ELPA_VERSION="yes ($version)"; fi else ELPA_VERSION="yes (path: $ELPA_DIR)" @@ -258,8 +258,8 @@ fi # CUDA-aware MPI CUDA_AWARE_MPI="no" if [ "${USE_CUDA}" == "ON" ]; then - if command -v ompi_info >/dev/null; then - out=$(ompi_info --parsable --all 2>/dev/null) + if command -v ompi_info > /dev/null; then + out=$(ompi_info --parsable --all 2> /dev/null) if echo "$out" | grep -q "mpi_built_with_cuda_support:value:true"; then CUDA_AWARE_MPI="yes" else @@ -304,6 +304,6 @@ sed \ -e "s#@ABACUS_ASAN_STATUS@#${ENABLE_ASAN:-no}#g" \ -e "s#@ABACUS_CMAKE_OPTIONS@#Not available with Makefile#g" \ -e "s#@ABACUS_CMAKE_FIND_PACKAGES@#Not available with Makefile#g" \ - "$INPUT_FILE" >"$OUTPUT_FILE" + "$INPUT_FILE" > "$OUTPUT_FILE" echo "Generated $OUTPUT_FILE successfully." diff --git a/interfaces/ShengBTE_interface/01_pw/3rd/run_stru.sh b/interfaces/ShengBTE_interface/01_pw/3rd/run_stru.sh index 56f82ff2918..2245a084104 100644 --- a/interfaces/ShengBTE_interface/01_pw/3rd/run_stru.sh +++ b/interfaces/ShengBTE_interface/01_pw/3rd/run_stru.sh @@ -6,7 +6,7 @@ for i in STRU_*; do mkdir SCF-$stru cd SCF-$stru pwd - cat >INPUT < INPUT << EOF INPUT_PARAMETERS #Parameters (General) suffix DIA-50-$stru @@ -32,7 +32,7 @@ mixing_beta 0.7 stru_file STRU_$stru EOF - cat >KPT < KPT << EOF K_POINTS 0 Gamma diff --git a/interfaces/ShengBTE_interface/02_lcao/3rd/run_stru.sh b/interfaces/ShengBTE_interface/02_lcao/3rd/run_stru.sh index 19113639c3e..15610bcff20 100644 --- a/interfaces/ShengBTE_interface/02_lcao/3rd/run_stru.sh +++ b/interfaces/ShengBTE_interface/02_lcao/3rd/run_stru.sh @@ -6,7 +6,7 @@ for i in STRU_*; do mkdir SCF-$stru cd SCF-$stru pwd - cat >INPUT < INPUT << EOF INPUT_PARAMETERS #Parameters (General) suffix DIA-50-$stru @@ -33,7 +33,7 @@ mixing_beta 0.7 stru_file STRU_$stru EOF - cat >KPT < KPT << EOF K_POINTS 0 Gamma diff --git a/source/source_basis/module_pw/test/test_gnu.sh b/source/source_basis/module_pw/test/test_gnu.sh index e5559007063..98ccd4c15ba 100644 --- a/source/source_basis/module_pw/test/test_gnu.sh +++ b/source/source_basis/module_pw/test/test_gnu.sh @@ -1,6 +1,6 @@ #!/bin/bash -make clean >/dev/null 2>&1 +make clean > /dev/null 2>&1 for ((i = 0; i < 4; ++i)); do @@ -27,17 +27,17 @@ for ((i = 0; i < 4; ++i)); do ./pw_test.exe sleep 1 echo "3 processors:" - mpirun -np 3 ./pw_test.exe >_tmp.txt + mpirun -np 3 ./pw_test.exe > _tmp.txt cat _tmp.txt | grep PASSED cat _tmp.txt | grep FAILED sleep 1 echo "5 processors:" - mpirun -np 5 ./pw_test.exe >_tmp.txt + mpirun -np 5 ./pw_test.exe > _tmp.txt cat _tmp.txt | grep PASSED cat _tmp.txt | grep FAILED sleep 1 echo "8 processors:" - mpirun -np 8 ./pw_test.exe >_tmp.txt + mpirun -np 8 ./pw_test.exe > _tmp.txt cat _tmp.txt | grep PASSED cat _tmp.txt | grep FAILED fi diff --git a/source/source_basis/module_pw/test/test_intel.sh b/source/source_basis/module_pw/test/test_intel.sh index babb2ebaa34..ba9f387587b 100644 --- a/source/source_basis/module_pw/test/test_intel.sh +++ b/source/source_basis/module_pw/test/test_intel.sh @@ -1,25 +1,25 @@ #!/bin/bash -make clean >/dev/null 2>&1 +make clean > /dev/null 2>&1 for ((i = 0; i < 4; ++i)); do if ((i == 0)); then - make -j12 CXX=icpc >/dev/null + make -j12 CXX=icpc > /dev/null echo "Test for Serial Version:" ./pw_test.exe elif ((i == 1)); then - make -j12 CXX=icpc FLOAT=ON >/dev/null + make -j12 CXX=icpc FLOAT=ON > /dev/null echo "Test for Serial Version with single precision:" ./pw_test.exe elif ((i == 2)); then - make -j12 CXX=mpiicpc >/dev/null + make -j12 CXX=mpiicpc > /dev/null echo "Test for MPI Version:" elif ((i == 3)); then - make -j12 CXX=mpiicpc FLOAT=ON >/dev/null + make -j12 CXX=mpiicpc FLOAT=ON > /dev/null echo "Test for MPI Version with single precision:" fi if ((i >= 2)); then @@ -27,22 +27,22 @@ for ((i = 0; i < 4; ++i)); do ./pw_test.exe sleep 1 echo "3 processors:" - mpirun -np 3 ./pw_test.exe >_tmp.txt + mpirun -np 3 ./pw_test.exe > _tmp.txt cat _tmp.txt | grep PASSED cat _tmp.txt | grep FAILED sleep 1 echo "5 processors:" - mpirun -np 5 ./pw_test.exe >_tmp.txt + mpirun -np 5 ./pw_test.exe > _tmp.txt cat _tmp.txt | grep PASSED cat _tmp.txt | grep FAILED sleep 1 echo "8 processors:" - mpirun -np 8 ./pw_test.exe >_tmp.txt + mpirun -np 8 ./pw_test.exe > _tmp.txt cat _tmp.txt | grep PASSED cat _tmp.txt | grep FAILED fi - make clean >/dev/null 2>&1 + make clean > /dev/null 2>&1 done diff --git a/tests/17_DS_DFTU/run_scf_nscf.sh b/tests/17_DS_DFTU/run_scf_nscf.sh index e114b885cf4..87bb6e5ba1c 100755 --- a/tests/17_DS_DFTU/run_scf_nscf.sh +++ b/tests/17_DS_DFTU/run_scf_nscf.sh @@ -58,7 +58,7 @@ fi # Check if this is a DFT+U test (needs occ_mat.txt handling) IS_DFTU=false -if grep -q "dft_plus_u" "${TEST_DIR}/INPUT" 2>/dev/null; then +if grep -q "dft_plus_u" "${TEST_DIR}/INPUT" 2> /dev/null; then IS_DFTU=true echo "DFT+U test detected: will handle occ_mat.txt files" fi @@ -85,7 +85,7 @@ cat "${TEST_DIR}/INPUT" | sed \ -e 's/init_chg\s*file/init_chg atomic/' \ -e '/read_file_dir/d' \ -e '/out_band/d' \ - >"${SCF_INPUT}" + > "${SCF_INPUT}" echo "" echo "--- SCF INPUT ---" @@ -98,7 +98,7 @@ echo "-----------------" echo "" echo "[1/4] Running SCF calculation..." cd "${SCF_DIR}" -mpirun -np ${MPI_NP} "${ABACUS}" >scf.log 2>&1 || { +mpirun -np ${MPI_NP} "${ABACUS}" > scf.log 2>&1 || { echo "ERROR: SCF calculation failed!" echo "Check ${SCF_DIR}/scf.log for details" cd "${TEST_DIR}" @@ -121,7 +121,7 @@ NSCF_SUFFIX=$(grep "suffix" "${TEST_DIR}/INPUT" | awk '{print $2}') NSCF_SUFFIX=${NSCF_SUFFIX:-OUT} # Find charge density file (pattern: *-CHARGE-DENSITY.restart or *-CHARGE-DENSITY) -CHG_FILE=$(find "${SCF_OUT}" -name "*CHARGE-DENSITY*" 2>/dev/null | head -1) +CHG_FILE=$(find "${SCF_OUT}" -name "*CHARGE-DENSITY*" 2> /dev/null | head -1) if [ -z "${CHG_FILE}" ]; then echo "ERROR: No charge density file found in ${SCF_OUT}" exit 1 @@ -138,7 +138,7 @@ echo " Copied to: ${TEST_DIR}/${NSCF_CHG_FILE}" # For DFT+U tests, also copy occ_mat.txt if it exists. # occ_mat.txt is read from read_file_dir (global_readin_dir), same as charge density if [ "${IS_DFTU}" = true ]; then - ONSITE_FILE=$(find "${SCF_OUT}" -name "occ_mat.txt" 2>/dev/null | head -1) + ONSITE_FILE=$(find "${SCF_OUT}" -name "occ_mat.txt" 2> /dev/null | head -1) if [ -n "${ONSITE_FILE}" ]; then cp "${ONSITE_FILE}" "${TEST_DIR}/occ_mat.txt" echo " Copied occ_mat.txt to: ${TEST_DIR}/occ_mat.txt" @@ -151,7 +151,7 @@ fi # Step 4: Run NSCF calculation # ------------------------------------------------------- echo "[3/4] Running NSCF calculation..." -mpirun -np ${MPI_NP} "${ABACUS}" >nscf.log 2>&1 || { +mpirun -np ${MPI_NP} "${ABACUS}" > nscf.log 2>&1 || { echo "ERROR: NSCF calculation failed!" echo "Check ${TEST_DIR}/nscf.log for details" exit 1 @@ -189,17 +189,17 @@ fi if [ -f "${NSF_OUT}/running_scf.log" ] || [ -f "${NSF_OUT}/running_nscf.log" ]; then echo "" echo "NSCF magnetic moments:" - grep -A 1 "TOTAL MAGNETISM" "${NSF_OUT}/running_scf.log" 2>/dev/null | tail -3 || - grep -A 1 "TOTAL MAGNETISM" "${NSF_OUT}/running_nscf.log" 2>/dev/null | tail -3 || + grep -A 1 "TOTAL MAGNETISM" "${NSF_OUT}/running_scf.log" 2> /dev/null | tail -3 || + grep -A 1 "TOTAL MAGNETISM" "${NSF_OUT}/running_nscf.log" 2> /dev/null | tail -3 || echo " (not found)" fi # Print lambda if DeltaSpin -if grep -q "sc_mag_switch" "${TEST_DIR}/INPUT" 2>/dev/null; then +if grep -q "sc_mag_switch" "${TEST_DIR}/INPUT" 2> /dev/null; then echo "" echo "NSCF lambda values:" - grep "lambda" "${NSF_OUT}/running_scf.log" 2>/dev/null | tail -3 || - grep "lambda" "${NSF_OUT}/running_nscf.log" 2>/dev/null | tail -3 || + grep "lambda" "${NSF_OUT}/running_scf.log" 2> /dev/null | tail -3 || + grep "lambda" "${NSF_OUT}/running_nscf.log" 2> /dev/null | tail -3 || echo " (not found)" fi diff --git a/tests/integrate/Autotest.sh b/tests/integrate/Autotest.sh index 601714403b8..4cb54d32c1f 100755 --- a/tests/integrate/Autotest.sh +++ b/tests/integrate/Autotest.sh @@ -53,8 +53,8 @@ mpi_np_flag=${ABACUS_MPIEXEC_NUMPROC_FLAG:--np} # FindMPI may require launcher-specific flags (for example # Open MPI's --allow-run-as-root in a CI container). Keep these as arrays so # every invocation uses the same command assembled by the CMake test setup. -read -r -a mpi_preflags <<<"${ABACUS_MPIEXEC_PREFLAGS:-}" -read -r -a mpi_postflags <<<"${ABACUS_MPIEXEC_POSTFLAGS:-}" +read -r -a mpi_preflags <<< "${ABACUS_MPIEXEC_PREFLAGS:-}" +read -r -a mpi_postflags <<< "${ABACUS_MPIEXEC_POSTFLAGS:-}" threshold_file="threshold" # can specify the threshold for each test case @@ -102,13 +102,13 @@ ncores=$(OMP_NUM_THREADS= OMP_THREAD_LIMIT= nproc) # a wide OpenMP team, because these cases are only a few atoms each. #---------------------------------------------------------- if [ "$njobs" == "auto" ]; then - if [ "$np" -le 0 ] 2>/dev/null; then + if [ "$np" -le 0 ] 2> /dev/null; then njobs=$ncores else njobs=$(expr $ncores / $np) fi fi -if [ "$njobs" -lt 1 ] 2>/dev/null; then +if [ "$njobs" -lt 1 ] 2> /dev/null; then njobs=1 fi @@ -130,14 +130,14 @@ if [ "$njobs" -gt 1 ] && [ "$nt_explicit" == false ]; then nt="" fi if [[ -z "$nt" ]]; then - if [ "$np" -le 0 ] 2>/dev/null; then + if [ "$np" -le 0 ] 2> /dev/null; then # serial build (no MPI launcher): use all cores for OpenMP nt=$(expr $ncores / $njobs) else nt=$(expr $ncores / ${np} / $njobs) fi fi -if [ "$nt" -lt 1 ] 2>/dev/null; then +if [ "$nt" -lt 1 ] 2> /dev/null; then nt=1 fi export OMP_NUM_THREADS=${nt} @@ -346,16 +346,16 @@ run_case() { TIMEFORMAT='[----------] Time elapsed: %R seconds' #parallel test time { - if [ "$np" -le 0 ] 2>/dev/null; then + if [ "$np" -le 0 ] 2> /dev/null; then # serial build: run the binary directly, no MPI launcher. # This lets a serial ABACUS (ENABLE_MPI=OFF, e.g. the native # Windows build) reuse this harness unchanged. - $abacus >log.txt + $abacus > log.txt elif grep -qE '^[[:space:]]*of_ml_gene_data[[:space:]]+1([[:space:]]|$)' INPUT; then # of_ml_gene_data supports single-rank only. - "$mpi_launcher" "$mpi_np_flag" 1 "${mpi_preflags[@]}" "$abacus" "${mpi_postflags[@]}" >log.txt + "$mpi_launcher" "$mpi_np_flag" 1 "${mpi_preflags[@]}" "$abacus" "${mpi_postflags[@]}" > log.txt else - "$mpi_launcher" "$mpi_np_flag" $np "${mpi_preflags[@]}" "$abacus" "${mpi_postflags[@]}" >log.txt + "$mpi_launcher" "$mpi_np_flag" $np "${mpi_preflags[@]}" "$abacus" "${mpi_postflags[@]}" > log.txt fi # if ABACUS failed, print out the error message @@ -400,12 +400,12 @@ run_case() { fi if [ "$sanitize" == true ]; then - echo -e "## Test case ${dir}\n" >>${report} + echo -e "## Test case ${dir}\n" >> ${report} for diagnostic in asan.*; do - echo -e "### On process id ${diagnostic}\n" >>${report} - echo -e "\`\`\`bash" >>${report} - cat ${diagnostic} >>${report} - echo -e "\`\`\`\n" >>${report} + echo -e "### On process id ${diagnostic}\n" >> ${report} + echo -e "\`\`\`bash" >> ${report} + cat ${diagnostic} >> ${report} + echo -e "\`\`\`\n" >> ${report} done fi } @@ -423,7 +423,7 @@ run_case() { echo "FATAL_LIST $fatal_case_list" echo "FATAL_DETAIL $fatal_detail_list" echo "STATUS $case_status" - } >"$result_dir/$dir.res" + } > "$result_dir/$dir.res" } #--------------------------------------------- @@ -431,7 +431,7 @@ run_case() { #--------------------------------------------- test -e $cases_file || (echo "Please specify test cases file by -f option." && exit 1) -which $abacus >/dev/null || (echo "No ABACUS executable was found." && exit 1) +which $abacus > /dev/null || (echo "No ABACUS executable was found." && exit 1) testdir=$(grep -Ev '^[[:space:]]*(#|$)' "$cases_file" | grep -E "$case") failed=0 @@ -451,7 +451,7 @@ trap 'rm -rf "$result_dir"' EXIT if [ "$sanitize" == true ]; then echo "Testing with Address Sanitizer..." mkdir ../html - echo -e "# Address Sanitizer Diagnostics\n" >../html/README.md + echo -e "# Address Sanitizer Diagnostics\n" > ../html/README.md report=$(realpath ../html/README.md) export ASAN_OPTIONS="log_path=asan" fi @@ -469,7 +469,7 @@ else # output is buffered to a file. #----------------------------------------------------- for dir in $testdir; do - (run_case $dir) >"$result_dir/$dir.out" 2>&1 & + (run_case $dir) > "$result_dir/$dir.out" 2>&1 & while [ $(jobs -rp | wc -l) -ge $njobs ]; do sleep 0.2 done @@ -508,7 +508,7 @@ for dir in $testdir; do FATAL_DETAIL) fatal_detail_list+=$rvalue ;; STATUS) case_status+=$rvalue ;; esac - done <"$result_dir/$dir.res" + done < "$result_dir/$dir.res" done if [ "$sanitize" == true ]; then @@ -520,7 +520,7 @@ if [ "$sanitize" == true ]; then fi if [ -z $g ]; then - printf "%b" "$case_status" >test.sum + printf "%b" "$case_status" > test.sum if [[ "$failed" -eq 0 && "$fatal" -eq 0 ]]; then echo -e "\e[0;32m[ PASSED ] \e[0m $ok test cases passed." else diff --git a/tests/integrate/validation_tools/props_basic.sh b/tests/integrate/validation_tools/props_basic.sh index 25529af50cc..620a32d0a2d 100644 --- a/tests/integrate/validation_tools/props_basic.sh +++ b/tests/integrate/validation_tools/props_basic.sh @@ -26,8 +26,8 @@ run_basic_props() { if [ $calculation != "get_wf" ] && [ $calculation != "get_pchg" ] && [ $calculation != "get_s" ] && [ $is_lr == 0 ]; then etot=$(grep "ETOT_" "$running_path" | tail -1 | awk '{print $2}') etotperatom=$(awk 'BEGIN {x='$etot';y='$natom';printf "%.10f\n",x/y}') - echo "etotref $etot" >>$props_result_file - echo "etotperatomref $etotperatom" >>$props_result_file + echo "etotref $etot" >> $props_result_file + echo "etotperatomref $etotperatom" >> $props_result_file fi # Opt-in collinear magnetic-state check. Comparing both moments distinguishes @@ -40,7 +40,7 @@ run_basic_props() { if (!have_total || !have_absolute) exit 1 print total, absolute } - ' "$running_path" >magnetism.out + ' "$running_path" > magnetism.out record_compare_result "$props_result_file" "CompareMagnetism_pass" "magnetism.ref" "magnetism.out" 3 fi @@ -96,24 +96,24 @@ run_basic_props() { print force_x[iat], force_y[iat], force_z[iat] } } - ' "$force_source" >force.txt; then + ' "$force_source" > force.txt; then echo "[ERROR] Failed to extract $natom valid force rows from $force_source" >&2 rm -f force.txt return 1 fi total_force=$(sum_file force.txt) rm force.txt - echo "totalforceref $total_force" >>$props_result_file + echo "totalforceref $total_force" >> $props_result_file fi #------------------------------- # stress information #------------------------------- if ! test -z "$has_stress" && [ $has_stress == 1 ]; then - grep -A6 "TOTAL-STRESS" $running_path | awk 'NF==3' | tail -3 >stress.txt + grep -A6 "TOTAL-STRESS" $running_path | awk 'NF==3' | tail -3 > stress.txt total_stress=$(sum_file stress.txt) rm stress.txt - echo "totalstressref $total_stress" >>$props_result_file + echo "totalstressref $total_stress" >> $props_result_file fi #------------------------------- @@ -121,7 +121,7 @@ run_basic_props() { #------------------------------- if ! test -z "$has_dos" && [ $has_dos == 1 ]; then total_dos=$(cat OUT.autotest/dos*.txt | awk 'END {print}' | awk '{print $3}') - echo "totaldosref $total_dos" >>$props_result_file + echo "totaldosref $total_dos" >> $props_result_file fi #------------------------------- @@ -131,7 +131,7 @@ run_basic_props() { onref=refOnsager.txt oncal=OUT.autotest/Onsager.txt python3 $COMPARE_SCRIPT $onref $oncal 3 -com_type 0 - echo "CompareH_Failed $?" >>$props_result_file + echo "CompareH_Failed $?" >> $props_result_file rm -f je-je.txt Chebycoef fi @@ -145,8 +145,8 @@ run_basic_props_post_ml() { if ! test -z "$imp_sol" && { [ "$imp_sol" = 1 ] || [ "$imp_sol" = 2 ]; }; then esol_el=$(grep E_sol_el $running_path | tail -1 | awk '{print $3}') esol_cav=$(grep E_sol_cav $running_path | tail -1 | awk '{print $3}') - echo "esolelref $esol_el" >>$props_result_file - echo "esolcavref $esol_cav" >>$props_result_file + echo "esolelref $esol_el" >> $props_result_file + echo "esolcavref $esol_cav" >> $props_result_file fi # Solvent-aware SCCS (imp_sol 2, sccs_solvent_radius > 0). With sccs_debug 2 @@ -163,7 +163,7 @@ run_basic_props_post_ml() { echo "Error: solvent-aware SCCS with sccs_debug 2 but no V_FILLED/Bohr3 in $running_path" exit 1 fi - echo "sccs_filled_volumeref $filled_volume" >>$props_result_file + echo "sccs_filled_volumeref $filled_volume" >> $props_result_file fi # out_sol 1: the cubes must exist (the cases set imp_sol 2, or imp_sol 1 with @@ -184,7 +184,7 @@ run_basic_props_post_ml() { done # Append mode retains earlier geometries; compare the final complete frame. integral=$(python3 "$CUBE_TOOL" integrate-last "OUT.autotest/sol_cavity.cube") || return 1 - echo "sol_cavity_integralref $integral" >>$props_result_file + echo "sol_cavity_integralref $integral" >> $props_result_file fi #-------------------------------------------- @@ -192,7 +192,7 @@ run_basic_props_post_ml() { #-------------------------------------------- if [[ "$assume_isolated" == "pcc_0d" || "$assume_isolated" == "pcc_2d" ]]; then epcc=$(grep E_pcc "$running_path" | tail -1 | awk '{print $3}') - echo "epccref $epcc" >>$props_result_file + echo "epccref $epcc" >> $props_result_file fi } @@ -208,16 +208,16 @@ run_basic_props_post_deepks() { pointgroup=$(grep 'POINT GROUP =' $running_path | grep -v 'MAGNETIC' | grep -v 'BvK' | awk '{print $4}') spacegroup=$(grep 'SPACE GROUP =' $running_path | grep -v 'MAGNETIC' | grep -v 'BvK' | awk '{print $7}') nksibz=$(grep 'Number of irreducible k-points' $running_path | awk '{print $6}') - echo "pointgroupref $pointgroup" >>$props_result_file - echo "spacegroupref $spacegroup" >>$props_result_file - echo "nksibzref $nksibz" >>$props_result_file + echo "pointgroupref $pointgroup" >> $props_result_file + echo "spacegroupref $spacegroup" >> $props_result_file + echo "nksibzref $nksibz" >> $props_result_file # (nspin=4) magnetic (Shubnikov) group analysis: capture the space-group-consistent # magnetic point group. Only printed when the group is actually reduced (magnetic); # non-magnetic nspin=4 does not print it, so the capture is skipped when empty. if ! test -z "$nspin" && [ $nspin == 4 ]; then magpointgroup=$(grep 'MAGNETIC POINT GROUP IN SPACE GROUP' $running_path | awk '{print $NF}') if ! test -z "$magpointgroup"; then - echo "magpointgroupref $magpointgroup" >>$props_result_file + echo "magpointgroupref $magpointgroup" >> $props_result_file fi fi fi @@ -237,7 +237,7 @@ run_basic_props_post_rdmft() { fi # Find all running*.log files in OUT.autotest directory - log_files=$(ls OUT.autotest/running*.log 2>/dev/null) + log_files=$(ls OUT.autotest/running*.log 2> /dev/null) if [ -z "$log_files" ]; then echo "Error: No running*.log files found in OUT.autotest/" @@ -256,10 +256,10 @@ run_basic_props_post_rdmft() { if $all_valid; then echo "All log filenames contain 'running_${calculation}_' - validation passed" - echo "log_filename_validation 1" >>$props_result_file + echo "log_filename_validation 1" >> $props_result_file else echo "Error: Some log filenames do not contain 'running_${calculation}_'" - echo "log_filename_validation 0" >>$props_result_file + echo "log_filename_validation 0" >> $props_result_file exit 1 fi fi diff --git a/tests/integrate/validation_tools/props_common.sh b/tests/integrate/validation_tools/props_common.sh index 805ea7f9def..bd90039015f 100644 --- a/tests/integrate/validation_tools/props_common.sh +++ b/tests/integrate/validation_tools/props_common.sh @@ -66,12 +66,12 @@ record_compare_result() { use_abs=${6:-0} if [ ! -f "$ref_file" ] || [ ! -f "$cal_file" ]; then - echo "$result_key 1" >>"$result_file" + echo "$result_key 1" >> "$result_file" return fi python3 $COMPARE_SCRIPT "$ref_file" "$cal_file" "$accuracy" -abs "$use_abs" - echo "$result_key $?" >>"$result_file" + echo "$result_key $?" >> "$result_file" } # props_init RESULT_FILE @@ -86,7 +86,7 @@ props_init() { # the command will ignore lines starting with # calculation=$(grep calculation INPUT | grep -v '^#' | awk '{print $2}' | sed s/[[:space:]]//g) - running_path=$(ls OUT.autotest/running_${calculation}*.log 2>/dev/null | head -1) + running_path=$(ls OUT.autotest/running_${calculation}*.log 2> /dev/null | head -1) if [ -z "$running_path" ]; then echo "Error: No running log file found for calculation=$calculation in OUT.autotest/" exit 1 @@ -164,5 +164,5 @@ props_init() { props_finalize() { props_result_file=$1 ttot=$(grep $word_total_time $running_path | awk '{print $3}') - echo "totaltimeref $ttot" >>$props_result_file + echo "totaltimeref $ttot" >> $props_result_file } diff --git a/tests/integrate/validation_tools/props_cube.sh b/tests/integrate/validation_tools/props_cube.sh index 7b599439092..5a2efe7e585 100644 --- a/tests/integrate/validation_tools/props_cube.sh +++ b/tests/integrate/validation_tools/props_cube.sh @@ -23,7 +23,7 @@ run_cube_pot_props() { pot1ref=pot.cube.ref pot1cal=OUT.autotest/pot.cube python3 $COMPARE_SCRIPT $pot1ref $pot1cal 3 - echo "ComparePot1_pass $?" >>$props_result_file + echo "ComparePot1_pass $?" >> $props_result_file fi #------------------------------- @@ -33,7 +33,7 @@ run_cube_pot_props() { pot1ref=potes.cube.ref pot1cal=OUT.autotest/potes.cube python3 $COMPARE_SCRIPT $pot1ref $pot1cal 8 - echo "ComparePot_pass $?" >>$props_result_file + echo "ComparePot_pass $?" >> $props_result_file fi #------------------------------- @@ -44,7 +44,7 @@ run_cube_pot_props() { elf1ref=elftot.cube.ref elf1cal=OUT.autotest/elftot.cube python3 $COMPARE_SCRIPT $elf1ref $elf1cal 3 - echo "ComparePot1_pass $?" >>$props_result_file + echo "ComparePot1_pass $?" >> $props_result_file fi } @@ -66,7 +66,7 @@ run_cube_props() { if ! test -z "$has_scan" && [ $has_scan == "scan" ] && ! test -z "$out_chg" && [ $out_chg == 1 ]; then python3 $COMPARE_SCRIPT tau.cube.ref OUT.autotest/tau.cube 8 - echo "tau.cube_pass $?" >>$props_result_file + echo "tau.cube_pass $?" >> $props_result_file fi #--------------------------------------- @@ -76,7 +76,7 @@ run_cube_props() { if ! test -z "$has_ldos" && [ $has_ldos == 1 ]; then stm_bias=$(get_input_key_value "stm_bias" "OUT.autotest/INPUT.info") python3 $COMPARE_SCRIPT ldos.cube.ref OUT.autotest/ldos_"$stm_bias"ev.cube 8 - echo "ldos.cube_pass $?" >>$props_result_file + echo "ldos.cube_pass $?" >> $props_result_file fi #--------------------------------------- @@ -95,7 +95,7 @@ run_cube_props() { variance_wfc_r=$(sed -n "13,$"p OUT.autotest/wfc_realspace/wfc_realspace_0_$band | awk -v all=$allgrid 'BEGIN {sumall=0} {for(i=1;i<=NF;i++) {sumall+=($i-1)*($i-1)}}\ END {printf"%.5f",(sumall/all)}') - echo "variance_wfc_r_0_$band $variance_wfc_r" >>$props_result_file + echo "variance_wfc_r_0_$band $variance_wfc_r" >> $props_result_file else echo "Can't find file OUT.autotest/wfc_realspace/wfc_realspace_0_$band" exit 1 @@ -138,7 +138,7 @@ run_cube_props() { if(sqrt($i*$i)>max) {max=sqrt($i*$i)} } } - }' "$full_path" >>"$props_result_file" + }' "$full_path" >> "$props_result_file" fi #-------------------------------------------- @@ -150,7 +150,7 @@ run_cube_props() { if ! test -z "$gamma_only" && [ $gamma_only == 1 ]; then wfc_cal=OUT.autotest/wf_nao.txt wfc_ref=wf_nao.txt.ref - else # multi-k point case + else # multi-k point case if ! test -z "$out_app_flag" && [ $out_app_flag == 0 ]; then # mode 0 overwrites one fixed file at every write, so the file holds # the last written step; the reference below records that step (3). @@ -201,8 +201,8 @@ run_cube_props() { # downstream comparison. if [ "$wfc_prep_ok" -ne 1 ]; then wfc_pass=1 - elif ! sed '/^[[:space:]]*#/d' "$wfc_cal" >"$wfc_cal_nohdr" \ - || ! sed '/^[[:space:]]*#/d' "$wfc_ref" >"$wfc_ref_nohdr"; then + elif ! sed '/^[[:space:]]*#/d' "$wfc_cal" > "$wfc_cal_nohdr" || + ! sed '/^[[:space:]]*#/d' "$wfc_ref" > "$wfc_ref_nohdr"; then echo "Error: failed to strip comment lines from $wfc_cal or $wfc_ref" wfc_pass=1 else @@ -210,7 +210,7 @@ run_cube_props() { wfc_pass=$? fi rm -f "$wfc_cal_nohdr" "$wfc_ref_nohdr" - echo "Compare_wfc_lcao_pass $wfc_pass" >>$props_result_file + echo "Compare_wfc_lcao_pass $wfc_pass" >> $props_result_file fi } @@ -222,7 +222,7 @@ run_cube_tail_props() { #-------------------------------------------- if ! test -z "$out_mul" && [ $out_mul == 1 ]; then python3 $COMPARE_SCRIPT mulliken.txt.ref OUT.autotest/mulliken.txt 3 - echo "Compare_mulliken_pass $?" >>$props_result_file + echo "Compare_mulliken_pass $?" >> $props_result_file fi #-------------------------------------------- @@ -243,11 +243,11 @@ run_cube_tail_props() { pchg_cube=${pchg_ref%.ref} pchg_key=$(sanitize_result_key "${pchg_cube}_compare") if [ ! -f "OUT.autotest/$pchg_cube" ]; then - echo "$pchg_key 1" >>"$props_result_file" + echo "$pchg_key 1" >> "$props_result_file" continue fi python3 "$COMPARE_SCRIPT" "$pchg_ref" "OUT.autotest/$pchg_cube" -tol "$pchg_tol" - echo "$pchg_key $?" >>"$props_result_file" + echo "$pchg_key $?" >> "$props_result_file" done shopt -u nullglob @@ -281,7 +281,7 @@ run_cube_tail_props() { continue fi total_chg=$(python3 "$CUBE_TOOL" integrate "OUT.autotest/$cube") - echo "$cube $total_chg" >>$props_result_file + echo "$cube $total_chg" >> $props_result_file done fi @@ -311,8 +311,8 @@ run_cube_tail_props() { if fingerprint=$(python3 "$CUBE_TOOL" fingerprint-wfc "${fingerprint_args[@]}"); then while read -r metric value; do - echo "${result_prefix}_${metric} $value" >>"$props_result_file" - done <<<"$fingerprint" + echo "${result_prefix}_${metric} $value" >> "$props_result_file" + done <<< "$fingerprint" else echo "Error: Failed to generate wavefunction fingerprint for $state_prefix" exit 1 @@ -327,9 +327,9 @@ run_cube_tail_props() { if [ "$nspin" = "4" ] && { [ "$if_separate_k" = "1" ] || [ "$if_separate_k" = "true" ]; } && [ -n "$out_wfc_norm" ] && [ -n "$out_wfc_re_im" ] && [ -n "$out_pchg" ]; then if python3 "$CUBE_TOOL" check-spinor OUT.autotest; then - echo "pw_spinor_cube_identity 0" >>"$props_result_file" + echo "pw_spinor_cube_identity 0" >> "$props_result_file" else - echo "pw_spinor_cube_identity 1" >>"$props_result_file" + echo "pw_spinor_cube_identity 1" >> "$props_result_file" fi fi diff --git a/tests/integrate/validation_tools/props_deepks.sh b/tests/integrate/validation_tools/props_deepks.sh index ae3d8a69b14..dd9f51e83ae 100644 --- a/tests/integrate/validation_tools/props_deepks.sh +++ b/tests/integrate/validation_tools/props_deepks.sh @@ -88,7 +88,7 @@ process_npy() { fi done - echo "$output_name $total" >>$6 + echo "$output_name $total" >> $6 } # Process a group of label outputs @@ -151,10 +151,10 @@ run_deepks_props() { #--------------------------------------------------------------------------- if ! test -z "$deepks_scf" && [ $deepks_scf == 1 ]; then # Process descriptor data - sed '/n_des/d' OUT.autotest/deepks_desc.dat >des_tmp.txt + sed '/n_des/d' OUT.autotest/deepks_desc.dat > des_tmp.txt total_des=$(sum_file des_tmp.txt 5) rm des_tmp.txt - echo "deepks_desc $total_des" >>$props_result_file + echo "deepks_desc $total_des" >> $props_result_file process_npy "single" "abs" "dm_eig" "" "deepks_dm_eig" "$props_result_file" fi @@ -182,10 +182,10 @@ run_deepks_props() { if ! test -z "$deepks_v_delta" && [ $deepks_v_delta -lt 0 ]; then hr_pass=0 python3 $COMPARE_SCRIPT "deepks_hrtot.csr.ref" "OUT.autotest/deepks_hrtot.csr" 8 || hr_pass=$? - echo "deepks_hr_label_pass $hr_pass" >>$props_result_file + echo "deepks_hr_label_pass $hr_pass" >> $props_result_file hrdelta_pass=0 python3 $COMPARE_SCRIPT "deepks_hrdelta.csr.ref" "OUT.autotest/deepks_hrdelta.csr" 8 || hrdelta_pass=$? - echo "deepks_vdelta_r_pass $hrdelta_pass" >>$props_result_file + echo "deepks_vdelta_r_pass $hrdelta_pass" >> $props_result_file # For deepks_v_delta = -1 if [ $deepks_v_delta -eq -1 ]; then process_npy "single" "abs" "vdrpre" "" "deepks_vdrp" "$props_result_file" diff --git a/tests/integrate/validation_tools/props_lr.sh b/tests/integrate/validation_tools/props_lr.sh index bd754fc71ea..921f59965e7 100644 --- a/tests/integrate/validation_tools/props_lr.sh +++ b/tests/integrate/validation_tools/props_lr.sh @@ -8,9 +8,9 @@ run_lr_tracking_props() { return 1 fi if python3 "$PROPS_SCRIPT_DIR/excited_state_check.py" "$running_path" state_tracking.ref; then - echo "CompareStateTracking_pass 0" >>"$props_result_file" + echo "CompareStateTracking_pass 0" >> "$props_result_file" else - echo "CompareStateTracking_pass 1" >>"$props_result_file" + echo "CompareStateTracking_pass 1" >> "$props_result_file" fi return 0 } @@ -20,11 +20,11 @@ run_lr_tracking_props() { run_lr_force_props() { # LR prints a separate force table for each excited state and spin channel. if [ $is_lr == 1 ] && ! test -z "$has_force" && [ $has_force == 1 ]; then - awk '/Forces \(-gradients\) of each excited state/{flag=1; next} flag{for(i=1;i<=NF;i++) if($i=="force"){print $(i+1),$(i+2),$(i+3)}}' "$running_path" >lr_force.txt + awk '/Forces \(-gradients\) of each excited state/{flag=1; next} flag{for(i=1;i<=NF;i++) if($i=="force"){print $(i+1),$(i+2),$(i+3)}}' "$running_path" > lr_force.txt # Accumulate all components before rounding the LR force total. total_lr_force=$(awk '{for (i=1; i<=NF; ++i) sum += sqrt($i*$i)} END {printf "%.10f\n", sum}' lr_force.txt) rm lr_force.txt - echo "totalforceref $total_lr_force" >>$props_result_file + echo "totalforceref $total_lr_force" >> $props_result_file # Keep the historical total, and independently check signed, labelled components. local force_tolerance=0.000001 if [ -f threshold ]; then @@ -35,9 +35,9 @@ run_lr_force_props() { fi fi if python3 "$PROPS_SCRIPT_DIR/lr_force_check.py" "$running_path" lr_force.ref "$force_tolerance"; then - echo "CompareLRForce_pass 0" >>"$props_result_file" + echo "CompareLRForce_pass 0" >> "$props_result_file" else - echo "CompareLRForce_pass 1" >>"$props_result_file" + echo "CompareLRForce_pass 1" >> "$props_result_file" fi fi diff --git a/tests/integrate/validation_tools/props_mat.sh b/tests/integrate/validation_tools/props_mat.sh index abe08b60683..1227307440a 100644 --- a/tests/integrate/validation_tools/props_mat.sh +++ b/tests/integrate/validation_tools/props_mat.sh @@ -60,7 +60,7 @@ run_mat_dm1_props() { dm1ref=dmr_nao.csr.ref dm1cal=OUT.autotest/dmr_nao.csr python3 $COMPARE_SCRIPT $dm1ref $dm1cal 8 - echo "CompareDM1_pass $?" >>$props_result_file + echo "CompareDM1_pass $?" >> $props_result_file fi } @@ -75,7 +75,7 @@ run_mat_props() { sref=sr_nao.csr.ref scal=OUT.autotest/sr_nao.csr python3 $COMPARE_SCRIPT $sref $scal 8 - echo "CompareS_pass $?" >>$props_result_file + echo "CompareS_pass $?" >> $props_result_file fi #------------------------------- @@ -86,7 +86,7 @@ run_mat_props() { orbref=refNaoTxt orbcal=OUT.autotest/nao.txt python3 $COMPARE_SCRIPT $orbref $orbcal 8 - echo "CompareOrb_pass $?" >>$props_result_file + echo "CompareOrb_pass $?" >> $props_result_file fi #------------------------------- @@ -103,13 +103,13 @@ run_mat_props() { # AMN is covariant under the band gauge (A -> U^dagger A), so compare # the gauge-invariant Gram matrix A^dagger A instead of the raw elements. python3 $COMPARE_AMN_SCRIPT $amnref $amncal - echo "CompareAMN_pass $?" >>$props_result_file + echo "CompareAMN_pass $?" >> $props_result_file # MMN is covariant as M(k,b) -> U_k^dagger M(k,b) U_{k+b}; CPU and GPU # differ by per-band phases, under which |M_mn| is invariant. python3 $COMPARE_MMN_SCRIPT $mmnref $mmncal - echo "CompareMMN_pass $?" >>$props_result_file + echo "CompareMMN_pass $?" >> $props_result_file python3 $COMPARE_SCRIPT $eigref $eigcal 8 - echo "CompareEIG_pass $?" >>$props_result_file + echo "CompareEIG_pass $?" >> $props_result_file fi #------------------------------- @@ -117,7 +117,7 @@ run_mat_props() { # echo total_dos # echo $has_band #------------------------------- - if ! test -z "$has_band" && [ $has_band == 1 ]; then + if ! test -z "$has_band" && [ $has_band == 1 ]; then bandref=band.txt.ref bandcal=OUT.autotest/band.txt # Every ionic step in band.txt is preceded by a provenance comment block @@ -127,10 +127,10 @@ run_mat_props() { # substitution would hand CompareFile.py an empty stream and pass silently. if ! test -f "$bandref" || ! test -f "$bandcal"; then echo "Error: can not find file $bandref or $bandcal" - echo "CompareBand_pass 1" >>$props_result_file + echo "CompareBand_pass 1" >> $props_result_file else python3 $COMPARE_SCRIPT <(sed '/^[[:space:]]*#/d' "$bandref") <(sed '/^[[:space:]]*#/d' "$bandcal") 8 - echo "CompareBand_pass $?" >>$props_result_file + echo "CompareBand_pass $?" >> $props_result_file fi fi @@ -151,13 +151,13 @@ run_mat_props() { scal=OUT.autotest/sk_nao.txt # Compare Hamiltonian matrix for spin 1 python3 $COMPARE_SCRIPT $h1ref $h1cal 6 - echo "CompareH1_pass $?" >>$props_result_file + echo "CompareH1_pass $?" >> $props_result_file # Compare Hamiltonian matrix for spin 2 python3 $COMPARE_SCRIPT $h2ref $h2cal 6 - echo "CompareH2_pass $?" >>$props_result_file + echo "CompareH2_pass $?" >> $props_result_file # Compare overlap matrix python3 $COMPARE_SCRIPT $sref $scal 8 - echo "CompareS_pass $?" >>$props_result_file + echo "CompareS_pass $?" >> $props_result_file elif ! test -z "$nspin" && [ $nspin == 4 ]; then # nspin=4 : do nothing, only matching condition without any operation true @@ -169,10 +169,10 @@ run_mat_props() { scal=OUT.autotest/sk_nao.txt # Compare Hamiltonian matrix python3 $COMPARE_SCRIPT $href $hcal 6 - echo "CompareH_pass $?" >>$props_result_file + echo "CompareH_pass $?" >> $props_result_file # Compare overlap matrix python3 $COMPARE_SCRIPT $sref $scal 8 - echo "CompareS_pass $?" >>$props_result_file + echo "CompareS_pass $?" >> $props_result_file fi else # ========== Multiple k-points calculation ========== @@ -186,13 +186,13 @@ run_mat_props() { scal=OUT.autotest/sk2_nao.txt # Compare Hamiltonian matrix for spin 1 python3 $COMPARE_SCRIPT $h1ref $h1cal 6 - echo "CompareH1_pass $?" >>$props_result_file + echo "CompareH1_pass $?" >> $props_result_file # Compare Hamiltonian matrix for spin 2 python3 $COMPARE_SCRIPT $h2ref $h2cal 6 - echo "CompareH2_pass $?" >>$props_result_file + echo "CompareH2_pass $?" >> $props_result_file # Compare overlap matrix python3 $COMPARE_SCRIPT $sref $scal 8 - echo "CompareS_pass $?" >>$props_result_file + echo "CompareS_pass $?" >> $props_result_file elif ! test -z "$nspin" && [ $nspin == 4 ]; then # nspin=4 : do nothing, only matching condition without any operation true @@ -204,10 +204,10 @@ run_mat_props() { scal=OUT.autotest/sk2_nao.txt # Compare Hamiltonian matrix python3 $COMPARE_SCRIPT $href $hcal 6 - echo "CompareH_pass $?" >>$props_result_file + echo "CompareH_pass $?" >> $props_result_file # Compare overlap matrix python3 $COMPARE_SCRIPT $sref $scal 8 - echo "CompareS_pass $?" >>$props_result_file + echo "CompareS_pass $?" >> $props_result_file fi fi elif ! test -z "$has_hs" && [ $has_hs == 2 ]; then @@ -215,15 +215,15 @@ run_mat_props() { if ! test -z "$gamma_only" && [ $gamma_only == 1 ]; then HSK_TEXT_REFERENCE_DIR="../scf_out_hk" python3 $HSK_BINARY_COMPARE OUT.autotest/hk_nao.dat "$HSK_TEXT_REFERENCE_DIR/hk_nao.txt.ref" real 3 - echo "CompareH_pass $?" >>$props_result_file + echo "CompareH_pass $?" >> $props_result_file python3 $HSK_BINARY_COMPARE OUT.autotest/sk_nao.dat "$HSK_TEXT_REFERENCE_DIR/sk_nao.txt.ref" real 3 - echo "CompareS_pass $?" >>$props_result_file + echo "CompareS_pass $?" >> $props_result_file else HSK_TEXT_REFERENCE_DIR="../scf_out_hsk" python3 $HSK_BINARY_COMPARE OUT.autotest/hk2_nao.dat "$HSK_TEXT_REFERENCE_DIR/hk2_nao.txt.ref" complex 3 - echo "CompareH_pass $?" >>$props_result_file + echo "CompareH_pass $?" >> $props_result_file python3 $HSK_BINARY_COMPARE OUT.autotest/sk2_nao.dat "$HSK_TEXT_REFERENCE_DIR/sk2_nao.txt.ref" complex 3 - echo "CompareS_pass $?" >>$props_result_file + echo "CompareS_pass $?" >> $props_result_file fi fi @@ -241,9 +241,9 @@ run_mat_props() { oeref=eband_vxc.ref oecal=OUT.autotest/eband_vxc.txt python3 $COMPARE_SCRIPT $xcref $xccal 4 - echo "CompareVXC_pass $?" >>$props_result_file + echo "CompareVXC_pass $?" >> $props_result_file compare_eband_energy $oeref $oecal 5 - echo "CompareOrbXC_pass $?" >>$props_result_file + echo "CompareOrbXC_pass $?" >> $props_result_file fi #-------------------------------- @@ -253,7 +253,7 @@ run_mat_props() { xc2ref=Vxc_R_spin0.ref xc2cal=OUT.autotest/Vxc_R_spin0.csr python3 $COMPARE_SCRIPT $xc2ref $xc2cal 8 - echo "CompareVXC_R_pass $?" >>$props_result_file + echo "CompareVXC_R_pass $?" >> $props_result_file fi #-------------------------------- @@ -261,13 +261,13 @@ run_mat_props() { #-------------------------------- if ! test -z "$has_eband_separate" && [ $has_eband_separate == 1 ]; then compare_eband_energy eband_kin.ref OUT.autotest/eband_kin.txt - echo "CompareOrbKinetic_pass $?" >>$props_result_file + echo "CompareOrbKinetic_pass $?" >> $props_result_file compare_eband_energy eband_vl.ref OUT.autotest/eband_vl.txt - echo "CompareOrbVL_pass $?" >>$props_result_file + echo "CompareOrbVL_pass $?" >> $props_result_file compare_eband_energy eband_vnl.ref OUT.autotest/eband_vnl.txt - echo "CompareOrbVNL_pass $?" >>$props_result_file + echo "CompareOrbVNL_pass $?" >> $props_result_file compare_eband_energy eband_hart.ref OUT.autotest/eband_hart.txt - echo "CompareOrbVHartree_pass $?" >>$props_result_file + echo "CompareOrbVHartree_pass $?" >> $props_result_file fi #----------------------------------- @@ -276,23 +276,23 @@ run_mat_props() { #echo $has_hs2 if ! test -z "$has_hs2" && [ $has_hs2 == 1 ]; then compare_hr_csr hrs1_nao.csr.ref OUT.autotest/hrs1_nao.csr - echo "CompareHR_pass $?" >>$props_result_file + echo "CompareHR_pass $?" >> $props_result_file if ! test -z "$nspin" && [ "$nspin" -eq 2 ]; then compare_hr_csr hrs2_nao.csr.ref OUT.autotest/hrs2_nao.csr - echo "CompareHR2_pass $?" >>$props_result_file + echo "CompareHR2_pass $?" >> $props_result_file fi python3 $COMPARE_SCRIPT sr_nao.csr.ref OUT.autotest/sr_nao.csr 8 - echo "CompareSR_pass $?" >>$props_result_file + echo "CompareSR_pass $?" >> $props_result_file elif ! test -z "$has_hs2" && [ "$has_hs2" == 2 ]; then HSR_BINARY_COMPARE="$PROPS_TOOLS_DIR/compare_hsr_binary.py" python3 $HSR_BINARY_COMPARE OUT.autotest/hrs1_nao.dat hrs1_nao.csr.ref real 4 - echo "CompareHR_pass $?" >>$props_result_file + echo "CompareHR_pass $?" >> $props_result_file if ! test -z "$nspin" && [ "$nspin" -eq 2 ]; then python3 $HSR_BINARY_COMPARE OUT.autotest/hrs2_nao.dat hrs2_nao.csr.ref real 4 - echo "CompareHR2_pass $?" >>$props_result_file + echo "CompareHR2_pass $?" >> $props_result_file fi python3 $HSR_BINARY_COMPARE OUT.autotest/sr_nao.dat sr_nao.csr.ref real 4 - echo "CompareSR_pass $?" >>$props_result_file + echo "CompareSR_pass $?" >> $props_result_file fi #----------------------------------- @@ -300,19 +300,19 @@ run_mat_props() { #----------------------------------- if { ! test -z "$out_hsr" && [ "$out_hsr" == 3 ]; } || { ! test -z "$out_hsr_npz" && [ "$out_hsr_npz" == 1 ]; }; then test -f OUT.autotest/sr_nao.npz - echo "OutputSRNPZ_pass $?" >>$props_result_file + echo "OutputSRNPZ_pass $?" >> $props_result_file fi if { ! test -z "$out_hr_npz" && [ "$out_hr_npz" == 1 ]; } || { ! test -z "$out_hsr" && [ "$out_hsr" == 3 ]; } || { ! test -z "$out_hsr_npz" && [ "$out_hsr_npz" == 1 ]; }; then test -f OUT.autotest/hrs1_nao.npz - echo "OutputHRNPZ_pass $?" >>$props_result_file + echo "OutputHRNPZ_pass $?" >> $props_result_file fi if ! test -z "$out_dm_npz" && [ "$out_dm_npz" == 1 ]; then test -f OUT.autotest/output_DM0.npz - echo "OutputDMNPZ_pass $?" >>$props_result_file + echo "OutputDMNPZ_pass $?" >> $props_result_file fi #----------------------------------- @@ -321,7 +321,7 @@ run_mat_props() { #echo $has_mat_r if ! test -z "$has_mat_r" && [ $has_mat_r == 1 ]; then python3 $COMPARE_SCRIPT rr_nao.txt.ref OUT.autotest/rr_nao.txt 8 - echo "ComparerR_pass $?" >>$props_result_file + echo "ComparerR_pass $?" >> $props_result_file fi #----------------------------------- @@ -330,7 +330,7 @@ run_mat_props() { #echo $has_mat_t if ! test -z "$has_mat_t" && [ $has_mat_t == 1 ]; then python3 $COMPARE_SCRIPT tr_nao.csr.ref OUT.autotest/tr_nao.csr 8 - echo "ComparerTR_pass $?" >>$props_result_file + echo "ComparerTR_pass $?" >> $props_result_file fi #----------------------------------- @@ -339,7 +339,7 @@ run_mat_props() { #echo $has_mat_syns if ! test -z "$has_mat_syns" && [ $has_mat_syns == 1 ]; then python3 $COMPARE_SCRIPT syns_nao.csr.ref OUT.autotest/syns_nao.csr 8 - echo "CompareSYNS_pass $?" >>$props_result_file + echo "CompareSYNS_pass $?" >> $props_result_file fi #----------------------------------- @@ -348,11 +348,11 @@ run_mat_props() { #echo $has_mat_dh if ! test -z "$has_mat_dh" && [ $has_mat_dh == 1 ] && [ $gamma_only != 1 ]; then python3 $COMPARE_SCRIPT dhrxs1_nao.csr.ref OUT.autotest/dhrxs1_nao.csr 8 - echo "ComparerdHRx_pass $?" >>$props_result_file + echo "ComparerdHRx_pass $?" >> $props_result_file python3 $COMPARE_SCRIPT dhrys1_nao.csr.ref OUT.autotest/dhrys1_nao.csr 8 - echo "ComparerdHRy_pass $?" >>$props_result_file + echo "ComparerdHRy_pass $?" >> $props_result_file python3 $COMPARE_SCRIPT dhrzs1_nao.csr.ref OUT.autotest/dhrzs1_nao.csr 8 - echo "ComparerdHRz_pass $?" >>$props_result_file + echo "ComparerdHRz_pass $?" >> $props_result_file fi #----------------------------------- @@ -380,7 +380,7 @@ run_mat_dm_props() { dmfile=OUT.autotest/dm_nao.txt dmref=dm_nao.txt.ref python3 $COMPARE_SCRIPT $dmref $dmfile 5 - echo "DM_different $?" >>$props_result_file + echo "DM_different $?" >> $props_result_file fi } diff --git a/tests/integrate/validation_tools/props_ml.sh b/tests/integrate/validation_tools/props_ml.sh index 3b9bbada15b..5f78fa500a4 100644 --- a/tests/integrate/validation_tools/props_ml.sh +++ b/tests/integrate/validation_tools/props_ml.sh @@ -19,7 +19,7 @@ run_ml_descriptor_props() { #-------------------------------------------- descriptor_dir="OUT.autotest/MLKEDF_Descriptors" if [ -d "$descriptor_dir" ]; then - python3 $COLLECT_NPY_MEANS "$descriptor_dir" >>"$props_result_file" + python3 $COLLECT_NPY_MEANS "$descriptor_dir" >> "$props_result_file" fi } @@ -31,7 +31,7 @@ run_ml_rpa_props() { #-------------------------------------------- if ! test -z "$run_rpa" && [ $run_rpa == 1 ]; then Etot_without_rpa=$(grep Etot_without_rpa log.txt | awk 'BEGIN{FS=":"} {print $2}') - echo "Etot_without_rpa $Etot_without_rpa" >>$props_result_file + echo "Etot_without_rpa $Etot_without_rpa" >> $props_result_file rpa_outdir=$(get_input_key_value "rpa_outdir" "INPUT") if [ -z "$rpa_outdir" ]; then rpa_outdir="./OUT.librpa" @@ -64,9 +64,9 @@ run_ml_lr_props() { lr_files=(OUT.autotest/trans_analysis_*_tda.dat) if grep -q '^ LR excitation energies:' "$running_path"; then # abs_gauge=none retains an energy-only report; ignore stale optical files. - awk '/^ LR excitation energies:/{p=1; next} /End LR excitation energies/{p=0} p && /^[[:space:]]*[0-9]+[[:space:]]/{printf "excitationenergyref%d %.6f\n", ++n, $2}' "$running_path" >>"$props_result_file" + awk '/^ LR excitation energies:/{p=1; next} /End LR excitation energies/{p=0} p && /^[[:space:]]*[0-9]+[[:space:]]/{printf "excitationenergyref%d %.6f\n", ++n, $2}' "$running_path" >> "$props_result_file" elif [ ${#lr_files[@]} -gt 0 ]; then - cat "${lr_files[@]}" | awk '/Excitation Energy/{p=1; next} p && /^[[:space:]]*[0-9]+[[:space:]]/{printf "excitationenergyref%d %.6f\n", ++n, $2} /Occupied orbital/{p=0}' >>$props_result_file + cat "${lr_files[@]}" | awk '/Excitation Energy/{p=1; next} p && /^[[:space:]]*[0-9]+[[:space:]]/{printf "excitationenergyref%d %.6f\n", ++n, $2} /Occupied orbital/{p=0}' >> $props_result_file fi shopt -u nullglob fi @@ -79,37 +79,37 @@ run_ml_rdmft_props() { # Check RDMFT method #-------------------------------------------- if ! test -z "$rdmft" && [[ $rdmft == 1 ]]; then - echo "" >>$props_result_file - echo "The following energy units are in Rydberg:" >>$props_result_file + echo "" >> $props_result_file + echo "The following energy units are in Rydberg:" >> $props_result_file E_TV_RDMFT=$(grep "E_TV_RDMFT" "$running_path" | tail -1 | awk '{print $2}') - echo "E_TV_RDMFT_ref $E_TV_RDMFT" >>$props_result_file + echo "E_TV_RDMFT_ref $E_TV_RDMFT" >> $props_result_file E_hartree_RDMFT=$(grep "E_hartree_RDMFT" "$running_path" | tail -1 | awk '{print $2}') - echo "E_hartree_RDMFT_ref $E_hartree_RDMFT" >>$props_result_file + echo "E_hartree_RDMFT_ref $E_hartree_RDMFT" >> $props_result_file Exc_cwp22_RDMFT=$(grep "Exc_cwp22_RDMFT" "$running_path" | tail -1 | awk '{print $2}') - echo "Exc_cwp22_RDMFT_ref $Exc_cwp22_RDMFT" >>$props_result_file + echo "Exc_cwp22_RDMFT_ref $Exc_cwp22_RDMFT" >> $props_result_file E_Ewald=$(grep "E_Ewald" "$running_path" | tail -1 | awk '{print $2}') - echo "E_Ewald_ref $E_Ewald" >>$props_result_file + echo "E_Ewald_ref $E_Ewald" >> $props_result_file E_entropy=$(grep "E_entropy(-TS)" "$running_path" | tail -1 | awk '{print $2}') - echo "E_entropy_ref $E_entropy" >>$props_result_file + echo "E_entropy_ref $E_entropy" >> $props_result_file E_descf=$(grep "E_descf" "$running_path" | tail -1 | awk '{print $2}') - echo "E_descf_ref $E_descf" >>$props_result_file + echo "E_descf_ref $E_descf" >> $props_result_file Etotal_RDMFT=$(grep "Etotal_RDMFT" "$running_path" | tail -1 | awk '{print $2}') - echo "Etotal_RDMFT_ref $Etotal_RDMFT" >>$props_result_file + echo "Etotal_RDMFT_ref $Etotal_RDMFT" >> $props_result_file Exc_ksdft=$(grep "Exc_ksdft" "$running_path" | tail -1 | awk '{print $2}') - echo "Exc_ksdft_ref $Exc_ksdft" >>$props_result_file + echo "Exc_ksdft_ref $Exc_ksdft" >> $props_result_file E_exx_ksdft=$(grep "E_exx_ksdft" "$running_path" | tail -1 | awk '{print $2}') - echo "E_exx_ksdft_ref $E_exx_ksdft" >>$props_result_file + echo "E_exx_ksdft_ref $E_exx_ksdft" >> $props_result_file - echo "" >>$props_result_file + echo "" >> $props_result_file fi } diff --git a/tests/integrate/validation_tools/props_tddft.sh b/tests/integrate/validation_tools/props_tddft.sh index e9af976d15a..8f730ddce43 100644 --- a/tests/integrate/validation_tools/props_tddft.sh +++ b/tests/integrate/validation_tools/props_tddft.sh @@ -33,7 +33,7 @@ run_tddft_props() { fi fi python3 "$COMPARE_SCRIPT" "$current1ref" "$current1cal" -tol "$current_tol" - echo "CompareCurrent_pass $?" >>$props_result_file + echo "CompareCurrent_pass $?" >> $props_result_file fi #-------------------------------------------- @@ -42,7 +42,7 @@ run_tddft_props() { if ! test -z "$out_efield" && [ "$out_efield" == 1 ]; then efield_refs=(efield_*.txt.ref) if [ ! -e "${efield_refs[0]}" ]; then - echo "CompareEfieldReference_pass 1" >>$props_result_file + echo "CompareEfieldReference_pass 1" >> $props_result_file else for efield_ref in "${efield_refs[@]}"; do efield_name=${efield_ref%.ref} diff --git a/tests/integrate/validation_tools/run_check.sh b/tests/integrate/validation_tools/run_check.sh index 5ad42e9064d..e9e1b5f7b56 100755 --- a/tests/integrate/validation_tools/run_check.sh +++ b/tests/integrate/validation_tools/run_check.sh @@ -48,9 +48,9 @@ exec_path=${exec_path//'${ABACUS_EXE}'/$ABACUS_EXE} exec_path=${exec_path//'$ABACUS_EXE'/$ABACUS_EXE} # command -v accepts both a path and a bare name looked up in PATH. -command -v "$exec_path" >/dev/null || echo "Error! ABACUS path was wrong!!" +command -v "$exec_path" > /dev/null || echo "Error! ABACUS path was wrong!!" -command -v "$exec_path" >/dev/null || exit 0 +command -v "$exec_path" > /dev/null || exit 0 CA=$(grep CHECKACCURACY $GENERAL_INFO_FILE | awk '{printf $2}') @@ -62,7 +62,7 @@ echo "Test in $path_here" echo "Begin testing the example with $NP cores" #parallel test -mpirun -np $NP "$exec_path" >log.txt +mpirun -np $NP "$exec_path" > log.txt test -d OUT.autotest || echo "Some errors occured in ABACUS!" diff --git a/tests/integrate/validation_tools/run_librpa_producer.sh b/tests/integrate/validation_tools/run_librpa_producer.sh index 2ae95ce0d47..391d56265ea 100755 --- a/tests/integrate/validation_tools/run_librpa_producer.sh +++ b/tests/integrate/validation_tools/run_librpa_producer.sh @@ -19,4 +19,4 @@ while read -r case_name; do case_dir="$cases_dir/$case_name" (cd "$case_dir" && python3 "$script_dir/check_librpa_producer.py" \ --root . --manifest librpa_producer_manifest.json) -done >$1 - echo "etotperatomref $etotperatom" >>$1 + etot=$(grep ETOT_ $running_path | awk '{print $2}') + etotperatom=$(awk 'BEGIN {x='$etot';y='$natom';printf "%.10f\n",x/y}') + echo "etotref $etot" >> $1 + echo "etotperatomref $etotperatom" >> $1 fi - #echo $etot #echo "hasforce:"$has_force if ! test -z "$has_force" && [ $has_force -eq 1 ]; then - nn3=`echo "$natom + 4" |bc` - #nn1=`echo "$natom + 1" |bc` - #nn5=`echo "$natom + 6" |bc` - #grep -A$nn3 "TOTAL-FORCE" $running_path|sed '1,5d'|sed ''$nn1','$nn5'd'|awk '{printf $2"\t"$3"\t"$4"\n"}' > force.txt - grep -A$nn3 "TOTAL-FORCE" $running_path |awk 'NF==4{print $2,$3,$4}' | tail -$natom > force.txt #check the last step result - total_force=`sum_file force.txt` - rm force.txt - echo "totalforceref $total_force" >>$1 + nn3=$(echo "$natom + 4" | bc) + #nn1=`echo "$natom + 1" |bc` + #nn5=`echo "$natom + 6" |bc` + #grep -A$nn3 "TOTAL-FORCE" $running_path|sed '1,5d'|sed ''$nn1','$nn5'd'|awk '{printf $2"\t"$3"\t"$4"\n"}' > force.txt + grep -A$nn3 "TOTAL-FORCE" $running_path | awk 'NF==4{print $2,$3,$4}' | tail -$natom > force.txt #check the last step result + total_force=$(sum_file force.txt) + rm force.txt + echo "totalforceref $total_force" >> $1 fi #echo $total_force #echo "has_stress:"$has_stress -if ! test -z "$has_stress" && [ $has_stress -eq 1 ]; then - #grep -A6 "TOTAL-STRESS" $running_path|sed '1,4d'|sed '4,8d' >stress.txt - grep -A6 "TOTAL-STRESS" $running_path| awk 'NF==3' | tail -3> stress.txt - total_stress=`sum_file stress.txt` - rm stress.txt - echo "totalstressref $total_stress" >>$1 +if ! test -z "$has_stress" && [ $has_stress -eq 1 ]; then + #grep -A6 "TOTAL-STRESS" $running_path|sed '1,4d'|sed '4,8d' >stress.txt + grep -A6 "TOTAL-STRESS" $running_path | awk 'NF==3' | tail -3 > stress.txt + total_stress=$(sum_file stress.txt) + rm stress.txt + echo "totalstressref $total_stress" >> $1 fi - #echo $total_stress #if ! test -z "$has_charge" && [ $has_charge -eq 1 ]; then # total_charge=`sum_file OUT.autotest/SPIN1_CHG` # echo "totalchargeref $total_charge" >>$1 #fi - #echo $total_charge -if ! test -z "$has_dos" && [ $has_dos -eq 1 ]; then - total_dos=`cat OUT.autotest/doss*.txt | awk 'END {print}' | awk '{print $3}'` - echo "totaldosref $total_dos" >> $1 +if ! test -z "$has_dos" && [ $has_dos -eq 1 ]; then + total_dos=$(cat OUT.autotest/doss*.txt | awk 'END {print}' | awk '{print $3}') + echo "totaldosref $total_dos" >> $1 fi # smearing_dos=`sum_file OUT.autotest/doss*.txt` # echo "totaldossmearing $smearing_dos" >> $1 - #echo total_dos #echo $has_band -if ! test -z "$has_band" && [ $has_band -eq 1 ]; then - total_band=`sum_file OUT.autotest/BANDS_1.dat` - echo "totalbandref $total_band" >>$1 +if ! test -z "$has_band" && [ $has_band -eq 1 ]; then + total_band=$(sum_file OUT.autotest/BANDS_1.dat) + echo "totalbandref $total_band" >> $1 fi #echo $has_hs -if ! test -z "$has_hs" && [ $has_hs -eq 1 ]; then - total_h=`sum_file OUT.autotest/data-H` - echo "totalHmatrix $total_h" >>$1 - total_s=`sum_file OUT.autotest/data-S` - echo "totalSmatrix $total_s" >>$1 +if ! test -z "$has_hs" && [ $has_hs -eq 1 ]; then + total_h=$(sum_file OUT.autotest/data-H) + echo "totalHmatrix $total_h" >> $1 + total_s=$(sum_file OUT.autotest/data-S) + echo "totalSmatrix $total_s" >> $1 fi #echo $total_band -ttot=`grep $word $running_path | awk '{print $3}'` -echo "totaltimeref $ttot" >>$1 +ttot=$(grep $word $running_path | awk '{print $3}') +echo "totaltimeref $ttot" >> $1 diff --git a/tests/performance/run.sh b/tests/performance/run.sh index 3ea4292d3ab..d30984fa03f 100644 --- a/tests/performance/run.sh +++ b/tests/performance/run.sh @@ -84,7 +84,7 @@ run_abacus() { lastword=$(tail -1 result.log | awk '{print $1}') fi if [[ $lastword != "SEE" ]]; then - OMP_NUM_THREADS=$2 /usr/bin/time -v mpirun -n $1 $abacus 1>result.log 2>time.log + OMP_NUM_THREADS=$2 /usr/bin/time -v mpirun -n $1 $abacus 1> result.log 2> time.log else printf "**result.log is normal end, skip this job** " fi @@ -136,21 +136,21 @@ fi #Begin to RUN test -e allcase || echo "Please specify tests in file 'allcase'." test -e allcase || exit 1 -which $abacus >/dev/null || echo "Error: ABACUS executable not found. Please check ABACUS installation or \$PATH." -which $abacus >/dev/null || usage -which $abacus >/dev/null || exit 1 +which $abacus > /dev/null || echo "Error: ABACUS executable not found. Please check ABACUS installation or \$PATH." +which $abacus > /dev/null || usage +which $abacus > /dev/null || exit 1 test -f sumall.dat && mv sumall.dat sumall.old.dat -cat version >>sumall.dat -date >>sumall.dat -cat /proc/version >>sumall.dat -cat /proc/cpuinfo | grep "model name" | tail -1 | cut -d ':' -f 2 >>sumall.dat -echo "ABACUS path: $(which $abacus)" >>sumall.dat -echo "Number of Cores: $ncpu" >>sumall.dat -echo "Accuracy for energy: 1e-$ca" >>sumall.dat -echo >>sumall.dat -echo "!!!all data will be summarized in file sumall.dat" >>sumall.dat -echo "" >>sumall.dat +cat version >> sumall.dat +date >> sumall.dat +cat /proc/version >> sumall.dat +cat /proc/cpuinfo | grep "model name" | tail -1 | cut -d ':' -f 2 >> sumall.dat +echo "ABACUS path: $(which $abacus)" >> sumall.dat +echo "Number of Cores: $ncpu" >> sumall.dat +echo "Accuracy for energy: 1e-$ca" >> sumall.dat +echo >> sumall.dat +echo "!!!all data will be summarized in file sumall.dat" >> sumall.dat +echo "" >> sumall.dat cat sumall.dat failed=0 @@ -168,9 +168,9 @@ if [[ $DoAllExampleRun != 0 ]]; then #sum the critical timing information python3 sumdat.py -i allcase -o sum.dat - echo "##AllExampleRun" >>sumall.dat - cat sum.dat >>sumall.dat - echo "" >>sumall.dat + echo "##AllExampleRun" >> sumall.dat + cat sum.dat >> sumall.dat + echo "" >> sumall.dat echo !!!all data are summarized in sum.dat echo fi @@ -188,7 +188,7 @@ if [[ $DoNCpuTest != 0 ]]; then for i in $NCpuList; do if [[ $i -lt $cpucore ]]; then - echo ${case}_${i}cpu >>allcase.ncpu + echo ${case}_${i}cpu >> allcase.ncpu test -d ${case}_${i}cpu || mkdir ${case}_${i}cpu cp ${case}/INPUT ${case}/STRU ${case}/KPT ${case}/result.ref ${case}_${i}cpu @@ -196,7 +196,7 @@ if [[ $DoNCpuTest != 0 ]]; then fi done - echo $case >>allcase.ncpu + echo $case >> allcase.ncpu if [[ ! -f $case/result.log ]]; then run_abacus $ncpu $thread ${case} fi @@ -204,9 +204,9 @@ if [[ $DoNCpuTest != 0 ]]; then #sum the critical timing information bash sumdat.sh allcase.ncpu sum.dat.ncpu - echo "##NCpuTest" >>sumall.dat - cat sum.dat.ncpu >>sumall.dat - echo "" >>sumall.dat + echo "##NCpuTest" >> sumall.dat + cat sum.dat.ncpu >> sumall.dat + echo "" >> sumall.dat echo "!!!all data are summarized in sum.dat.ncpu" echo fi @@ -222,17 +222,17 @@ if [[ $DoKParTest != 0 ]]; then continue fi - echo $case >>allcase.kpar + echo $case >> allcase.kpar if [[ ! -f $case/result.log ]]; then run_abacus $ncpu $thread ${case} fi for i in $KParList; do if [[ $i -le $maxkpar ]]; then - echo ${case}_${i}kpar >>allcase.kpar + echo ${case}_${i}kpar >> allcase.kpar test -d ${case}_${i}kpar || mkdir ${case}_${i}kpar cp ${case}/INPUT ${case}/STRU ${case}/KPT ${case}/result.ref ${case}_${i}kpar - echo "kpar $i" >>${case}_${i}kpar/INPUT + echo "kpar $i" >> ${case}_${i}kpar/INPUT run_abacus $ncpu $thread ${case}_${i}kpar fi @@ -240,9 +240,9 @@ if [[ $DoKParTest != 0 ]]; then done #sum the critical timing information bash sumdat.sh allcase.kpar sum.dat.kpar - echo "##KParTest" >>sumall.dat - cat sum.dat.kpar >>sumall.dat - echo "" >>sumall.dat + echo "##KParTest" >> sumall.dat + cat sum.dat.kpar >> sumall.dat + echo "" >> sumall.dat echo "!!!all data are summarized in sum.dat.kpar" echo fi @@ -258,17 +258,17 @@ if [[ $DoBxyzTest != 0 ]]; then continue fi - echo $case >>allcase.bxyz + echo $case >> allcase.bxyz if [[ ! -f $case/result.log ]]; then run_abacus $ncpu $thread ${case} fi for i in $BxyzList; do if [[ $i != 2 ]]; then - echo ${case}_${i}bxyz >>allcase.bxyz + echo ${case}_${i}bxyz >> allcase.bxyz test -d ${case}_${i}bxyz || mkdir ${case}_${i}bxyz cp ${case}/INPUT ${case}/STRU ${case}/KPT ${case}/result.ref ${case}_${i}bxyz - printf " bx $i \n by $i \n bz $i" >>${case}_${i}bxyz/INPUT + printf " bx $i \n by $i \n bz $i" >> ${case}_${i}bxyz/INPUT run_abacus $ncpu $thread ${case}_${i}bxyz fi @@ -276,9 +276,9 @@ if [[ $DoBxyzTest != 0 ]]; then done #sum the critical timing information bash sumdat.sh allcase.bxyz sum.dat.bxyz - echo "##BxyzTest" >>sumall.dat - cat sum.dat.bxyz >>sumall.dat - echo "" >>sumall.dat + echo "##BxyzTest" >> sumall.dat + cat sum.dat.bxyz >> sumall.dat + echo "" >> sumall.dat echo "!!!all data are summarized in sum.dat.bxyz" echo fi diff --git a/toolchain/build_abacus_aocc-aocl.sh b/toolchain/build_abacus_aocc-aocl.sh index 63ebc888e4c..5844e83b7d4 100755 --- a/toolchain/build_abacus_aocc-aocl.sh +++ b/toolchain/build_abacus_aocc-aocl.sh @@ -92,14 +92,14 @@ cmake "${cmake_args[@]}" cmake --build "${BUILD_DIR}" --target install -j "${NUM_JOBS}" # generate abacus_env.sh -cat <"${TOOL}/abacus_env.sh" +cat << EOF > "${TOOL}/abacus_env.sh" #!/bin/bash source "${INSTALL_DIR}/setup" export PATH="${PREFIX}/bin":\${PATH} EOF # generate information -cat <"${TOOL}/abacus_env.sh" +cat << EOF > "${TOOL}/abacus_env.sh" #!/bin/bash source "${INSTALL_DIR}/setup" export PATH="${PREFIX}/bin":\${PATH} EOF # generate information -cat <"${TOOL}/abacus_env.sh" +cat << EOF > "${TOOL}/abacus_env.sh" #!/bin/bash source "${INSTALL_DIR}/setup" export PATH="${PREFIX}/bin":\${PATH} EOF # generate information -cat <"${TOOL}/abacus_env.sh" +cat << EOF > "${TOOL}/abacus_env.sh" #!/bin/bash source "${INSTALL_DIR}/setup" export PATH="${PREFIX}/bin":\${PATH} EOF # generate information -cat <"${TOOL}/abacus_env.sh" +cat << EOF > "${TOOL}/abacus_env.sh" #!/bin/bash source "${INSTALL_DIR}/setup" export PATH="${PREFIX}/bin":\${PATH} EOF # generate information -cat </dev/null | head -n 1) +built_exe=$(ls "${ABACUS_DIR}/${BUILD_DIR}"/abacus_*.exe 2> /dev/null | head -n 1) if [ -n "$built_exe" ]; then cp -f "$built_exe" "${ABACUS_DIR}/${BUILD_DIR}/abacus.exe" echo "Created generic launcher: ${ABACUS_DIR}/${BUILD_DIR}/abacus.exe -> $(basename "$built_exe")" @@ -134,7 +134,7 @@ fi # (msmpi.dll in System32, kernel32, ...) resolve on their own and are skipped. if [ -n "$built_exe" ]; then echo "Bundling dependent DLLs into ${BUILD_DIR}/ ..." - ldd "${ABACUS_DIR}/${BUILD_DIR}/abacus.exe" 2>/dev/null | + ldd "${ABACUS_DIR}/${BUILD_DIR}/abacus.exe" 2> /dev/null | awk -v p="$MINGW_PREFIX" '$3 ~ p {print $3}' | sort -u | while read -r dll; do cp -f "$dll" "${ABACUS_DIR}/${BUILD_DIR}/"; done fi @@ -145,7 +145,7 @@ fi # one thread per rank -- otherwise each rank's multithreaded OpenBLAS # oversubscribes the cores and its buffer allocator fails under several ranks. if [ "$ENABLE_MPI" = "ON" ]; then - cat <<'SHIM' >"${ABACUS_DIR}/${BUILD_DIR}/mpirun" + cat << 'SHIM' > "${ABACUS_DIR}/${BUILD_DIR}/mpirun" #!/bin/bash # mpirun -> mpiexec shim for native Windows (MS-MPI). See build_abacus_windows.sh. export OMP_NUM_THREADS=1 @@ -162,7 +162,7 @@ fi # OPENBLAS_NUM_THREADS) is what actually caps its threads; pin it to 1 so that # `mpiexec -n N abacus` doesn't oversubscribe and trip OpenBLAS's buffer # allocator. (Both are set; OPENBLAS_NUM_THREADS alone has no effect here.) -cat <"${TOOL}/abacus_env.sh" +cat << EOF > "${TOOL}/abacus_env.sh" #!/bin/bash [ -f "${INSTALL_DIR}/setup" ] && source "${INSTALL_DIR}/setup" export PATH="${ABACUS_DIR}/${BUILD_DIR}":\${PATH} @@ -173,7 +173,7 @@ export OMP_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 EOF -cat <"$SETUPFILE" + cat << EOF > "$SETUPFILE" #!/bin/bash source "${SCRIPTDIR}/tool_kit.sh" export ABACUS_TOOLCHAIN_OPTIONS="${TOOLCHAIN_OPTIONS}" @@ -146,10 +146,10 @@ EOF # write toolchain config ui_info "Writing toolchain configuration..." - echo "tool_list=\"${tool_list}\"" >${INSTALLDIR}/toolchain.conf + echo "tool_list=\"${tool_list}\"" > ${INSTALLDIR}/toolchain.conf for ii in ${package_list}; do install_mode="$(eval echo \${with_${ii}})" - echo "with_${ii}=\"${install_mode}\"" >>${INSTALLDIR}/toolchain.conf + echo "with_${ii}=\"${install_mode}\"" >> ${INSTALLDIR}/toolchain.conf done # Exit if dry run @@ -162,7 +162,7 @@ EOF # Build packages (following original toolchain logic) ui_section "Starting Package Installation" ui_info "Initializing build environment..." - echo "# Leak suppressions" >${INSTALLDIR}/lsan.supp + echo "# Leak suppressions" > ${INSTALLDIR}/lsan.supp # Install packages stage by stage with enhanced progress display ui_stage_progress "0" "Build Tools & Compilers" diff --git a/toolchain/scripts/lib/config_manager.sh b/toolchain/scripts/lib/config_manager.sh index 0b79f6b555d..2f127f6c361 100644 --- a/toolchain/scripts/lib/config_manager.sh +++ b/toolchain/scripts/lib/config_manager.sh @@ -180,7 +180,7 @@ config_load_from_file() { elif [[ -n "$line" ]]; then echo "Warning: Invalid configuration syntax in config file line $line_num: $line" fi - done <"$config_file" + done < "$config_file" CONFIG_FILE_LOADED=true echo "Configuration loaded successfully from: $config_file" @@ -283,9 +283,9 @@ config_set_defaults() { # Set default parallel jobs (NEW: Fix for parallel jobs parameter) if [[ -z "${NPROCS_OVERWRITE}" ]]; then - if command -v nproc >/dev/null 2>&1; then + if command -v nproc > /dev/null 2>&1; then CONFIG_CACHE["NPROCS_OVERWRITE"]="$(nproc --all)" - elif command -v sysctl >/dev/null 2>&1; then + elif command -v sysctl > /dev/null 2>&1; then CONFIG_CACHE["NPROCS_OVERWRITE"]="$(sysctl -n hw.ncpu)" else CONFIG_CACHE["NPROCS_OVERWRITE"]="1" @@ -313,10 +313,10 @@ config_set_defaults() { # For MPI, we try to detect system MPI variant (following original script logic) # Only detect if MPI_MODE is not already set (to avoid duplicate detection) - if [[ -z "${CONFIG_CACHE[MPI_MODE]}" ]] && command -v mpiexec >/dev/null 2>&1; then + if [[ -z "${CONFIG_CACHE[MPI_MODE]}" ]] && command -v mpiexec > /dev/null 2>&1; then # check if we are dealing with openmpi, mpich or intelmpi if mpiexec --version 2>&1 | grep -s -q "HYDRA"; then - if command -v ui_info &>/dev/null; then + if command -v ui_info &> /dev/null; then ui_info "🔍 Detected system MPI: MPICH" else echo "MPI is detected and it appears to be MPICH" @@ -324,7 +324,7 @@ config_set_defaults() { CONFIG_CACHE["MPI_MODE"]="mpich" CONFIG_CACHE["with_mpich"]="__SYSTEM__" elif mpiexec --version 2>&1 | grep -s -q "OpenRTE"; then - if command -v ui_info &>/dev/null; then + if command -v ui_info &> /dev/null; then ui_info "🔍 Detected system MPI: OpenMPI" else echo "MPI is detected and it appears to be OpenMPI" @@ -332,7 +332,7 @@ config_set_defaults() { CONFIG_CACHE["MPI_MODE"]="openmpi" CONFIG_CACHE["with_openmpi"]="__SYSTEM__" elif mpiexec --version 2>&1 | grep -s -q "Intel"; then - if command -v ui_info &>/dev/null; then + if command -v ui_info &> /dev/null; then ui_info "🔍 Detected system MPI: Intel MPI" else echo "MPI is detected and it appears to be Intel MPI" @@ -344,7 +344,7 @@ config_set_defaults() { CONFIG_CACHE["with_intelmpi"]="__SYSTEM__" CONFIG_CACHE["MPI_MODE"]="intelmpi" else # default to mpich - if command -v ui_info &>/dev/null; then + if command -v ui_info &> /dev/null; then ui_info "🔍 MPI detected, defaulting to MPICH configuration" else echo "MPI is detected and defaults to MPICH" @@ -353,7 +353,7 @@ config_set_defaults() { CONFIG_CACHE["with_mpich"]="__SYSTEM__" fi else - if command -v report_warning &>/dev/null; then + if command -v report_warning &> /dev/null; then report_warning ${LINENO} "No MPI installation detected (ignore this message in Cray Linux Environment or when MPI installation was requested)." else echo "Warning: No MPI installation detected (ignore this message in Cray Linux Environment or when MPI installation was requested)." @@ -1167,7 +1167,7 @@ config_init() { config_set_defaults # Initialize version helper to ensure VERSION_STRATEGY defaults are set - if command -v version_helper_init >/dev/null 2>&1; then + if command -v version_helper_init > /dev/null 2>&1; then version_helper_init fi @@ -1205,7 +1205,7 @@ config_apply_modes() { # Apply MPI mode settings (with output for user feedback) local mpi_mode="${CONFIG_CACHE[MPI_MODE]}" if [[ -n "$mpi_mode" ]]; then - if command -v ui_info &>/dev/null; then + if command -v ui_info &> /dev/null; then ui_info "⚙️ Configuring MPI mode: $mpi_mode" else echo "Applying MPI mode: $mpi_mode" @@ -1238,7 +1238,7 @@ config_apply_modes() { # Apply math mode settings (with output for user feedback) local math_mode="${CONFIG_CACHE[MATH_MODE]}" if [[ -n "$math_mode" ]]; then - if command -v ui_info &>/dev/null; then + if command -v ui_info &> /dev/null; then ui_info "🧮 Configuring Math mode: $math_mode" else echo "Applying Math mode: $math_mode" diff --git a/toolchain/scripts/lib/config_validator.sh b/toolchain/scripts/lib/config_validator.sh index 783935fefba..b582f1067a5 100644 --- a/toolchain/scripts/lib/config_validator.sh +++ b/toolchain/scripts/lib/config_validator.sh @@ -203,12 +203,12 @@ validate_system_requirements() { # Only check for system cmake if using system cmake if [[ "${CONFIG_CACHE[with_cmake]}" == "__SYSTEM__" ]]; then - if ! command -v "cmake" &>/dev/null; then + if ! command -v "cmake" &> /dev/null; then missing_tools+=("cmake") else # Check cmake version if it exists local cmake_min_version="3.16" - local cmake_version=$(cmake --version 2>/dev/null | head -n 1 | awk '{print $3}') + local cmake_version=$(cmake --version 2> /dev/null | head -n 1 | awk '{print $3}') if [[ -z "$cmake_version" ]]; then add_validation_error "Failed to determine CMake version" @@ -267,7 +267,7 @@ validate_system_requirements() { fi for tool in "${required_tools[@]}"; do - if ! command -v "$tool" &>/dev/null; then + if ! command -v "$tool" &> /dev/null; then missing_tools+=("$tool") fi done @@ -305,7 +305,7 @@ validate_system_requirements() { local missing_dev=() for pkg in "${dev_packages[@]}"; do - if ! command -v "$pkg" &>/dev/null && ! dpkg -l | grep -q "$pkg" 2>/dev/null; then + if ! command -v "$pkg" &> /dev/null && ! dpkg -l | grep -q "$pkg" 2> /dev/null; then missing_dev+=("$pkg") fi done @@ -320,11 +320,11 @@ validate_system_requirements() { local gcc_min_version=5 # Check if GCC tools are available - if ! command -v gcc &>/dev/null || ! command -v g++ &>/dev/null || ! command -v gfortran &>/dev/null; then + if ! command -v gcc &> /dev/null || ! command -v g++ &> /dev/null || ! command -v gfortran &> /dev/null; then local missing_tools=() - ! command -v gcc &>/dev/null && missing_tools+=("gcc") - ! command -v g++ &>/dev/null && missing_tools+=("g++") - ! command -v gfortran &>/dev/null && missing_tools+=("gfortran") + ! command -v gcc &> /dev/null && missing_tools+=("gcc") + ! command -v g++ &> /dev/null && missing_tools+=("g++") + ! command -v gfortran &> /dev/null && missing_tools+=("gfortran") add_validation_error_group "gcc_incomplete" \ "System GCC toolchain incomplete. Missing: ${missing_tools[*]}" \ @@ -337,9 +337,9 @@ validate_system_requirements() { fi # Get versions of GCC components - local gcc_version=$(gcc --version 2>/dev/null | head -n 1 | awk '{print $NF}') - local gxx_version=$(g++ --version 2>/dev/null | head -n 1 | awk '{print $NF}') - local gfc_version=$(gfortran --version 2>/dev/null | head -n 1 | awk '{print $NF}') + local gcc_version=$(gcc --version 2> /dev/null | head -n 1 | awk '{print $NF}') + local gxx_version=$(g++ --version 2> /dev/null | head -n 1 | awk '{print $NF}') + local gfc_version=$(gfortran --version 2> /dev/null | head -n 1 | awk '{print $NF}') # Check if version extraction was successful if [[ -z "$gcc_version" || -z "$gxx_version" || -z "$gfc_version" ]]; then @@ -406,8 +406,8 @@ validate_system_requirements() { fi local cuda_major="" - if command -v nvidia-smi &>/dev/null; then - local nvidia_banner=$(nvidia-smi 2>/dev/null | head -n 3 | tr '\n' ' ') + if command -v nvidia-smi &> /dev/null; then + local nvidia_banner=$(nvidia-smi 2> /dev/null | head -n 3 | tr '\n' ' ') local cuda_version=$(echo "$nvidia_banner" | sed -n 's/.*CUDA Version:[[:space:]]*\([0-9.]*\).*/\1/p') cuda_major=$(echo "$cuda_version" | awk -F. '{print $1}') fi diff --git a/toolchain/scripts/lib/package_manager.sh b/toolchain/scripts/lib/package_manager.sh index d2e31891ee5..7a3dcbe0ffb 100644 --- a/toolchain/scripts/lib/package_manager.sh +++ b/toolchain/scripts/lib/package_manager.sh @@ -21,7 +21,7 @@ package_manager_init() { fi # Initialize dependencies - if ! command -v config_manager_init &>/dev/null; then + if ! command -v config_manager_init &> /dev/null; then source "${SCRIPTDIR}/lib/config_manager.sh" fi @@ -191,7 +191,7 @@ package_check_system_requirements() { local missing_tools="" for tool in $required_tools; do - if ! command -v "$tool" &>/dev/null; then + if ! command -v "$tool" &> /dev/null; then missing_tools="$missing_tools $tool" fi done @@ -206,17 +206,17 @@ package_check_system_requirements() { local compiler_mode=$(config_get MATH_MODE) case "$compiler_mode" in gcc) - if ! command -v gcc &>/dev/null; then + if ! command -v gcc &> /dev/null; then report_warning ${LINENO} "GCC compiler not found in system PATH" fi ;; intel) - if ! command -v icc &>/dev/null && ! command -v icx &>/dev/null; then + if ! command -v icc &> /dev/null && ! command -v icx &> /dev/null; then report_warning ${LINENO} "Intel compiler not found in system PATH" fi ;; amd) - if ! command -v clang &>/dev/null; then + if ! command -v clang &> /dev/null; then report_warning ${LINENO} "AMD/Clang compiler not found in system PATH" fi ;; @@ -231,30 +231,30 @@ package_check_system_requirements() { package_write_config() { local config_file="$1" - echo "# ABACUS Toolchain Package Configuration" >"$config_file" - echo "# Generated on $(date)" >>"$config_file" - echo "" >>"$config_file" + echo "# ABACUS Toolchain Package Configuration" > "$config_file" + echo "# Generated on $(date)" >> "$config_file" + echo "" >> "$config_file" # Write package lists - echo "tool_list=\"${tool_list}\"" >>"$config_file" - echo "mpi_list=\"${mpi_list}\"" >>"$config_file" - echo "math_list=\"${math_list}\"" >>"$config_file" - echo "lib_list=\"${lib_list}\"" >>"$config_file" - echo "package_list=\"${package_list}\"" >>"$config_file" - echo "" >>"$config_file" + echo "tool_list=\"${tool_list}\"" >> "$config_file" + echo "mpi_list=\"${mpi_list}\"" >> "$config_file" + echo "math_list=\"${math_list}\"" >> "$config_file" + echo "lib_list=\"${lib_list}\"" >> "$config_file" + echo "package_list=\"${package_list}\"" >> "$config_file" + echo "" >> "$config_file" # Write package configurations for pkg in ${package_list}; do local status=$(config_get "with_${pkg}") - echo "with_${pkg}=\"${status}\"" >>"$config_file" + echo "with_${pkg}=\"${status}\"" >> "$config_file" done - echo "" >>"$config_file" - echo "# Configuration modes" >>"$config_file" - echo "MPI_MODE=\"$(config_get MPI_MODE)\"" >>"$config_file" - echo "MATH_MODE=\"$(config_get MATH_MODE)\"" >>"$config_file" - echo "TARGET_CPU=\"$(config_get TARGET_CPU)\"" >>"$config_file" - echo "GPUVER=\"$(config_get GPUVER)\"" >>"$config_file" + echo "" >> "$config_file" + echo "# Configuration modes" >> "$config_file" + echo "MPI_MODE=\"$(config_get MPI_MODE)\"" >> "$config_file" + echo "MATH_MODE=\"$(config_get MATH_MODE)\"" >> "$config_file" + echo "TARGET_CPU=\"$(config_get TARGET_CPU)\"" >> "$config_file" + echo "GPUVER=\"$(config_get GPUVER)\"" >> "$config_file" echo "Package configuration written to: $config_file" } diff --git a/toolchain/scripts/lib/user_interface.sh b/toolchain/scripts/lib/user_interface.sh index a7d04601fa3..323c0548c3a 100644 --- a/toolchain/scripts/lib/user_interface.sh +++ b/toolchain/scripts/lib/user_interface.sh @@ -110,8 +110,8 @@ ui_detect_unicode_support() { fi # Additional check using locale command if available - if [[ "$locale_utf8" == "false" ]] && command -v locale &>/dev/null; then - local charset=$(locale charmap 2>/dev/null || echo "") + if [[ "$locale_utf8" == "false" ]] && command -v locale &> /dev/null; then + local charset=$(locale charmap 2> /dev/null || echo "") if [[ "$charset" =~ UTF-?8 ]]; then locale_utf8=true fi @@ -312,7 +312,7 @@ ui_print_color() { # Log to file if specified if [[ -n "$UI_LOG_FILE" ]]; then - echo "[$(date '+%Y-%m-%d %H:%M:%S')] $message" >>"$UI_LOG_FILE" + echo "[$(date '+%Y-%m-%d %H:%M:%S')] $message" >> "$UI_LOG_FILE" fi } @@ -360,8 +360,8 @@ ui_get_glibc_version() { fi # Method 1: ldd --version (most reliable) - if command -v ldd &>/dev/null; then - local ldd_output=$(ldd --version 2>/dev/null | head -n1) + if command -v ldd &> /dev/null; then + local ldd_output=$(ldd --version 2> /dev/null | head -n1) if [[ $? -eq 0 && -n "$ldd_output" ]]; then # Extract version from ldd output (e.g., "ldd (Ubuntu GLIBC 2.35-0ubuntu3.1) 2.35") glibc_version=$(echo "$ldd_output" | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n1) @@ -383,7 +383,7 @@ ui_get_glibc_version() { for libc_path in "${libc_paths[@]}"; do if [[ -x "$libc_path" ]]; then - local libc_output=$("$libc_path" 2>/dev/null | head -n1) + local libc_output=$("$libc_path" 2> /dev/null | head -n1) if [[ $? -eq 0 && -n "$libc_output" ]]; then # Extract version from libc output glibc_version=$(echo "$libc_output" | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n1) @@ -396,8 +396,8 @@ ui_get_glibc_version() { done # Method 3: getconf GNU_LIBC_VERSION (alternative) - if command -v getconf &>/dev/null; then - local getconf_output=$(getconf GNU_LIBC_VERSION 2>/dev/null) + if command -v getconf &> /dev/null; then + local getconf_output=$(getconf GNU_LIBC_VERSION 2> /dev/null) if [[ $? -eq 0 && -n "$getconf_output" ]]; then # Extract version from getconf output (e.g., "glibc 2.35") glibc_version=$(echo "$getconf_output" | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n1) @@ -410,7 +410,7 @@ ui_get_glibc_version() { # Method 4: Check /proc/version_signature or similar (last resort) if [[ -r "/proc/version" ]]; then - local proc_version=$(cat /proc/version 2>/dev/null) + local proc_version=$(cat /proc/version 2> /dev/null) if [[ -n "$proc_version" ]]; then # Look for glibc version in kernel version string (rare but possible) glibc_version=$(echo "$proc_version" | grep -oE 'glibc[[:space:]]*[0-9]+\.[0-9]+(\.[0-9]+)?' | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n1) @@ -445,10 +445,10 @@ ui_get_version() { if [[ -n "$version_file" && -f "$version_file" ]]; then # Extract version from VERSION file, handling different formats - version=$(grep -E '^VERSION=' "$version_file" 2>/dev/null | cut -d'=' -f2 | tr -d '"' | tr -d "'" | xargs) + version=$(grep -E '^VERSION=' "$version_file" 2> /dev/null | cut -d'=' -f2 | tr -d '"' | tr -d "'" | xargs) if [[ -z "$version" ]]; then # Fallback: try to read the entire file content if no VERSION= line - version=$(head -n 1 "$version_file" 2>/dev/null | grep -v '^#' | xargs) + version=$(head -n 1 "$version_file" 2> /dev/null | grep -v '^#' | xargs) fi if [[ -z "$version" ]]; then version="Unknown" @@ -550,7 +550,7 @@ ui_progress() { ui_show_help() { ui_welcome_banner - cat <<'EOF' + cat << 'EOF' USAGE: install_abacus_toolchain_new.sh [OPTIONS] @@ -689,17 +689,17 @@ ui_show_summary() { echo " ├─ OS: $(uname -s) $(uname -m)" echo " ├─ Kernel: $(uname -r)" echo " ├─ glibc: $(ui_get_glibc_version)" - echo " ├─ CPU Cores: $(nproc 2>/dev/null || echo "unknown")" + echo " ├─ CPU Cores: $(nproc 2> /dev/null || echo "unknown")" # CPU model detection local cpu_model="unknown" - if command -v lscpu &>/dev/null; then + if command -v lscpu &> /dev/null; then cpu_model=$(LC_ALL=C lscpu | awk -F: '/^Model name/{print $2}' | sed 's/^[[:space:]]*//') fi if [[ -z "$cpu_model" || "$cpu_model" == "unknown" ]] && [[ -r /proc/cpuinfo ]]; then cpu_model=$(awk -F: '/model name|Hardware|Processor/{print $2; exit}' /proc/cpuinfo | sed 's/^[[:space:]]*//') fi echo " ├─ CPU Model: ${cpu_model}" - if command -v free &>/dev/null; then + if command -v free &> /dev/null; then local mem_gb=$(free -g | awk '/^Mem:/ {print $2}') echo " ├─ Memory: ${mem_gb}GB" else @@ -712,8 +712,8 @@ ui_show_summary() { local gpu_models="" # Method 1: Try nvidia-smi for NVIDIA GPUs - if command -v nvidia-smi &>/dev/null; then - local nvidia_output=$(nvidia-smi --query-gpu=name --format=csv,noheader,nounits 2>/dev/null) + if command -v nvidia-smi &> /dev/null; then + local nvidia_output=$(nvidia-smi --query-gpu=name --format=csv,noheader,nounits 2> /dev/null) if [[ $? -eq 0 && -n "$nvidia_output" ]]; then gpu_count=$(echo "$nvidia_output" | wc -l) if [[ $gpu_count -gt 0 ]]; then @@ -728,12 +728,12 @@ ui_show_summary() { fi # Method 2: Try rocm-smi for AMD GPUs (if no NVIDIA found) - if [[ "$gpu_info" == "no GPU detected" ]] && command -v rocm-smi &>/dev/null; then - local amd_output=$(rocm-smi --showproductname 2>/dev/null | grep -E "GPU\[" | head -n1) + if [[ "$gpu_info" == "no GPU detected" ]] && command -v rocm-smi &> /dev/null; then + local amd_output=$(rocm-smi --showproductname 2> /dev/null | grep -E "GPU\[" | head -n1) if [[ $? -eq 0 && -n "$amd_output" ]]; then local amd_name=$(echo "$amd_output" | sed -n 's/.*: \(.*\)/\1/p' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') if [[ -n "$amd_name" ]]; then - local amd_count=$(rocm-smi --showproductname 2>/dev/null | grep -c "GPU\[" || echo "1") + local amd_count=$(rocm-smi --showproductname 2> /dev/null | grep -c "GPU\[" || echo "1") if [[ $amd_count -eq 1 ]]; then gpu_info="$amd_name" else @@ -744,8 +744,8 @@ ui_show_summary() { fi # Method 3: Try lspci as fallback for any GPU vendor - if [[ "$gpu_info" == "no GPU detected" ]] && command -v lspci &>/dev/null; then - local pci_gpus=$(lspci 2>/dev/null | grep -i "vga\|3d\|display" | grep -v "audio") + if [[ "$gpu_info" == "no GPU detected" ]] && command -v lspci &> /dev/null; then + local pci_gpus=$(lspci 2> /dev/null | grep -i "vga\|3d\|display" | grep -v "audio") if [[ -n "$pci_gpus" ]]; then gpu_count=$(echo "$pci_gpus" | wc -l) local first_gpu_line=$(echo "$pci_gpus" | head -n1) @@ -779,12 +779,12 @@ ui_show_summary() { local nvidia_driver="unavailable" local cuda_version="unavailable" - if command -v nvidia-smi &>/dev/null; then - nvidia_driver=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>/dev/null | head -n1 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') + if command -v nvidia-smi &> /dev/null; then + nvidia_driver=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader 2> /dev/null | head -n1 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') if [[ -z "$nvidia_driver" ]]; then nvidia_driver="unavailable" fi - local nvidia_banner=$(nvidia-smi 2>/dev/null | head -n 3 | tr '\n' ' ') + local nvidia_banner=$(nvidia-smi 2> /dev/null | head -n 3 | tr '\n' ' ') cuda_version=$(echo "$nvidia_banner" | sed -n 's/.*CUDA Version:[[:space:]]*\([0-9.]*\).*/\1/p') cuda_version=$(echo "$cuda_version" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') if [[ -z "$cuda_version" ]]; then @@ -854,7 +854,7 @@ ui_show_summary() { echo "" # Installation summary - local install_list=$(package_list_to_install 2>/dev/null || echo "") + local install_list=$(package_list_to_install 2> /dev/null || echo "") if [[ -n "$install_list" ]]; then ui_print_color "${UI_GREEN}${UI_BOLD}" "🚀 Packages to be built from source:" for pkg in $install_list; do @@ -1142,9 +1142,9 @@ ui_show_system_info() { printf " ├─ %-20s %s\n" "Operating System:" "$(uname -s)" printf " ├─ %-20s %s\n" "Architecture:" "$(uname -m)" printf " ├─ %-20s %s\n" "Kernel Version:" "$(uname -r)" - printf " ├─ %-20s %s\n" "CPU Cores:" "$(nproc 2>/dev/null || echo "unknown")" + printf " ├─ %-20s %s\n" "CPU Cores:" "$(nproc 2> /dev/null || echo "unknown")" - if command -v free &>/dev/null; then + if command -v free &> /dev/null; then local mem_gb=$(free -g | awk '/^Mem:/ {print $2}') printf " ├─ %-20s %sGB\n" "Total Memory:" "$mem_gb" fi @@ -1167,7 +1167,7 @@ ui_check_system_requirements() { ui_print_color "${UI_BLUE}${UI_BOLD}" "🔍 Checking required system tools..." for tool in $required_tools; do - if ! command -v "$tool" &>/dev/null; then + if ! command -v "$tool" &> /dev/null; then missing_tools="$missing_tools $tool" ui_print_color "${UI_RED}" " ${UI_ICON_CROSS} $tool - not found" else diff --git a/toolchain/scripts/lib/version_helper.sh b/toolchain/scripts/lib/version_helper.sh index d99996f9d98..24f940271b1 100644 --- a/toolchain/scripts/lib/version_helper.sh +++ b/toolchain/scripts/lib/version_helper.sh @@ -68,7 +68,7 @@ version_show_package_info() { # Display version switching help # Usage: version_show_help version_show_help() { - cat <<'EOF' + cat << 'EOF' ABACUS Toolchain Version Switching Help ======================================= diff --git a/toolchain/scripts/stage0/install_amd.sh b/toolchain/scripts/stage0/install_amd.sh index 82f934c7331..2031f29ab3a 100755 --- a/toolchain/scripts/stage0/install_amd.sh +++ b/toolchain/scripts/stage0/install_amd.sh @@ -78,14 +78,14 @@ if [ "${with_amd}" != "__DONTUSE__" ]; then else [ $(realpath $(command -v gfortran) | grep -e aocc-compiler) ] || echo "Check the GNU Fortran compiler path" fi - cat <"${BUILDDIR}/setup_amd" + cat << EOF > "${BUILDDIR}/setup_amd" export CC="${CC}" export CXX="${CXX}" export FC="${FC}" export F90="${F90}" export F77="${F77}" EOF - cat <>"${BUILDDIR}/setup_amd" + cat << EOF >> "${BUILDDIR}/setup_amd" export AMD_CFLAGS="${AMD_CFLAGS}" export AMD_LDFLAGS="${AMD_LDFLAGS}" export AMD_LIBS="${AMD_LIBS}" diff --git a/toolchain/scripts/stage0/install_cmake.sh b/toolchain/scripts/stage0/install_cmake.sh index ec291260251..daa4e3684eb 100755 --- a/toolchain/scripts/stage0/install_cmake.sh +++ b/toolchain/scripts/stage0/install_cmake.sh @@ -89,7 +89,7 @@ case "${with_cmake}" in else strip_components=1 fi - tar --strip-components=${strip_components} -xvf ${cmake_pkg} -C ${pkg_install_dir} >install.log 2>&1 || tail_excerpt install.log + tar --strip-components=${strip_components} -xvf ${cmake_pkg} -C ${pkg_install_dir} > install.log 2>&1 || tail_excerpt install.log write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage0/$(basename ${SCRIPT_NAME})" fi ;; @@ -112,7 +112,7 @@ case "${with_cmake}" in esac if [ "${with_cmake}" != "__DONTUSE__" ]; then if [ "${with_cmake}" != "__SYSTEM__" ]; then - cat <"${BUILDDIR}/setup_cmake" + cat << EOF > "${BUILDDIR}/setup_cmake" prepend_path PATH "${pkg_install_dir}/bin" EOF filter_setup "${BUILDDIR}/setup_cmake" $SETUPFILE diff --git a/toolchain/scripts/stage0/install_gcc.sh b/toolchain/scripts/stage0/install_gcc.sh index 83cf6ab7346..cd7f1aa7043 100755 --- a/toolchain/scripts/stage0/install_gcc.sh +++ b/toolchain/scripts/stage0/install_gcc.sh @@ -69,16 +69,16 @@ case "${with_gcc}" in cd gcc-${gcc_ver} # Check network connectivity before downloading prerequisites - if curl -s --connect-timeout 5 https://gcc.gnu.org >/dev/null 2>&1; then + if curl -s --connect-timeout 5 https://gcc.gnu.org > /dev/null 2>&1; then echo "Downloading prerequisites from official GCC site..." # Try official site first - if ./contrib/download_prerequisites >prereq.log 2>&1; then + if ./contrib/download_prerequisites > prereq.log 2>&1; then echo "Prerequisites downloaded successfully from official site" else echo "Official site failed, trying mirror site..." # Fallback to cp2k.org mirror sed -i 's|http://gcc.gnu.org/pub/gcc/infrastructure/|https://cp2k.org/static/downloads/|' ./contrib/download_prerequisites - ./contrib/download_prerequisites >prereq.log 2>&1 || tail -n ${LOG_LINES} prereq.log + ./contrib/download_prerequisites > prereq.log 2>&1 || tail -n ${LOG_LINES} prereq.log fi else echo "Network unavailable, skipping prerequisites download (offline mode)" @@ -117,13 +117,13 @@ case "${with_gcc}" in --disable-multilib --disable-bootstrap \ --enable-lto \ --enable-plugins \ - >configure.log 2>&1 || tail -n ${LOG_LINES} configure.log + > configure.log 2>&1 || tail -n ${LOG_LINES} configure.log make -j $(get_nprocs) \ CFLAGS="${CFLAGS}" \ CXXFLAGS="${CXXFLAGS}" \ FCFLAGS="${FCFLAGS}" \ - >make.log 2>&1 || tail -n ${LOG_LINES} make.log - make -j $(get_nprocs) install >install.log 2>&1 || tail -n ${LOG_LINES} install.log + > make.log 2>&1 || tail -n ${LOG_LINES} make.log + make -j $(get_nprocs) install > install.log 2>&1 || tail -n ${LOG_LINES} install.log # thread sanitizer if [ "${ENABLE_TSAN}" = "__TRUE__" ]; then # now the tricky bit... we need to recompile in particular @@ -134,7 +134,7 @@ case "${with_gcc}" in # gcc, tested with 5.1.0 based on # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55374#c10 cd x86_64*/libgfortran - make clean >clean.log 2>&1 || tail -n ${LOG_LINES} clean.log + make clean > clean.log 2>&1 || tail -n ${LOG_LINES} clean.log CFLAGS="${CFLAGS} -fsanitize=thread" CXXFLAGS="${CXXFLAGS} -fsanitize=thread" FCFLAGS="${FCFLAGS} -fsanitize=thread" @@ -143,17 +143,17 @@ case "${with_gcc}" in CXXFLAGS="${CXXFLAGS}" \ FCFLAGS="${FCFLAGS}" \ LDFLAGS="-B$(pwd)/../libsanitizer/tsan/.libs/ -Wl,-rpath,$(pwd)/../libsanitizer/tsan/.libs/ -fsanitize=thread" \ - >make.log 2>&1 || tail -n ${LOG_LINES} make.log - make install >install.log 2>&1 || tail -n ${LOG_LINES} install.log + > make.log 2>&1 || tail -n ${LOG_LINES} make.log + make install > install.log 2>&1 || tail -n ${LOG_LINES} install.log cd ../libgomp - make clean >clean.log 2>&1 || tail -n ${LOG_LINES} clean.log + make clean > clean.log 2>&1 || tail -n ${LOG_LINES} clean.log make -j $(get_nprocs) \ CFLAGS="${CFLAGS}" \ CXXFLAGS="${CXXFLAGS}" \ FCFLAGS="${FCFLAGS}" \ LDFLAGS="-B$(pwd)/../libsanitizer/tsan/.libs/ -Wl,-rpath,$(pwd)/../libsanitizer/tsan/.libs/ -fsanitize=thread" \ - >make.log 2>&1 || tail -n ${LOG_LINES} make.log - make install >install.log 2>&1 || tail -n ${LOG_LINES} install.log + > make.log 2>&1 || tail -n ${LOG_LINES} make.log + make install > install.log 2>&1 || tail -n ${LOG_LINES} install.log cd ${GCCROOT}/obj/ fi cd ../.. @@ -206,7 +206,7 @@ else TSANFLAGS="" fi if [ "${with_gcc}" != "__DONTUSE__" ]; then - cat <"${BUILDDIR}/setup_gcc" + cat << EOF > "${BUILDDIR}/setup_gcc" export CC="${CC}" export CXX="${CXX}" export FC="${FC}" @@ -214,7 +214,7 @@ export F90="${F90}" export F77="${F77}" EOF if [ "${with_gcc}" != "__SYSTEM__" ]; then - cat <>"${BUILDDIR}/setup_gcc" + cat << EOF >> "${BUILDDIR}/setup_gcc" # needs full path for mpich/openmpi builds, triggers openblas bug prepend_path PATH "${pkg_install_dir}/bin" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" @@ -226,7 +226,7 @@ prepend_path LIBRARY_PATH "${pkg_install_dir}/lib64" prepend_path CPATH "${pkg_install_dir}/include" EOF fi - cat <>"${BUILDDIR}/setup_gcc" + cat << EOF >> "${BUILDDIR}/setup_gcc" export GCC_CFLAGS="${GCC_CFLAGS}" export GCC_LDFLAGS="${GCC_LDFLAGS}" export TSANFLAGS="${TSANFLAGS}" @@ -240,7 +240,7 @@ fi # this might need to be adjusted for the versions of the software # employed -cat <>${INSTALLDIR}/lsan.supp +cat << EOF >> ${INSTALLDIR}/lsan.supp # known leak either related to mpi or scalapack (e.g. showing randomly for Fist/regtest-7-2/UO2-2x2x2-genpot_units.inp) leak:__cp_fm_types_MOD_cp_fm_write_unformatted # leak related to mpi or scalapack triggers sometimes for regtest-kp-2/cc2.inp @@ -250,7 +250,7 @@ leak:blacs_gridmap_ leak:__dbcsr_tensor_types_MOD___copy_dbcsr_tensor_types_Dbcsr_tas_dist_t leak:__dbcsr_tensor_types_MOD___copy_dbcsr_tensor_types_Dbcsr_tas_blk_size_t EOF -cat <>${INSTALLDIR}/tsan.supp +cat << EOF >> ${INSTALLDIR}/tsan.supp # tsan bugs likely related to gcc # PR66756 deadlock:_gfortran_st_open @@ -262,7 +262,7 @@ race:__dbcsr_transformations_MOD_dbcsr_make_untransposed_blocks EOF # need to also link to the .supp file in setup file -cat <>${SETUPFILE} +cat << EOF >> ${SETUPFILE} export LSAN_OPTIONS=suppressions=${INSTALLDIR}/lsan.supp export TSAN_OPTIONS=suppressions=${INSTALLDIR}/tsan.supp EOF diff --git a/toolchain/scripts/stage0/install_intel.sh b/toolchain/scripts/stage0/install_intel.sh index c00a205bd11..c0eb9b61b09 100755 --- a/toolchain/scripts/stage0/install_intel.sh +++ b/toolchain/scripts/stage0/install_intel.sh @@ -82,14 +82,14 @@ if [ "${with_intel}" != "__DONTUSE__" ]; then echo "CC is ${CC}" echo "CXX is ${CXX}" echo "FC is ${FC}" - cat <"${BUILDDIR}/setup_intel" + cat << EOF > "${BUILDDIR}/setup_intel" export CC="${CC}" export CXX="${CXX}" export FC="${FC}" export F90="${F90}" export F77="${F77}" EOF - cat <>"${BUILDDIR}/setup_intel" + cat << EOF >> "${BUILDDIR}/setup_intel" export INTEL_CFLAGS="${INTEL_CFLAGS}" export INTEL_LDFLAGS="${INTEL_LDFLAGS}" export INTEL_LIBS="${INTEL_LIBS}" diff --git a/toolchain/scripts/stage1/install_intelmpi.sh b/toolchain/scripts/stage1/install_intelmpi.sh index 9fd574e79e0..d94c6140f53 100755 --- a/toolchain/scripts/stage1/install_intelmpi.sh +++ b/toolchain/scripts/stage1/install_intelmpi.sh @@ -122,7 +122,7 @@ if [ "${with_intelmpi}" != "__DONTUSE__" ]; then echo "MPICXX is ${MPICXX}" echo "MPICC is ${MPICC}" echo "MPIFC is ${MPIFC}" - cat <"${BUILDDIR}/setup_intelmpi" + cat << EOF > "${BUILDDIR}/setup_intelmpi" export I_MPI_CXX="${I_MPI_CXX}" export I_MPI_CC="${I_MPI_CC}" export I_MPI_FC="${I_MPI_FC}" diff --git a/toolchain/scripts/stage1/install_mpich.sh b/toolchain/scripts/stage1/install_mpich.sh index 576186900ab..3a222b27b85 100755 --- a/toolchain/scripts/stage1/install_mpich.sh +++ b/toolchain/scripts/stage1/install_mpich.sh @@ -73,9 +73,9 @@ case "${with_mpich}" in FFLAGS="${FCFLAGS} ${compat_flag}" \ FCFLAGS="${FCFLAGS} ${compat_flag}" \ --with-device=${MPICH_DEVICE} \ - >configure.log 2>&1 || tail -n ${LOG_LINES} configure.log - make -j $(get_nprocs) >make.log 2>&1 || tail -n ${LOG_LINES} make.log - make install >install.log 2>&1 || tail -n ${LOG_LINES} install.log + > configure.log 2>&1 || tail -n ${LOG_LINES} configure.log + make -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log + make install > install.log 2>&1 || tail -n ${LOG_LINES} install.log cd .. write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage1/$(basename ${SCRIPT_NAME})" fi @@ -103,7 +103,7 @@ case "${with_mpich}" in fi check_command mpiexec "mpich" && MPIRUN="$(command -v mpiexec)" check_command mpicc "mpich" && MPICC="$(command -v mpicc)" || exit 1 - if [ $(command -v mpic++ >/dev/null 2>&1) ]; then + if [ $(command -v mpic++ > /dev/null 2>&1) ]; then check_command mpic++ "mpich" && MPICXX="$(command -v mpic++)" || exit 1 else check_command mpicxx "mpich" && MPICXX="$(command -v mpicxx)" || exit 1 @@ -143,7 +143,7 @@ if [ "${with_mpich}" != "__DONTUSE__" ]; then mpi_bin="mpiexec" fi MPICH_LIBS="-lmpifort -lmpicxx -lmpi" - cat <"${BUILDDIR}/setup_mpich" + cat << EOF > "${BUILDDIR}/setup_mpich" export MPI_MODE="${MPI_MODE}" export MPIRUN="${MPIRUN}" export MPICC="${MPICC}" @@ -163,7 +163,7 @@ export CP_LDFLAGS="\${CP_LDFLAGS} IF_MPI(${MPICH_LDFLAGS}|)" export CP_LIBS="\${CP_LIBS} IF_MPI(${MPICH_LIBS}|)" EOF if [ "${with_mpich}" != "__SYSTEM__" ]; then - cat <>"${BUILDDIR}/setup_mpich" + cat << EOF >> "${BUILDDIR}/setup_mpich" prepend_path PATH "${pkg_install_dir}/bin" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" @@ -175,7 +175,7 @@ EOF fi # Update leak suppression file -cat <>${INSTALLDIR}/lsan.supp +cat << EOF >> ${INSTALLDIR}/lsan.supp # MPICH 3.3.2 with GCC 10.3.0 leak:MPIR_Find_local_and_external leak:MPIU_Find_local_and_external diff --git a/toolchain/scripts/stage1/install_openmpi.sh b/toolchain/scripts/stage1/install_openmpi.sh index 71797ce5c18..e6af83af183 100755 --- a/toolchain/scripts/stage1/install_openmpi.sh +++ b/toolchain/scripts/stage1/install_openmpi.sh @@ -97,9 +97,9 @@ case "${with_openmpi}" in --libdir="${pkg_install_dir}/lib" \ --with-libevent=internal \ ${EXTRA_CONFIGURE_FLAGS} \ - >configure.log 2>&1 || tail -n ${LOG_LINES} configure.log - make -j $(get_nprocs) >make.log 2>&1 || tail -n ${LOG_LINES} make.log - make -j $(get_nprocs) install >install.log 2>&1 || tail -n ${LOG_LINES} install.log + > configure.log 2>&1 || tail -n ${LOG_LINES} configure.log + make -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log + make -j $(get_nprocs) install > install.log 2>&1 || tail -n ${LOG_LINES} install.log cd .. write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage1/$(basename ${SCRIPT_NAME})" fi @@ -178,7 +178,7 @@ else OPENMPI_LIBS+=" -l${lib}" OPENMPI_LDFLAGS="${OPENMPI_LDFLAGS//-l${lib}/}" done - cat <"${BUILDDIR}/setup_openmpi" + cat << EOF > "${BUILDDIR}/setup_openmpi" export MPI_MODE="${MPI_MODE}" export MPIRUN="${MPIRUN}" export MPICC="${MPICC}" @@ -204,7 +204,7 @@ export CP_LDFLAGS="\${CP_LDFLAGS} IF_MPI(${OPENMPI_LDFLAGS}|)" export CP_LIBS="\${CP_LIBS} IF_MPI(${OPENMPI_LIBS}|)" EOF if [ "${with_openmpi}" != "__SYSTEM__" ]; then - cat <>"${BUILDDIR}/setup_openmpi" + cat << EOF >> "${BUILDDIR}/setup_openmpi" prepend_path PATH "${pkg_install_dir}/bin" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" @@ -218,7 +218,7 @@ EOF # ---------------------------------------------------------------------- # Suppress reporting of known leaks # ---------------------------------------------------------------------- - cat <>${INSTALLDIR}/valgrind.supp + cat << EOF >> ${INSTALLDIR}/valgrind.supp { Memcheck:Leak @@ -265,7 +265,7 @@ EOF fun:ompi_comm_activate } EOF - cat <>${INSTALLDIR}/lsan.supp + cat << EOF >> ${INSTALLDIR}/lsan.supp # leaks related to OpenMPI leak:query_2_0_0 leak:ompi_init_f diff --git a/toolchain/scripts/stage2/install_aocl.sh b/toolchain/scripts/stage2/install_aocl.sh index 48f8ad87b42..854d8c8dca9 100755 --- a/toolchain/scripts/stage2/install_aocl.sh +++ b/toolchain/scripts/stage2/install_aocl.sh @@ -57,7 +57,7 @@ case "${with_aocl}" in ;; esac if [ "$with_aocl" != "__DONTUSE__" ]; then - cat <>"${BUILDDIR}/setup_aocl" + cat << EOF >> "${BUILDDIR}/setup_aocl" export AOCL_ROOT="${pkg_install_dir}" export AOCL_CFLAGS="${AOCL_CFLAGS}" export AOCL_LDFLAGS="${AOCL_LDFLAGS}" diff --git a/toolchain/scripts/stage2/install_mkl.sh b/toolchain/scripts/stage2/install_mkl.sh index 26e4a7ba02a..b21c5b1e925 100755 --- a/toolchain/scripts/stage2/install_mkl.sh +++ b/toolchain/scripts/stage2/install_mkl.sh @@ -110,7 +110,7 @@ if [ "${with_mkl}" != "__DONTUSE__" ]; then fi # write setup files - cat <"${BUILDDIR}/setup_mkl" + cat << EOF > "${BUILDDIR}/setup_mkl" export MKLROOT="${MKLROOT}" export MKL_CFLAGS="${MKL_CFLAGS}" export MKL_LIBS="${MKL_LIBS}" @@ -119,13 +119,13 @@ export MATH_LIBS="\${MATH_LIBS} ${MKL_LIBS}" export CP_DFLAGS="\${CP_DFLAGS} -D__MKL -D__FFTW3 IF_COVERAGE(IF_MPI(|-U__FFTW3)|)" EOF if [ -n "${mkl_scalapack_lib}" ]; then - cat <>"${BUILDDIR}/setup_mkl" + cat << EOF >> "${BUILDDIR}/setup_mkl" export CP_DFLAGS="\${CP_DFLAGS} IF_MPI(-D__SCALAPACK|)" export with_scalapack="__DONTUSE__" EOF fi if [ "${MKL_FFTW}" != "no" ]; then - cat <>"${BUILDDIR}/setup_mkl" + cat << EOF >> "${BUILDDIR}/setup_mkl" export with_fftw="__DONTUSE__" export FFTW3_INCLUDES="${MKL_CFLAGS}" export FFTW3_LIBS="${MKL_LIBS}" diff --git a/toolchain/scripts/stage2/install_openblas.sh b/toolchain/scripts/stage2/install_openblas.sh index 757b655915b..4c9ed42b65b 100755 --- a/toolchain/scripts/stage2/install_openblas.sh +++ b/toolchain/scripts/stage2/install_openblas.sh @@ -82,7 +82,7 @@ case "${with_openblas}" in CC="${CC}" \ FC="${FC}" \ PREFIX="${pkg_install_dir}" \ - >make.log 2>&1; then + > make.log 2>&1; then tail -n "${LOG_LINES}" make.log make clean BUILD_DYNAMIC=1 @@ -100,13 +100,13 @@ case "${with_openblas}" in CC="${CC}" \ FC="${FC}" \ PREFIX="${pkg_install_dir}" \ - >make.log 2>&1; then + > make.log 2>&1; then tail -n "${LOG_LINES}" make.log exit 1 fi fi if ! make MAKE_NB_JOBS=0 PREFIX="${pkg_install_dir}" install \ - >install.log 2>&1; then + > install.log 2>&1; then tail -n "${LOG_LINES}" install.log exit 1 fi @@ -127,8 +127,8 @@ case "${with_openblas}" in check_lib -lopenblas "OpenBLAS" OPENBLAS_LIBS="-lopenblas" # detect separate omp builds - check_lib -lopenblas_openmp 2>/dev/null && OPENBLAS_LIBS="-lopenblas_openmp" - check_lib -lopenblas_omp 2>/dev/null && OPENBLAS_LIBS="-lopenblas_omp" + check_lib -lopenblas_openmp 2> /dev/null && OPENBLAS_LIBS="-lopenblas_openmp" + check_lib -lopenblas_omp 2> /dev/null && OPENBLAS_LIBS="-lopenblas_omp" add_include_from_paths OPENBLAS_CFLAGS "openblas_config.h" $INCLUDE_PATHS add_lib_from_paths OPENBLAS_LDFLAGS "libopenblas.*" $LIB_PATHS ;; @@ -143,22 +143,22 @@ case "${with_openblas}" in OPENBLAS_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath,'${pkg_install_dir}/lib'" OPENBLAS_LIBS="-lopenblas" # detect separate omp builds - (__libdir="${pkg_install_dir}/lib" LIB_PATHS="__libdir" check_lib -lopenblas_openmp 2>/dev/null) && + (__libdir="${pkg_install_dir}/lib" LIB_PATHS="__libdir" check_lib -lopenblas_openmp 2> /dev/null) && OPENBLAS_LIBS="-lopenblas_openmp" - (__libdir="${pkg_install_dir}/lib" LIB_PATHS="__libdir" check_lib -lopenblas_omp 2>/dev/null) && + (__libdir="${pkg_install_dir}/lib" LIB_PATHS="__libdir" check_lib -lopenblas_omp 2> /dev/null) && OPENBLAS_LIBS="-lopenblas_omp" ;; esac if [ "$with_openblas" != "__DONTUSE__" ]; then if [ "$with_openblas" != "__SYSTEM__" ]; then - cat <"${BUILDDIR}/setup_openblas" + cat << EOF > "${BUILDDIR}/setup_openblas" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" prepend_path LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path CPATH "${pkg_install_dir}/include" EOF fi - cat <>"${BUILDDIR}/setup_openblas" + cat << EOF >> "${BUILDDIR}/setup_openblas" export OPENBLAS_ROOT="${pkg_install_dir}" export OPENBLAS_CFLAGS="${OPENBLAS_CFLAGS}" export OPENBLAS_LDFLAGS="${OPENBLAS_LDFLAGS}" diff --git a/toolchain/scripts/stage3/install_elpa.sh b/toolchain/scripts/stage3/install_elpa.sh index 99097720889..b8f619ff014 100755 --- a/toolchain/scripts/stage3/install_elpa.sh +++ b/toolchain/scripts/stage3/install_elpa.sh @@ -94,18 +94,18 @@ case "$with_elpa" in config_flags="--disable-avx-kernels --disable-avx2-kernels --disable-avx512-kernels --disable-sse-kernels --disable-sse-assembly-kernels" if [ "${TARGET_CPU}" = "native" ]; then if [ -f /proc/cpuinfo ] && [ "${SYSTEM_ARCH}" = "x86_64" ]; then - has_AVX=$(grep '\bavx\b' /proc/cpuinfo 1>/dev/null && echo 'yes' || echo 'no') + has_AVX=$(grep '\bavx\b' /proc/cpuinfo 1> /dev/null && echo 'yes' || echo 'no') [ "${has_AVX}" = "yes" ] && AVX_flag="-mavx" || AVX_flag="" - has_AVX2=$(grep '\bavx2\b' /proc/cpuinfo 1>/dev/null && echo 'yes' || echo 'no') + has_AVX2=$(grep '\bavx2\b' /proc/cpuinfo 1> /dev/null && echo 'yes' || echo 'no') [ "${has_AVX2}" = "yes" ] && AVX_flag="-mavx2" - has_AVX512=$(grep '\bavx512f\b' /proc/cpuinfo 1>/dev/null && echo 'yes' || echo 'no') + has_AVX512=$(grep '\bavx512f\b' /proc/cpuinfo 1> /dev/null && echo 'yes' || echo 'no') [ "${has_AVX512}" = "yes" ] && AVX512_flags="-mavx512f" - FMA_flag=$(grep '\bfma\b' /proc/cpuinfo 1>/dev/null && echo '-mfma' || echo '-mno-fma') - SSE4_flag=$(grep '\bsse4_1\b' /proc/cpuinfo 1>/dev/null && echo '-msse4' || echo '-mno-sse4') - grep '\bavx512dq\b' /proc/cpuinfo 1>/dev/null && AVX512_flags+=" -mavx512dq" - grep '\bavx512cd\b' /proc/cpuinfo 1>/dev/null && AVX512_flags+=" -mavx512cd" - grep '\bavx512bw\b' /proc/cpuinfo 1>/dev/null && AVX512_flags+=" -mavx512bw" - grep '\bavx512vl\b' /proc/cpuinfo 1>/dev/null && AVX512_flags+=" -mavx512vl" + FMA_flag=$(grep '\bfma\b' /proc/cpuinfo 1> /dev/null && echo '-mfma' || echo '-mno-fma') + SSE4_flag=$(grep '\bsse4_1\b' /proc/cpuinfo 1> /dev/null && echo '-msse4' || echo '-mno-sse4') + grep '\bavx512dq\b' /proc/cpuinfo 1> /dev/null && AVX512_flags+=" -mavx512dq" + grep '\bavx512cd\b' /proc/cpuinfo 1> /dev/null && AVX512_flags+=" -mavx512cd" + grep '\bavx512bw\b' /proc/cpuinfo 1> /dev/null && AVX512_flags+=" -mavx512bw" + grep '\bavx512vl\b' /proc/cpuinfo 1> /dev/null && AVX512_flags+=" -mavx512vl" config_flags="--enable-avx-kernels=${has_AVX} --enable-avx2-kernels=${has_AVX2} --enable-avx512-kernels=${has_AVX512}" fi fi @@ -113,8 +113,8 @@ case "$with_elpa" in # GCC 15.2 miscompiles ELPA's double-complex AVX/AVX2 BLOCK2 # kernels when tree SLP vectorization is enabled. elpa_c_workaround_flags="" - cc_version="$("${MPICC}" -dumpfullversion -dumpversion 2>/dev/null || true)" - cc_banner="$("${MPICC}" --version 2>/dev/null | head -n 1 || true)" + cc_version="$("${MPICC}" -dumpfullversion -dumpversion 2> /dev/null || true)" + cc_banner="$("${MPICC}" --version 2> /dev/null | head -n 1 || true)" if [[ "${cc_banner}" == *gcc* || "${cc_banner}" == *GCC* ]] && [[ "${cc_version}" =~ ^15\.2(\.|$) ]]; then elpa_c_workaround_flags="-fno-tree-slp-vectorize" @@ -157,7 +157,7 @@ case "$with_elpa" in LIBS="${SCALAPACK_LIBS} $(resolve_string "${MATH_LIBS}" "MPI") ${MPI_LIBS}" \ SCALAPACK_LDFLAGS="${SCALAPACK_LDFLAGS}" \ SCALAPACK_FCFLAGS="${SCALAPACK_CFLAGS}" \ - >configure.log 2>&1 || tail -n ${LOG_LINES} configure.log + > configure.log 2>&1 || tail -n ${LOG_LINES} configure.log # remove unsupported compile option in libtool sed -i ./libtool \ -e 's/\\$wl-soname //g' \ @@ -188,10 +188,10 @@ case "$with_elpa" in LIBS="${SCALAPACK_LIBS} $(resolve_string "${MATH_LIBS}" "MPI")" \ SCALAPACK_LDFLAGS="${SCALAPACK_LDFLAGS}" \ SCALAPACK_FCFLAGS="${SCALAPACK_CFLAGS}" \ - >configure.log 2>&1 || tail -n ${LOG_LINES} configure.log + > configure.log 2>&1 || tail -n ${LOG_LINES} configure.log fi - make -j $(get_nprocs) >make.log 2>&1 || tail -n ${LOG_LINES} make.log - make install >install.log 2>&1 || tail -n ${LOG_LINES} install.log + make -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log + make install > install.log 2>&1 || tail -n ${LOG_LINES} install.log cd .. # link elpa link=${pkg_install_dir}/${TARGET}/include/elpa @@ -249,11 +249,11 @@ case "$with_elpa" in esac if [ "$with_elpa" != "__DONTUSE__" ]; then ELPA_LIBS="-lelpa${elpa_dir_openmp}" - cat <"${BUILDDIR}/setup_elpa" + cat << EOF > "${BUILDDIR}/setup_elpa" prepend_path CPATH "$elpa_include" EOF if [ "$with_elpa" != "__SYSTEM__" ]; then - cat <>"${BUILDDIR}/setup_elpa" + cat << EOF >> "${BUILDDIR}/setup_elpa" prepend_path PATH "${pkg_install_dir}/cpu/bin" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/cpu/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/cpu/lib" @@ -262,7 +262,7 @@ prepend_path PKG_CONFIG_PATH "${pkg_install_dir}/cpu/lib/pkgconfig" prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}/cpu" EOF if [ -d ${pkg_install_dir}/nvidia ]; then - cat <>"${BUILDDIR}/setup_elpa" + cat << EOF >> "${BUILDDIR}/setup_elpa" prepend_path PATH "${pkg_install_dir}/nvidia/bin" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/nvidia/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/nvidia/lib" @@ -272,7 +272,7 @@ prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}/nvidia" EOF fi fi - cat <>"${BUILDDIR}/setup_elpa" + cat << EOF >> "${BUILDDIR}/setup_elpa" export ELPA_ROOT="${pkg_install_dir}" export ELPA_CFLAGS="${ELPA_CFLAGS}" export ELPA_LDFLAGS="${ELPA_LDFLAGS}" diff --git a/toolchain/scripts/stage3/install_fftw.sh b/toolchain/scripts/stage3/install_fftw.sh index d50e9bf8458..7eedfce5319 100755 --- a/toolchain/scripts/stage3/install_fftw.sh +++ b/toolchain/scripts/stage3/install_fftw.sh @@ -65,9 +65,9 @@ case "$with_fftw" in [ "${MPI_MODE}" != "no" ] && FFTW_FLAGS="--enable-mpi ${FFTW_FLAGS}" if [ "${TARGET_CPU}" = "native" ]; then if [ -f /proc/cpuinfo ]; then - grep '\bavx\b' /proc/cpuinfo 1>/dev/null && FFTW_FLAGS="${FFTW_FLAGS} --enable-avx" - grep '\bavx2\b' /proc/cpuinfo 1>/dev/null && FFTW_FLAGS="${FFTW_FLAGS} --enable-avx2" - grep '\bavx512f\b' /proc/cpuinfo 1>/dev/null && FFTW_FLAGS="${FFTW_FLAGS} --enable-avx512" + grep '\bavx\b' /proc/cpuinfo 1> /dev/null && FFTW_FLAGS="${FFTW_FLAGS} --enable-avx" + grep '\bavx2\b' /proc/cpuinfo 1> /dev/null && FFTW_FLAGS="${FFTW_FLAGS} --enable-avx2" + grep '\bavx512f\b' /proc/cpuinfo 1> /dev/null && FFTW_FLAGS="${FFTW_FLAGS} --enable-avx512" fi fi # ABACUS need float version and double version fftw at the same time @@ -77,19 +77,19 @@ case "$with_fftw" in --libdir="${pkg_install_dir}/lib" \ --enable-float \ ${FFTW_FLAGS} \ - >configure.log 2>&1 || tail -n ${LOG_LINES} configure.log - make -j $(get_nprocs) >make.log 2>&1 || tail -n ${LOG_LINES} make.log - make install >install.log 2>&1 || tail -n ${LOG_LINES} install.log + > configure.log 2>&1 || tail -n ${LOG_LINES} configure.log + make -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log + make install > install.log 2>&1 || tail -n ${LOG_LINES} install.log # install double version fftw echo "clean" - make distclean >/dev/null 2>&1 || true + make distclean > /dev/null 2>&1 || true echo "install double version fftw" ./configure --prefix="${pkg_install_dir}" \ --libdir="${pkg_install_dir}/lib" \ ${FFTW_FLAGS} \ - >configure.log 2>&1 || tail -n ${LOG_LINES} configure.log - make -j $(get_nprocs) >make.log 2>&1 || tail -n ${LOG_LINES} make.log - make install >install.log 2>&1 || tail -n ${LOG_LINES} install.log + > configure.log 2>&1 || tail -n ${LOG_LINES} configure.log + make -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log + make install > install.log 2>&1 || tail -n ${LOG_LINES} install.log cd .. write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage3/$(basename ${SCRIPT_NAME})" fi @@ -123,7 +123,7 @@ if [ "$with_fftw" != "__DONTUSE__" ]; then [ "$MPI_MODE" != "no" ] && FFTW_LIBS="IF_MPI(-lfftw3_mpi|)" FFTW_LIBS+="-lfftw3 -lfftw3_omp" if [ "$with_fftw" != "__SYSTEM__" ]; then - cat <"${BUILDDIR}/setup_fftw" + cat << EOF > "${BUILDDIR}/setup_fftw" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" prepend_path LIBRARY_PATH "${pkg_install_dir}/lib" @@ -132,7 +132,7 @@ prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}" EOF fi # we may also want to cover FFT_SG - cat <>"${BUILDDIR}/setup_fftw" + cat << EOF >> "${BUILDDIR}/setup_fftw" export FFTW3_INCLUDES="${FFTW_CFLAGS}" export FFTW3_LIBS="${FFTW_LIBS}" export FFTW_CFLAGS="${FFTW_CFLAGS}" @@ -149,7 +149,7 @@ cd "${ROOTDIR}" # ---------------------------------------------------------------------- # Suppress reporting of known leaks # ---------------------------------------------------------------------- -cat <>${INSTALLDIR}/valgrind.supp +cat << EOF >> ${INSTALLDIR}/valgrind.supp { Memcheck:Addr32 diff --git a/toolchain/scripts/stage3/install_libxc.sh b/toolchain/scripts/stage3/install_libxc.sh index 54553bfb848..537b8f8ade4 100755 --- a/toolchain/scripts/stage3/install_libxc.sh +++ b/toolchain/scripts/stage3/install_libxc.sh @@ -72,9 +72,9 @@ case "$with_libxc" in -DENABLE_FORTRAN=ON \ -DENABLE_PYTHON=OFF \ -DBUILD_TESTING=OFF .. \ - >configure.log 2>&1 || tail -n ${LOG_LINES} configure.log - make -j $(get_nprocs) >make.log 2>&1 || tail -n ${LOG_LINES} make.log - make install >install.log 2>&1 || tail -n ${LOG_LINES} install.log + > configure.log 2>&1 || tail -n ${LOG_LINES} configure.log + make -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log + make install > install.log 2>&1 || tail -n ${LOG_LINES} install.log cd ../.. write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage3/$(basename ${SCRIPT_NAME})" fi @@ -106,7 +106,7 @@ esac if [ "$with_libxc" != "__DONTUSE__" ]; then LIBXC_LIBS="-lxcf03 -lxc" if [ "$with_libxc" != "__SYSTEM__" ]; then - cat <"${BUILDDIR}/setup_libxc" + cat << EOF > "${BUILDDIR}/setup_libxc" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" prepend_path LIBRARY_PATH "${pkg_install_dir}/lib" @@ -115,7 +115,7 @@ prepend_path PKG_CONFIG_PATH "${pkg_install_dir}/lib/pkgconfig" prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}" EOF fi - cat <>"${BUILDDIR}/setup_libxc" + cat << EOF >> "${BUILDDIR}/setup_libxc" export LIBXC_CFLAGS="${LIBXC_CFLAGS}" export LIBXC_LDFLAGS="${LIBXC_LDFLAGS}" export LIBXC_LIBS="${LIBXC_LIBS}" diff --git a/toolchain/scripts/stage3/install_scalapack.sh b/toolchain/scripts/stage3/install_scalapack.sh index 66d686df23a..8f3343780a7 100755 --- a/toolchain/scripts/stage3/install_scalapack.sh +++ b/toolchain/scripts/stage3/install_scalapack.sh @@ -60,7 +60,7 @@ case "${with_scalapack}" in tar -xzf ${scalapack_pkg} mkdir -p "scalapack-${scalapack_ver}/build" - pushd "scalapack-${scalapack_ver}/build" >/dev/null + pushd "scalapack-${scalapack_ver}/build" > /dev/null cflags="" fflags="" @@ -78,11 +78,11 @@ case "${with_scalapack}" in -DCMAKE_BUILD_TYPE=Release .. \ -DBUILD_TESTING=NO \ -DSCALAPACK_BUILD_TESTS=NO \ - >configure.log 2>&1 || tail -n ${LOG_LINES} configure.log - make -j $(get_nprocs) >make.log 2>&1 || tail -n ${LOG_LINES} make.log - make install >>make.log 2>&1 || tail -n ${LOG_LINES} make.log + > configure.log 2>&1 || tail -n ${LOG_LINES} configure.log + make -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log + make install >> make.log 2>&1 || tail -n ${LOG_LINES} make.log - popd >/dev/null + popd > /dev/null write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage3/$(basename ${SCRIPT_NAME})" fi SCALAPACK_LDFLAGS="-L'${pkg_install_dir}/lib' -Wl,-rpath,'${pkg_install_dir}/lib'" @@ -108,7 +108,7 @@ esac if [ "$with_scalapack" != "__DONTUSE__" ]; then SCALAPACK_LIBS="-lscalapack" if [ "$with_scalapack" != "__SYSTEM__" ]; then - cat <"${BUILDDIR}/setup_scalapack" + cat << EOF > "${BUILDDIR}/setup_scalapack" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" prepend_path LIBRARY_PATH "${pkg_install_dir}/lib" @@ -116,7 +116,7 @@ prepend_path PKG_CONFIG_PATH "${pkg_install_dir}/lib/pkgconfig" prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}" EOF fi - cat <>"${BUILDDIR}/setup_scalapack" + cat << EOF >> "${BUILDDIR}/setup_scalapack" export SCALAPACK_ROOT="${pkg_install_dir}" export SCALAPACK_LDFLAGS="${SCALAPACK_LDFLAGS}" export SCALAPACK_LIBS="${SCALAPACK_LIBS}" @@ -131,7 +131,7 @@ cd "${ROOTDIR}" # ---------------------------------------------------------------------- # Suppress reporting of known leaks # ---------------------------------------------------------------------- -cat <>${INSTALLDIR}/lsan.supp +cat << EOF >> ${INSTALLDIR}/lsan.supp # leaks related to SCALAPACK leak:pdpotrf_ EOF diff --git a/toolchain/scripts/stage4/install_cereal.sh b/toolchain/scripts/stage4/install_cereal.sh index 0f24b42d1ef..d99c4da5b8b 100755 --- a/toolchain/scripts/stage4/install_cereal.sh +++ b/toolchain/scripts/stage4/install_cereal.sh @@ -79,8 +79,8 @@ case "$with_cereal" in -DTHREAD_SAFE=ON \ -DSKIP_PORTABILITY_TEST=ON \ -DSKIP_PERFORMANCE_COMPARISON=ON \ - .. >cmake.log 2>&1 || tail -n ${LOG_LINES} cmake.log - make install -j $(get_nprocs) >make.log 2>&1 || tail -n ${LOG_LINES} make.log + .. > cmake.log 2>&1 || tail -n ${LOG_LINES} cmake.log + make install -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" fi CEREAL_CFLAGS="-I'${pkg_install_dir}/include'" @@ -116,11 +116,11 @@ case "$with_cereal" in esac if [ "$with_cereal" != "__DONTUSE__" ]; then if [ "$with_cereal" != "__SYSTEM__" ]; then - cat <"${BUILDDIR}/setup_cereal" + cat << EOF > "${BUILDDIR}/setup_cereal" prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}" EOF fi - cat <>"${BUILDDIR}/setup_cereal" + cat << EOF >> "${BUILDDIR}/setup_cereal" export CEREAL_ROOT="${pkg_install_dir}" export CEREAL_VERSION="${cereal_ver}" EOF diff --git a/toolchain/scripts/stage4/install_dftd4.sh b/toolchain/scripts/stage4/install_dftd4.sh index bf9d786cce5..4bb8ac86870 100755 --- a/toolchain/scripts/stage4/install_dftd4.sh +++ b/toolchain/scripts/stage4/install_dftd4.sh @@ -49,8 +49,8 @@ case "${with_dftd4}" in -DCMAKE_INSTALL_LIBDIR=lib \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_VERBOSE_MAKEFILE=ON \ - .. >cmake.log 2>&1 || tail -n ${LOG_LINES} cmake.log - make install -j $(get_nprocs) >make.log 2>&1 || tail -n ${LOG_LINES} make.log + .. > cmake.log 2>&1 || tail -n ${LOG_LINES} cmake.log + make install -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log cd .. write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" fi @@ -83,12 +83,12 @@ case "${with_dftd4}" in esac if [ "${with_dftd4}" != "__DONTUSE__" ]; then - cat <"${BUILDDIR}/setup_dftd4" + cat << EOF > "${BUILDDIR}/setup_dftd4" export DFTD4_VER="${dftd4_ver}" export DFTD4_ROOT="${pkg_install_dir}" EOF if [ "${with_dftd4}" != "__SYSTEM__" ]; then - cat <>"${BUILDDIR}/setup_dftd4" + cat << EOF >> "${BUILDDIR}/setup_dftd4" prepend_path PATH "${pkg_install_dir}/bin" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" diff --git a/toolchain/scripts/stage4/install_json.sh b/toolchain/scripts/stage4/install_json.sh index a7fce477ea2..e76f875cc79 100755 --- a/toolchain/scripts/stage4/install_json.sh +++ b/toolchain/scripts/stage4/install_json.sh @@ -38,8 +38,8 @@ case "${with_json}" in cmake .. \ -DCMAKE_INSTALL_PREFIX="${pkg_install_dir}" \ -DJSON_BuildTests=OFF \ - >cmake.log 2>&1 || tail -n "${LOG_LINES}" cmake.log - make install -j "$(get_nprocs)" >install.log 2>&1 || tail -n "${LOG_LINES}" install.log + > cmake.log 2>&1 || tail -n "${LOG_LINES}" cmake.log + make install -j "$(get_nprocs)" > install.log 2>&1 || tail -n "${LOG_LINES}" install.log write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/install_json.sh" fi ;; @@ -55,7 +55,7 @@ case "${with_json}" in esac if [ -n "${pkg_install_dir}" ]; then - cat >"${BUILDDIR}/setup_json" < "${BUILDDIR}/setup_json" << EOF prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}" EOF filter_setup "${BUILDDIR}/setup_json" "${SETUPFILE}" diff --git a/toolchain/scripts/stage4/install_libcomm.sh b/toolchain/scripts/stage4/install_libcomm.sh index 1c491fc38d2..4be63617cd5 100755 --- a/toolchain/scripts/stage4/install_libcomm.sh +++ b/toolchain/scripts/stage4/install_libcomm.sh @@ -107,11 +107,11 @@ case "$with_libcomm" in esac if [ "$with_libcomm" != "__DONTUSE__" ]; then if [ "$with_libcomm" != "__SYSTEM__" ]; then - cat <"${BUILDDIR}/setup_libcomm" + cat << EOF > "${BUILDDIR}/setup_libcomm" prepend_path CPATH "${pkg_install_dir}/include" EOF fi - cat <>"${BUILDDIR}/setup_libcomm" + cat << EOF >> "${BUILDDIR}/setup_libcomm" export LIBCOMM_ROOT="${pkg_install_dir}" EOF filter_setup "${BUILDDIR}/setup_libcomm" $SETUPFILE diff --git a/toolchain/scripts/stage4/install_libnpy.sh b/toolchain/scripts/stage4/install_libnpy.sh index a0ecf8697b2..6eb24b7f08e 100755 --- a/toolchain/scripts/stage4/install_libnpy.sh +++ b/toolchain/scripts/stage4/install_libnpy.sh @@ -99,11 +99,11 @@ case "$with_libnpy" in esac if [ "$with_libnpy" != "__DONTUSE__" ]; then if [ "$with_libnpy" != "__SYSTEM__" ]; then - cat <"${BUILDDIR}/setup_libnpy" + cat << EOF > "${BUILDDIR}/setup_libnpy" prepend_path CPATH "${pkg_install_dir}/include" EOF fi - cat <>"${BUILDDIR}/setup_libnpy" + cat << EOF >> "${BUILDDIR}/setup_libnpy" export LIBNPY_ROOT="${pkg_install_dir}" EOF filter_setup "${BUILDDIR}/setup_libnpy" $SETUPFILE diff --git a/toolchain/scripts/stage4/install_libri.sh b/toolchain/scripts/stage4/install_libri.sh index c6fce10280f..947819690dd 100755 --- a/toolchain/scripts/stage4/install_libri.sh +++ b/toolchain/scripts/stage4/install_libri.sh @@ -106,11 +106,11 @@ case "$with_libri" in esac if [ "$with_libri" != "__DONTUSE__" ]; then if [ "$with_libri" != "__SYSTEM__" ]; then - cat <"${BUILDDIR}/setup_libri" + cat << EOF > "${BUILDDIR}/setup_libri" prepend_path CPATH "${pkg_install_dir}/include" EOF fi - cat <>"${BUILDDIR}/setup_libri" + cat << EOF >> "${BUILDDIR}/setup_libri" export LIBRI_ROOT="${pkg_install_dir}" EOF filter_setup "${BUILDDIR}/setup_libri" $SETUPFILE diff --git a/toolchain/scripts/stage4/install_libtorch.sh b/toolchain/scripts/stage4/install_libtorch.sh index b9b425ff948..5c4699b8737 100755 --- a/toolchain/scripts/stage4/install_libtorch.sh +++ b/toolchain/scripts/stage4/install_libtorch.sh @@ -100,7 +100,7 @@ esac if [ "$with_libtorch" != "__DONTUSE__" ]; then if [ "$with_libtorch" != "__SYSTEM__" ]; then - cat <"${BUILDDIR}/setup_libtorch" + cat << EOF > "${BUILDDIR}/setup_libtorch" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" prepend_path LIBRARY_PATH "${pkg_install_dir}/lib" @@ -109,17 +109,17 @@ prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}" prepend_path CPATH "${pkg_install_dir}/include" EOF fi - cat <>"${BUILDDIR}/setup_libtorch" + cat << EOF >> "${BUILDDIR}/setup_libtorch" export CP_DFLAGS="\${CP_DFLAGS} -D__LIBTORCH" export CXXFLAGS="\${CXXFLAGS} ${LIBTORCH_CXXFLAGS}" export CP_LDFLAGS="\${CP_LDFLAGS} ${LIBTORCH_LDFLAGS}" EOF if [ "$ENABLE_CUDA" = "__TRUE__" ]; then - cat <>"${BUILDDIR}/setup_libtorch" + cat << EOF >> "${BUILDDIR}/setup_libtorch" export CP_LIBS="\${CP_LIBS} -lc10 -lc10_cuda -ltorch_cpu -ltorch_cuda -ltorch" EOF else - cat <>"${BUILDDIR}/setup_libtorch" + cat << EOF >> "${BUILDDIR}/setup_libtorch" export CP_LIBS="\${CP_LIBS} -lc10 -ltorch_cpu -ltorch" EOF fi diff --git a/toolchain/scripts/stage4/install_nep.sh b/toolchain/scripts/stage4/install_nep.sh index 4d956ac38d0..b574466e9a8 100755 --- a/toolchain/scripts/stage4/install_nep.sh +++ b/toolchain/scripts/stage4/install_nep.sh @@ -48,7 +48,7 @@ case "$with_nep" in tar -xzf $filename cd $dirname - cat <Makefile + cat << EOF > Makefile CXX ?= g++ # Compiler flags @@ -89,8 +89,8 @@ install: cp src/*.h \$(PREFIX)/include/ EOF - make >make.log 2>&1 || tail -n ${LOG_LINES} make.log - make PREFIX="${pkg_install_dir}" install >install.log 2>&1 || tail -n ${LOG_LINES} install.log + make > make.log 2>&1 || tail -n ${LOG_LINES} make.log + make PREFIX="${pkg_install_dir}" install > install.log 2>&1 || tail -n ${LOG_LINES} install.log cd .. write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" @@ -119,7 +119,7 @@ esac if [ "$with_nep" != "__DONTUSE__" ]; then NEP_LIBS="-lnep" if [ "$with_nep" != "__SYSTEM__" ]; then - cat <"${BUILDDIR}/setup_nep" + cat << EOF > "${BUILDDIR}/setup_nep" prepend_path LD_LIBRARY_PATH "${pkg_install_dir}/lib" prepend_path LD_RUN_PATH "${pkg_install_dir}/lib" prepend_path LIBRARY_PATH "${pkg_install_dir}/lib" @@ -127,7 +127,7 @@ prepend_path CPATH "${pkg_install_dir}/include" prepend_path CMAKE_PREFIX_PATH "${pkg_install_dir}" EOF fi - cat <>"${BUILDDIR}/setup_nep" + cat << EOF >> "${BUILDDIR}/setup_nep" export NEP_ROOT="${pkg_install_dir}" EOF filter_setup "${BUILDDIR}/setup_nep" $SETUPFILE diff --git a/toolchain/scripts/tool_kit.sh b/toolchain/scripts/tool_kit.sh index 94899286525..71a314d952e 100755 --- a/toolchain/scripts/tool_kit.sh +++ b/toolchain/scripts/tool_kit.sh @@ -114,7 +114,7 @@ report_warning_enhanced() { recommend_offline_installation() { __filename=$1 __url=$2 - cat </dev/null 2>&1); then + elif $(command -v nproc > /dev/null 2>&1); then echo $(nproc) - elif $(command -v sysctl >/dev/null 2>&1); then + elif $(command -v sysctl > /dev/null 2>&1); then echo $(sysctl -n hw.ncpu) else echo 1 @@ -449,7 +449,7 @@ check_system_requirements() { # Check required commands for cmd in "${required_commands[@]}"; do - if ! command -v "$cmd" >/dev/null 2>&1; then + if ! command -v "$cmd" > /dev/null 2>&1; then report_error_enhanced 1 "Required command not found: $cmd" return 1 fi @@ -467,7 +467,7 @@ resolve_string() { shift local __flags=$@ - echo $("${SCRIPTDIR}/parse_if.py" $__flags <<<"${__to_resolve}") + echo $("${SCRIPTDIR}/parse_if.py" $__flags <<< "${__to_resolve}") } # Enhanced string processing with validation @@ -487,7 +487,7 @@ resolve_string_safe() { fi local result - result=$("${SCRIPTDIR}/parse_if.py" "${__flags[@]}" <<<"${__to_resolve}" 2>/dev/null) + result=$("${SCRIPTDIR}/parse_if.py" "${__flags[@]}" <<< "${__to_resolve}" 2> /dev/null) local exit_code=$? if [[ $exit_code -ne 0 ]]; then @@ -511,7 +511,7 @@ check_command() { elif [ $# -gt 1 ]; then local __package=${2} fi - if $(command -v ${__command} >/dev/null 2>&1); then + if $(command -v ${__command} > /dev/null 2>&1); then echo "path to ${__command} is $(realpath $(command -v ${__command}))" else report_error "Cannot find ${__command}, please check if the package ${__package} is installed or in system search path" @@ -525,7 +525,7 @@ check_command_version() { local min_version="$2" local package_name="${3:-$command_name}" - if ! command -v "$command_name" >/dev/null 2>&1; then + if ! command -v "$command_name" > /dev/null 2>&1; then report_error_enhanced 1 "Command not found: $command_name" "Package: $package_name" return 1 fi @@ -549,7 +549,7 @@ check_commands_batch() { local failed_commands=() for cmd in "${commands[@]}"; do - if ! command -v "$cmd" >/dev/null 2>&1; then + if ! command -v "$cmd" > /dev/null 2>&1; then failed_commands+=("$cmd") else echo "✓ Found: $cmd at $(command -v "$cmd")" @@ -584,7 +584,7 @@ check_install() { elif [ $# -gt 1 ]; then local __package=${2} fi - if $(command -v ${__command} >/dev/null 2>&1); then + if $(command -v ${__command} > /dev/null 2>&1); then echo "$(basename ${__command}) is installed as $(command -v ${__command})" else report_error "cannot find ${__command}, please check if the package ${__package} has been installed correctly" @@ -637,7 +637,7 @@ check_lib() { check_gfortran_module() { local __module_name=$1 local __FC=${FC:-gfortran} - cat </dev/null 2>&1 + cat << EOF | $__FC -c -o /dev/null -xf95 -ffree-form - > /dev/null 2>&1 PROGRAM check_gfortran_module USE ${__module_name} IMPLICIT NONE @@ -653,7 +653,7 @@ check_gfortran_flag() { local __FC=${FC:-gfortran} # no need to do a full compilation, just -E -cpp would do for # checking flags - cat </dev/null 2>&1 + cat << EOF | $__FC -E -cpp $__flag -xf95 -ffree-form - > /dev/null 2>&1 PROGRAM test_code IMPLICIT NONE PRINT *, "PASS" @@ -668,7 +668,7 @@ check_gcc_flag() { local __CC=${CC:-gcc} # no need to do a full compilation, just -E -cpp would do for # checking flags - cat </dev/null 2>&1 + cat << EOF | $__CC -E -cpp $__flag -xc - > /dev/null 2>&1 #include int main() { printf("PASS\n"); @@ -683,7 +683,7 @@ check_gxx_flag() { local __CXX=${CXX:-g++} # no need to do a full compilation, just -E -cpp would do for # checking flags - cat </dev/null 2>&1 + cat << EOF | $__CXX -E -cpp $__flag -xc - > /dev/null 2>&1 #include int main() { printf("PASS\n"); @@ -869,7 +869,7 @@ checksum() { local __shasum_command='sha256sum' # check if we have sha256sum command, Mac OS X does not have # sha256sum, but has an equivalent with shasum -a 256 - command -v "$__shasum_command" >/dev/null 2>&1 || + command -v "$__shasum_command" > /dev/null 2>&1 || __shasum_command="shasum -a 256" echo "$__sha256 $__filename" | ${__shasum_command} --check } @@ -889,15 +889,15 @@ verify_file_integrity() { case "$hash_type" in sha256) hash_command="sha256sum" - command -v "$hash_command" >/dev/null 2>&1 || hash_command="shasum -a 256" + command -v "$hash_command" > /dev/null 2>&1 || hash_command="shasum -a 256" ;; sha1) hash_command="sha1sum" - command -v "$hash_command" >/dev/null 2>&1 || hash_command="shasum -a 1" + command -v "$hash_command" > /dev/null 2>&1 || hash_command="shasum -a 1" ;; md5) hash_command="md5sum" - command -v "$hash_command" >/dev/null 2>&1 || hash_command="md5" + command -v "$hash_command" > /dev/null 2>&1 || hash_command="md5" ;; *) report_error_enhanced 1 "Unsupported hash type" "$hash_type" @@ -1014,10 +1014,10 @@ verify_checksums() { # check if we have sha256sum command, Mac OS X does not have # sha256sum, but has an equivalent with shasum -a 256 - command -v "$__shasum_command" >/dev/null 2>&1 || + command -v "$__shasum_command" > /dev/null 2>&1 || __shasum_command="shasum -a 256" - ${__shasum_command} --check "${__checksum_file}" >/dev/null 2>&1 + ${__shasum_command} --check "${__checksum_file}" > /dev/null 2>&1 } # write a checksum file $1 containing checksums for each given file $2, $3, ... (plus the $VERSION_FILE) @@ -1028,10 +1028,10 @@ write_checksums() { # check if we have sha256sum command, Mac OS X does not have # sha256sum, but has an equivalent with shasum -a 256 - command -v "$__shasum_command" >/dev/null 2>&1 || + command -v "$__shasum_command" > /dev/null 2>&1 || __shasum_command="shasum -a 256" - ${__shasum_command} "${VERSION_FILE}" "$@" >"${__checksum_file}" + ${__shasum_command} "${VERSION_FILE}" "$@" > "${__checksum_file}" } # generate a filtered toolchain.env @@ -1055,7 +1055,7 @@ write_toolchain_env() { unset DBUS_SESSION_BUS_ADDRESS export -p - ) >"${__installdir}/toolchain.env" + ) > "${__installdir}/toolchain.env" } # Write a setup file without containing flags unnecessay for building and running ABACUS @@ -1070,6 +1070,6 @@ filter_setup() { fi local filename=$(basename "$source_file") - echo "# ==================== Setup for ${filename#*_} ==================== #" >>"$target_file" - sed '/if[[:space:]]/,/^[[:space:]]*fi$/d' "$source_file" | grep -v -E '# For|# Other|with_|FLAGS|LIBS|INCLUDES' >>"$target_file" + echo "# ==================== Setup for ${filename#*_} ==================== #" >> "$target_file" + sed '/if[[:space:]]/,/^[[:space:]]*fi$/d' "$source_file" | grep -v -E '# For|# Other|with_|FLAGS|LIBS|INCLUDES' >> "$target_file" } diff --git a/toolchain/tests/test_installer_argument_failures.sh b/toolchain/tests/test_installer_argument_failures.sh index 29d5066cbee..09f44048e85 100755 --- a/toolchain/tests/test_installer_argument_failures.sh +++ b/toolchain/tests/test_installer_argument_failures.sh @@ -26,7 +26,7 @@ copy_toolchain() { run_installer_in_copy() { local tmpdir="$1" shift - (cd "${tmpdir}/toolchain" && ./install_abacus_toolchain_new.sh "$@") >"${tmpdir}/output.log" 2>&1 + (cd "${tmpdir}/toolchain" && ./install_abacus_toolchain_new.sh "$@") > "${tmpdir}/output.log" 2>&1 } assert_invalid_input_fails() { diff --git a/toolchain/tests/test_openmpi_binding_policy_setup.sh b/toolchain/tests/test_openmpi_binding_policy_setup.sh index 5ae0bfb9c6d..00672ffb59c 100755 --- a/toolchain/tests/test_openmpi_binding_policy_setup.sh +++ b/toolchain/tests/test_openmpi_binding_policy_setup.sh @@ -15,7 +15,7 @@ write_fake_openmpi_commands() { local version="$2" mkdir -p "$bindir" - cat >"${bindir}/mpiexec" < "${bindir}/mpiexec" << EOF #!/usr/bin/env bash if [[ "\$1" == "--version" ]]; then printf 'mpiexec (Open MPI) ${version}\n' @@ -23,7 +23,7 @@ if [[ "\$1" == "--version" ]]; then fi exit 0 EOF - cat >"${bindir}/mpicxx" <<'EOF' + cat > "${bindir}/mpicxx" << 'EOF' #!/usr/bin/env bash if [[ "$1" == "--showme:libs" ]]; then printf 'mpi\n' @@ -41,9 +41,9 @@ run_openmpi_system_setup() { local version="$2" mkdir -p "${tmpdir}/install" "${tmpdir}/build" - : >"${tmpdir}/install/setup" - : >"${tmpdir}/install/toolchain.env" - cat >"${tmpdir}/install/toolchain.conf" <<'EOF' + : > "${tmpdir}/install/setup" + : > "${tmpdir}/install/toolchain.env" + cat > "${tmpdir}/install/toolchain.conf" << 'EOF' MPI_MODE="openmpi" with_openmpi="__SYSTEM__" PACK_RUN="__FALSE__" @@ -57,7 +57,7 @@ EOF BUILDDIR="${tmpdir}/build" \ SETUPFILE="${tmpdir}/install/setup" \ bash "${TOOLCHAIN_DIR}/scripts/stage1/install_openmpi.sh" \ - >"${tmpdir}/openmpi.log" 2>&1 + > "${tmpdir}/openmpi.log" 2>&1 } assert_setup_contains() { diff --git a/toolchain/toolchain_windows.sh b/toolchain/toolchain_windows.sh index 2fc9389647d..abe3b32df57 100644 --- a/toolchain/toolchain_windows.sh +++ b/toolchain/toolchain_windows.sh @@ -16,7 +16,7 @@ # then: # ./build_abacus_windows.sh -if ! command -v pacman >/dev/null 2>&1; then +if ! command -v pacman > /dev/null 2>&1; then echo "ERROR: pacman not found. Run this inside an MSYS2 shell (https://www.msys2.org)." exit 1 fi @@ -52,7 +52,7 @@ pacman -S --needed --noconfirm bc TOOL=$(cd "$(dirname "$0")" && pwd) INSTALL_DIR="$TOOL/install" mkdir -p "$INSTALL_DIR" -cat >"$INSTALL_DIR/setup" <<'EOF' +cat > "$INSTALL_DIR/setup" << 'EOF' # Native Windows (MSYS2/MinGW-w64) prerequisites live under /mingw64. export MINGW_PREFIX="${MINGW_PREFIX:-/mingw64}" export OPENBLAS_ROOT="$MINGW_PREFIX" # OpenBLAS provides BLAS *and* LAPACK @@ -60,7 +60,7 @@ export FFTW_ROOT="$MINGW_PREFIX" export PATH="$MINGW_PREFIX/bin:$PATH" EOF -cat </dev/null + grep slots $hostfpath > /dev/null if [ $? = 0 ]; then # has "slots" in file: $hostfpath cpu_num=$(cat $hostfpath | cut -d "=" -f 2-3 | awk '{sum += $1};END {print sum}') else @@ -79,7 +79,7 @@ if [ -z "$EXE_mpi" ]; then EXE_mpi="mpirun -np $cpu_num -hostfile ../$hostfpath " fi echo " EXE_mpi = $EXE_mpi " -Host_List=($($EXE_mpi hostname 2>/dev/null)) +Host_List=($($EXE_mpi hostname 2> /dev/null)) Host1_List=($(echo ${Host_List[@]} | grep -o "$Host_List")) Host1_NCore=${#Host1_List[@]} echo " Host1_NCore = $Host1_NCore" @@ -475,7 +475,7 @@ for name in $targets; do if [ "${ListSTRU[iSTRU]}" == "dimer" ]; then na=2 - cat >$name.stru < $name.stru << EOF ATOMIC_SPECIES $element $mass $pseudofile LATTICE_CONSTANT @@ -495,7 +495,7 @@ EOF elif [ "${ListSTRU[iSTRU]}" == "trimer" ]; then na=3 - cat >$name.stru < $name.stru << EOF ATOMIC_SPECIES $element $mass $pseudofile LATTICE_CONSTANT @@ -516,7 +516,7 @@ EOF elif [ "${ListSTRU[iSTRU]}" == "tetramer" ]; then na=4 - cat >$name.stru < $name.stru << EOF ATOMIC_SPECIES $element $mass $pseudofile LATTICE_CONSTANT @@ -540,7 +540,7 @@ EOF echo " na=$na" # (1.4.2.2) get KPOINTS - cat >KPOINTS < KPOINTS << EOF K_POINTS 0 Gamma @@ -548,7 +548,7 @@ Gamma EOF # (1.4.2.3) get INPUTw - cat >INPUTw < INPUTw << EOF WANNIER_PARAMETERS rcut 10 out_spillage 2 @@ -568,7 +568,7 @@ EOF # EOF # (1.4.2.5) get INPUT - cat >INPUT < INPUT << EOF INPUT_PARAMETERS suffix $element-$rcut-$BL stru_file $name.stru @@ -641,7 +641,7 @@ EOF echo -e " Using Simulated Annealing Method \n" ### (1.4.3.2) prepare for the INPUT file - cat >INPUT < INPUT << EOF 1 // if or not calculate the spillage. 1/0 $((${RestartSTRU[$iSTRU]} > 0)) // restart or not. 1/0 @@ -653,13 +653,13 @@ EOF count_files=1 while [ $count_files -le ${BL_number[iSTRU]} ]; do BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') - cat >>INPUT <> INPUT << EOF ../OUT.$element-$rcut-$BL/orb_matrix.0.dat EOF let count_files++ done - cat >>INPUT <> INPUT << EOF @@ -707,7 +707,7 @@ ${ref_bands[$iSTRU]} // int, the ed band index(>INPUT <> INPUT << EOF ${EndLevel[$iSTRU]} // Number of levels. label / na / skip / lmax / each L / @@ -720,16 +720,16 @@ EOF leveltype="skip" fi #echo "leveltype=$leveltype" - cat >>INPUT <> INPUT << EOF $id $na $leveltype ${Llevels[i]} EOF done - cat >>INPUT <> INPUT << EOF EOF - cat >>INPUT <> INPUT << EOF 0.01 //dr(a.u.) of uniform mesh. Attention!!dr will affect kinetic energy minmized largely. -6 //xmin @@ -763,7 +763,7 @@ EOF ### len(dis[info["input"]["element"]]), ### (1.4.3.2) prepare INPUT file in json for PyTorch program - cat >INPUT < INPUT << EOF { "file_list": { @@ -774,13 +774,13 @@ EOF count_files=1 while [ $count_files -lt ${BL_number[iSTRU]} ]; do BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') - cat >>INPUT <> INPUT << EOF "../OUT.$element-$rcut-$BL/orb_matrix.0.dat", EOF let count_files++ done BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') - cat >>INPUT <> INPUT << EOF "../OUT.$element-$rcut-$BL/orb_matrix.0.dat" ], "linear": @@ -791,19 +791,19 @@ EOF count_files=1 while [ $count_files -lt ${BL_number[iSTRU]} ]; do BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') - cat >>INPUT <> INPUT << EOF "../OUT.$element-$rcut-$BL/orb_matrix.1.dat", EOF let count_files++ done BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') - cat >>INPUT <> INPUT << EOF "../OUT.$element-$rcut-$BL/orb_matrix.1.dat" ] ] EOF - cat >>INPUT <> INPUT << EOF }, "info": @@ -857,12 +857,12 @@ EOF echo " numL = ${numL[@]}, LValueMax = $LValueMax " for ((LValue = 0; LValue < ${LValueMax}; LValue++)); do - cat >>INPUT <> INPUT << EOF ${numL[$LValue]}, EOF done - cat >>INPUT <> INPUT << EOF ${numL[$LValueMax]} ] }, @@ -885,50 +885,50 @@ EOF EOF for ((i_BL = 1; i_BL < ${BL_number[iSTRU]}; i_BL++)); do - cat >>INPUT <> INPUT << EOF 1, EOF done - cat >>INPUT <> INPUT << EOF 1 ], EOF if [ 2 -ge 1 ]; then - cat >>INPUT <> INPUT << EOF "bands_range": [ EOF for ((i_BL = 1; i_BL < ${BL_number[iSTRU]}; i_BL++)); do - cat >>INPUT <> INPUT << EOF $(printf %.0f ${ref_bands[iSTRU]}), EOF done - cat >>INPUT <> INPUT << EOF $(printf %.0f ${ref_bands[iSTRU]}) ] EOF else - cat >>INPUT <> INPUT << EOF "bands_file": [ ] EOF fi - cat >>INPUT <> INPUT << EOF }, "C_init_info": { EOF C_init_file="ORBITAL_RESULTS.txt" if [ ${RestartSTRU[$iSTRU]} -ge 1 ]; then ## [ "$C_init_from_file" == "true" ]; then - cat >>INPUT <> INPUT << EOF "init_from_file": true, "C_init_file" : "$C_init_file", "opt_C_read" : false EOF echo -e " init_from_file : true, \n C_init_file : $C_init_file, \n opt_C_read: false\n" elif [ ${RestartSTRU[$iSTRU]} -eq 0 ]; then - cat >>INPUT <> INPUT << EOF "init_from_file": false EOF echo -e " init_from_file : false \n " @@ -936,7 +936,7 @@ EOF exit fi - cat >>INPUT <> INPUT << EOF }, "V_info": { @@ -958,7 +958,7 @@ EOF ### len(dis[info["input"]["element"]]), ### (1.4.3.2) prepare INPUT file in json for PyTorch program - cat >INPUT < INPUT << EOF { "file_list": [ EOF @@ -966,13 +966,13 @@ EOF count_files=1 while [ $count_files -lt ${BL_number[iSTRU]} ]; do BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') - cat >>INPUT <> INPUT << EOF "../OUT.$element-$rcut-$BL/orb_matrix.0.dat", EOF let count_files++ done BL=$(echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}') - cat >>INPUT <> INPUT << EOF "../OUT.$element-$rcut-$BL/orb_matrix.0.dat" ], "info": { @@ -1020,11 +1020,11 @@ EOF echo " numL = ${numL[@]}, LValueMax = $LValueMax " for ((LValue = 0; LValue < ${LValueMax}; LValue++)); do - cat >>INPUT <> INPUT << EOF ${numL[$LValue]}, EOF done - cat >>INPUT <> INPUT << EOF ${numL[$LValueMax]} ] }, @@ -1032,18 +1032,18 @@ EOF EOF for ((i_BL = 1; i_BL < ${BL_number[iSTRU]}; i_BL++)); do - cat >>INPUT <> INPUT << EOF ${ref_bands[iSTRU]}, EOF done - cat >>INPUT <> INPUT << EOF ${ref_bands[iSTRU]} ], "weight": [ EOF for ((i_BL = 1; i_BL < ${BL_number[iSTRU]}; i_BL++)); do - cat >>INPUT <> INPUT << EOF 1, EOF done @@ -1052,7 +1052,7 @@ EOF else lr_value=0.01 fi - cat >>INPUT <> INPUT << EOF 1 ], "Rcut": { @@ -1073,13 +1073,13 @@ EOF C_init_file="ORBITAL_RESULTS.txt" if [ ${RestartSTRU[$iSTRU]} -ge 1 ]; then ## [ "$C_init_from_file" == "true" ]; then - cat >>INPUT <> INPUT << EOF "init_from_file": true, "C_init_file" : "$C_init_file" EOF echo -e " init_from_file : true \n C_init_file : $C_init_file \n " elif [ ${RestartSTRU[$iSTRU]} -eq 0 ]; then - cat >>INPUT <> INPUT << EOF "init_from_file": false EOF echo -e " init_from_file : false \n " @@ -1087,7 +1087,7 @@ EOF exit fi - cat >>INPUT <> INPUT << EOF }, "V_info": { "same_band": true, diff --git a/tools/01_NAO_generation/examples/example_opt_lcao_bash/generate_orbital_mixstru.sh b/tools/01_NAO_generation/examples/example_opt_lcao_bash/generate_orbital_mixstru.sh index 1ff346ba6d3..78f5427b3eb 100755 --- a/tools/01_NAO_generation/examples/example_opt_lcao_bash/generate_orbital_mixstru.sh +++ b/tools/01_NAO_generation/examples/example_opt_lcao_bash/generate_orbital_mixstru.sh @@ -54,7 +54,7 @@ if [ -z "$EXE_mpi" ]; then cpu_num=8 hostfpath="myhosts" #hostfpath="/home/nic/wszhang/eclipse_project/mesia_dft/delta_test/delta_dft/cifs2deltaDFT/myhosts" - grep slots $hostfpath >/dev/null + grep slots $hostfpath > /dev/null if [ $? = 0 ]; then # has "slots" in file: $hostfpath cpu_num=$(cat $hostfpath | cut -d "=" -f 2-3 | awk '{sum += $1};END {print sum}') else @@ -379,7 +379,7 @@ for name in $targets; do if [ "${ListSTRU[iSTRU]}" == "dimer" ]; then na=2 - cat >$name.stru < $name.stru << EOF ATOMIC_SPECIES $element $mass $pseudofile LATTICE_CONSTANT @@ -399,7 +399,7 @@ EOF elif [ "${ListSTRU[iSTRU]}" == "trimer" ]; then na=3 - cat >$name.stru < $name.stru << EOF ATOMIC_SPECIES $element $mass $pseudofile LATTICE_CONSTANT @@ -420,7 +420,7 @@ EOF elif [ "${ListSTRU[iSTRU]}" == "tetramer" ]; then na=4 - cat >$name.stru < $name.stru << EOF ATOMIC_SPECIES $element $mass $pseudofile LATTICE_CONSTANT @@ -444,7 +444,7 @@ EOF echo " na=$na" # (1.4.2.2) get KPOINTS - cat >KPOINTS < KPOINTS << EOF K_POINTS 0 Gamma @@ -452,14 +452,14 @@ Gamma EOF # (1.4.2.3) get INPUTw - cat >INPUTw < INPUTw << EOF WANNIER_PARAMETERS rcut 10 out_spillage 2 EOF # (1.4.2.4) get INPUTs - cat >INPUTs < INPUTs << EOF INPUT_ORBITAL_INFORMATION 1 // smooth or not @@ -471,7 +471,7 @@ $rcut // cutoff of wavefunctions(a.u.) EOF # (1.4.2.5) get INPUT - cat >INPUT < INPUT << EOF INPUT_PARAMETERS suffix $element-$rcut-$BL latname $element-$rcut-$BL @@ -620,7 +620,7 @@ EOF fi ### (1.4.3.2) prepare for the INPUT file - cat >INPUT < INPUT << EOF 1 // if or not calculate the spillage. 1/0 $isrestart // restart or not. 1/0 @@ -632,13 +632,13 @@ EOF count_files=1 while [ $count_files -le ${BL_number[iSTRU]} ]; do BL=$(echo "${info[iSTRU]}" | awk '{print $'$count_files'}') - cat >>INPUT <> INPUT << EOF ../$element-$rcut-$BL.$lat0.dat EOF let count_files++ done - cat >>INPUT <> INPUT << EOF @@ -686,7 +686,7 @@ ${ref_bands[iSTRU]} // int, the ed band index(>INPUT <> INPUT << EOF ${LevelEnd[iSTRU]} // Number of levels. label / na / skip / lmax / each L / @@ -699,16 +699,16 @@ EOF leveltype="skip" fi #echo "leveltype=$leveltype" - cat >>INPUT <> INPUT << EOF $id $na $leveltype ${L[i]} EOF done - cat >>INPUT <> INPUT << EOF EOF - cat >>INPUT <> INPUT << EOF 0.01 //dr(a.u.) of uniform mesh. Attention!!dr will affect kinetic energy minmized largely. -6 //xmin diff --git a/tools/01_NAO_generation/examples/example_opt_lcao_bash/opt_orb/sub.sh b/tools/01_NAO_generation/examples/example_opt_lcao_bash/opt_orb/sub.sh index 0eafea01387..4e31613c6fe 100644 --- a/tools/01_NAO_generation/examples/example_opt_lcao_bash/opt_orb/sub.sh +++ b/tools/01_NAO_generation/examples/example_opt_lcao_bash/opt_orb/sub.sh @@ -5,4 +5,4 @@ #BSUB -m node151 export OMP_NUM_THREADS=8 EXEC=/home/nic/wszhang/eclipse_project/abacus-NewGit/ABACUS.1.0.0/tools/tools_exx/opt_orb_pytorch/main.py -python3 $EXEC >running_stdout.log +python3 $EXEC > running_stdout.log diff --git a/tools/01_NAO_generation/examples/example_opt_lcao_bash/pre_run.sh b/tools/01_NAO_generation/examples/example_opt_lcao_bash/pre_run.sh index b4544067787..3322b92e5c0 100755 --- a/tools/01_NAO_generation/examples/example_opt_lcao_bash/pre_run.sh +++ b/tools/01_NAO_generation/examples/example_opt_lcao_bash/pre_run.sh @@ -3,9 +3,9 @@ #bsub -q idle -E ./pre_run.sh -oo %J.log touch 000 if [ $(($(date +%s) % 20)) -le 10 ]; then - echo $(date +%s) " requeue" >>001 + echo $(date +%s) " requeue" >> 001 exit 1 else - echo $(date +%s) " run" >>001 + echo $(date +%s) " run" >> 001 exit 0 fi diff --git a/tools/04_windows_installation/provision.sh b/tools/04_windows_installation/provision.sh index 75b2d967e35..3a7db9e121a 100644 --- a/tools/04_windows_installation/provision.sh +++ b/tools/04_windows_installation/provision.sh @@ -85,7 +85,7 @@ fi log "Installing system launchers..." -cat >/usr/local/bin/abacus < /usr/local/bin/abacus << EOF #!/usr/bin/env bash # Cap OpenMP threads to 1 by default to avoid oversubscription. # Override from Windows via: set OMP_NUM_THREADS=4 (forwarded through WSLENV). @@ -97,7 +97,7 @@ exec "$ENV_BIN/abacus" "\$@" EOF chmod +x /usr/local/bin/abacus -cat >/usr/local/bin/abacus-mpi < /usr/local/bin/abacus-mpi << EOF #!/usr/bin/env bash : "\${OMP_NUM_THREADS:=1}" export OMP_NUM_THREADS @@ -114,7 +114,7 @@ EOF chmod +x /usr/local/bin/abacus-mpi log "Verifying..." -if /usr/local/bin/abacus --version >/dev/null 2>&1; then +if /usr/local/bin/abacus --version > /dev/null 2>&1; then /usr/local/bin/abacus --version || true elif [ -x "$ENV_BIN/abacus" ]; then log "abacus binary present at $ENV_BIN/abacus (no --version flag)." From b38aa08b868571c3577e71b66aba94da53e6d23e Mon Sep 17 00:00:00 2001 From: SY Wang Date: Tue, 3 Nov 2026 19:32:24 +0800 Subject: [PATCH 2/2] Make precommit check relevant --- .github/workflows/precommit.yml | 2 - .pre-commit-config.yaml | 8 ++-- source/CMakeLists.txt | 7 ++-- source/source_base/CMakeLists.txt | 11 ++---- source/source_base/test/CMakeLists.txt | 5 +-- .../source_base/test_parallel/CMakeLists.txt | 2 +- .../module_ao/test/CMakeLists.txt | 2 +- source/source_cell/CMakeLists.txt | 7 +--- .../module_neighlist/test/CMakeLists.txt | 3 +- source/source_cell/test/CMakeLists.txt | 11 ++---- source/source_hsolver/CMakeLists.txt | 4 +- .../source_hsolver/unittests/CMakeLists.txt | 37 +++++++++++-------- source/source_io/unittests/CMakeLists.txt | 13 ++++--- .../source_lcao/module_lr/test/CMakeLists.txt | 5 +-- .../module_ri/unittests/CMakeLists.txt | 3 +- source/source_md/module_snap/CMakeLists.txt | 11 +----- .../module_snap/unittest/CMakeLists.txt | 24 +++++------- .../module_dfpt/test_serial/CMakeLists.txt | 6 +-- 18 files changed, 71 insertions(+), 90 deletions(-) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index a4a9764dd12..89cf388d635 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -18,5 +18,3 @@ jobs: with: python-version: '3.12' - uses: pre-commit/action@v3.0.1 - # TODO: Drop "continue-on-error" - continue-on-error: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a06159a5077..53fa926757d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,10 +6,10 @@ repos: - id: mixed-line-ending args: [--fix=lf] exclude: '(\.bat|\.cmd)$' - - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v23.1.3 - hooks: - - id: clang-format +# - repo: https://github.com/pre-commit/mirrors-clang-format +# rev: v23.1.3 +# hooks: +# - id: clang-format - repo: https://github.com/cheshirekow/cmake-format-precommit rev: v0.6.13 hooks: diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index ae735fb8d83..bb3b6971d2f 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -172,9 +172,10 @@ if(USE_DSP) endif() list(APPEND _abacus_linalg_libs ${_abacus_cpack_library}) else() - message(STATUS - "USE_DSP without MT_CPACK_DIR: C_PACK disabled, the serial generalized " - "eigensolver falls back to the configured LAPACK provider (zhegvx).") + message( + STATUS + "USE_DSP without MT_CPACK_DIR: C_PACK disabled, the serial generalized " + "eigensolver falls back to the configured LAPACK provider (zhegvx).") endif() endif() diff --git a/source/source_base/CMakeLists.txt b/source/source_base/CMakeLists.txt index f10de773b79..cba009a187d 100644 --- a/source/source_base/CMakeLists.txt +++ b/source/source_base/CMakeLists.txt @@ -90,20 +90,17 @@ endif() if(BUILD_TESTING) # TODO: classify the serial and parrallel tests - AddTest( + addtest( TARGET MODULE_BASE_block_cyclic_distribution LIBS parameter base device container - SOURCES test/test_block_cyclic_distribution.cpp - ) + SOURCES test/test_block_cyclic_distribution.cpp) if(ENABLE_MPI) add_test( NAME MODULE_BASE_block_cyclic_distribution_mpi COMMAND - ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 4 - ${MPIEXEC_PREFLAGS} + ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS} $ - ${MPIEXEC_POSTFLAGS} - ) + ${MPIEXEC_POSTFLAGS}) add_subdirectory(test) add_subdirectory(test_parallel) add_subdirectory(kernels/test) diff --git a/source/source_base/test/CMakeLists.txt b/source/source_base/test/CMakeLists.txt index 814d5ea2765..e8c0a5c8e25 100644 --- a/source/source_base/test/CMakeLists.txt +++ b/source/source_base/test/CMakeLists.txt @@ -277,8 +277,7 @@ if(ENABLE_GOOGLEBENCH) SOURCES perf_sphbes_test.cpp ../math_sphbes.cpp ../timer.cpp) endif() -AddTest( +addtest( TARGET MODULE_BASE_filename LIBS parameter base device - SOURCES test_filename.cpp -) + SOURCES test_filename.cpp) diff --git a/source/source_base/test_parallel/CMakeLists.txt b/source/source_base/test_parallel/CMakeLists.txt index 048e18ea338..f40735024c0 100644 --- a/source/source_base/test_parallel/CMakeLists.txt +++ b/source/source_base/test_parallel/CMakeLists.txt @@ -86,7 +86,7 @@ add_test( COMMAND mpirun -np 4 "$" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -AddTest( +addtest( TARGET MODULE_BASE_parallel_domain_grid SOURCES parallel_domain_grid_test.cpp ../test/mpi_test_main.cpp LIBS parameter MPI::MPI_CXX base device) diff --git a/source/source_basis/module_ao/test/CMakeLists.txt b/source/source_basis/module_ao/test/CMakeLists.txt index 2a978ddd754..24c5d726dba 100644 --- a/source/source_basis/module_ao/test/CMakeLists.txt +++ b/source/source_basis/module_ao/test/CMakeLists.txt @@ -31,7 +31,7 @@ list( ../../../source_base/libm/sincos.cpp ../../../source_base/sph_bessel_tf.cpp ../../../source_base/cubic_spline.cpp - ../../../source_base/block_cyclic_distribution.cpp + ../../../source_base/block_cyclic_distribution.cpp ../orb_read.cpp ../orb_atomic.cpp ../orb_atomic_lm.cpp diff --git a/source/source_cell/CMakeLists.txt b/source/source_cell/CMakeLists.txt index 535891ec64c..4a7c735bff0 100644 --- a/source/source_cell/CMakeLists.txt +++ b/source/source_cell/CMakeLists.txt @@ -2,11 +2,8 @@ add_subdirectory(module_symmetry) add_subdirectory(module_neighbor) add_subdirectory(module_neighlist) -add_library(domain_decomposition OBJECT - dom_core.cpp - dom_ghost.cpp - dom_migrate.cpp - dom_force.cpp) +add_library(domain_decomposition OBJECT dom_core.cpp dom_ghost.cpp + dom_migrate.cpp dom_force.cpp) add_library( cell OBJECT diff --git a/source/source_cell/module_neighlist/test/CMakeLists.txt b/source/source_cell/module_neighlist/test/CMakeLists.txt index b5ffaf299e0..14d5bb4df7c 100644 --- a/source/source_cell/module_neighlist/test/CMakeLists.txt +++ b/source/source_cell/module_neighlist/test/CMakeLists.txt @@ -7,7 +7,8 @@ abacus_disable_feature_definitions(__EXX) addtest( TARGET MODULE_CELL_NEIGHBOR_neighbor_search LIBS parameter base device cell neighbor symmetry - SOURCES test_neighbor_search.cpp ../neighbor_search.cpp + SOURCES test_neighbor_search.cpp + ../neighbor_search.cpp ../../dom_core.cpp ../../dom_ghost.cpp ../../dom_migrate.cpp diff --git a/source/source_cell/test/CMakeLists.txt b/source/source_cell/test/CMakeLists.txt index db18828ac0f..28bec1ab904 100644 --- a/source/source_cell/test/CMakeLists.txt +++ b/source/source_cell/test/CMakeLists.txt @@ -54,14 +54,9 @@ addtest( SOURCES test_cell_geometry.cpp ../cell_geometry.cpp) addtest( - TARGET - MODULE_CELL_stru_frame_io - LIBS - base - device - SOURCES - test_stru_frame_io.cpp - ../stru_frame_io.cpp) + TARGET MODULE_CELL_stru_frame_io + LIBS base device + SOURCES test_stru_frame_io.cpp ../stru_frame_io.cpp) if(NOT ENABLE_MPI) return() diff --git a/source/source_hsolver/CMakeLists.txt b/source/source_hsolver/CMakeLists.txt index a415316e101..b698fd699d2 100644 --- a/source/source_hsolver/CMakeLists.txt +++ b/source/source_hsolver/CMakeLists.txt @@ -29,9 +29,7 @@ if(ENABLE_LCAO) # DSP build without C_PACK: provide the zhegvx_ fallback for # cpack_zhegvx_driver (used by diago_lapack.cpp under __DSP). if(USE_DSP AND NOT MT_CPACK_DIR) - list(APPEND objects - cpack_zhegvx_fallback.cpp - ) + list(APPEND objects cpack_zhegvx_fallback.cpp) endif() if(USE_CUDA) diff --git a/source/source_hsolver/unittests/CMakeLists.txt b/source/source_hsolver/unittests/CMakeLists.txt index 8403099a87b..f4dc84e1257 100644 --- a/source/source_hsolver/unittests/CMakeLists.txt +++ b/source/source_hsolver/unittests/CMakeLists.txt @@ -2,35 +2,40 @@ abacus_disable_feature_definitions(__CUDA) abacus_disable_feature_definitions(__ROCM) abacus_disable_feature_definitions(__EXX) -set(DAV_SUBSPACE_TEST_SOURCES test_diago_dav_subspace.cpp ../diago_dav_subspace.cpp) +set(DAV_SUBSPACE_TEST_SOURCES test_diago_dav_subspace.cpp + ../diago_dav_subspace.cpp) set(DAV_SUBSPACE_TEST_LIBS parameter base device container psi) if(ENABLE_MPI) - list(APPEND DAV_SUBSPACE_TEST_SOURCES ../diag_hs_para.cpp ../diago_pxxxgvx.cpp ../diago_scalapack.cpp) + list(APPEND DAV_SUBSPACE_TEST_SOURCES ../diag_hs_para.cpp + ../diago_pxxxgvx.cpp ../diago_scalapack.cpp) if(ENABLE_ELPA) list(APPEND DAV_SUBSPACE_TEST_SOURCES ../diago_elpa.cpp) list(APPEND DAV_SUBSPACE_TEST_LIBS genelpa ELPA::ELPA) endif() endif() -AddTest( +addtest( TARGET MODULE_HSOLVER_dav_subspace LIBS ${DAV_SUBSPACE_TEST_LIBS} - SOURCES ${DAV_SUBSPACE_TEST_SOURCES} -) + SOURCES ${DAV_SUBSPACE_TEST_SOURCES}) if(ENABLE_MPI) - add_test(NAME MODULE_HSOLVER_dav_subspace_parallel - COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 2 ${MPIEXEC_PREFLAGS} - $ --gtest_filter=DavSubspaceTest/0.*:DavSubspace.* ${MPIEXEC_POSTFLAGS}) - set_tests_properties(MODULE_HSOLVER_dav_subspace_parallel PROPERTIES PROCESSORS 2 TIMEOUT 120) + add_test( + NAME MODULE_HSOLVER_dav_subspace_parallel + COMMAND + ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 2 ${MPIEXEC_PREFLAGS} + $ + --gtest_filter=DavSubspaceTest/0.*:DavSubspace.* ${MPIEXEC_POSTFLAGS}) + set_tests_properties(MODULE_HSOLVER_dav_subspace_parallel + PROPERTIES PROCESSORS 2 TIMEOUT 120) endif() if(USE_CUDA OR USE_ROCM) - AddTest( + addtest( TARGET MODULE_HSOLVER_dav_subspace_gpu LIBS ${DAV_SUBSPACE_TEST_LIBS} SOURCES ${DAV_SUBSPACE_TEST_SOURCES} - KEEP_FEATURE_DEFINITIONS __CUDA __ROCM - ) - target_compile_definitions(MODULE_HSOLVER_dav_subspace_gpu PRIVATE ABACUS_DAV_GPU_TEST) + KEEP_FEATURE_DEFINITIONS __CUDA __ROCM) + target_compile_definitions(MODULE_HSOLVER_dav_subspace_gpu + PRIVATE ABACUS_DAV_GPU_TEST) endif() if(ENABLE_MPI) @@ -120,12 +125,14 @@ if(ENABLE_MPI) TARGET MODULE_HSOLVER_LCAO LIBS parameter ELPA::ELPA base genelpa psi device SOURCES test_diago_lcao.cpp ../diago_elpa.cpp ../diago_elpa_native.cpp - ../diago_scalapack.cpp ../diago_lapack.cpp ${_dsp_cpack_fallback_src}) + ../diago_scalapack.cpp ../diago_lapack.cpp + ${_dsp_cpack_fallback_src}) else() addtest( TARGET MODULE_HSOLVER_LCAO LIBS parameter base psi device - SOURCES test_diago_lcao.cpp ../diago_scalapack.cpp ../diago_lapack.cpp ${_dsp_cpack_fallback_src}) + SOURCES test_diago_lcao.cpp ../diago_scalapack.cpp ../diago_lapack.cpp + ${_dsp_cpack_fallback_src}) endif() if(TARGET PEXSI::PEXSI) diff --git a/source/source_io/unittests/CMakeLists.txt b/source/source_io/unittests/CMakeLists.txt index 7f7b4754807..79abb120c58 100644 --- a/source/source_io/unittests/CMakeLists.txt +++ b/source/source_io/unittests/CMakeLists.txt @@ -22,7 +22,8 @@ if(NOT ENABLE_MPI) endif() add_executable( - MODULE_IO_input_error_mpi test_read_input.cpp + MODULE_IO_input_error_mpi + test_read_input.cpp # io_input references stru_frame_io::extract_last_frame without linking cell. ../../source_cell/stru_frame_io.cpp) target_link_libraries( @@ -69,9 +70,10 @@ abacus_copy_test_files(support INPUTs) addtest( TARGET MODULE_IO_input_test_para LIBS parameter base device io_input - SOURCES test_read_input_parallel.cpp - # io_input references stru_frame_io::extract_last_frame without linking cell. - ../../source_cell/stru_frame_io.cpp) + SOURCES + test_read_input_parallel.cpp + # io_input references stru_frame_io::extract_last_frame without linking cell. + ../../source_cell/stru_frame_io.cpp) add_test( NAME MODULE_IO_input_test_para_4 @@ -320,8 +322,7 @@ if(ENABLE_LIBRI) LIBS parameter base device SOURCES test_restart_exx_csr.cpp ../module_restart/restart_exx_csr.cpp ../module_hs/hs_sparse_io.cpp ../module_hs/lat_r_csr.cpp - ../../source_basis/module_ao/parallel_orbitals.cpp - tmp_mocks.cpp) + ../../source_basis/module_ao/parallel_orbitals.cpp tmp_mocks.cpp) endif() addtest(TARGET MODULE_IO_write_elf_logic_test SOURCES test_write_elf_logic.cpp) diff --git a/source/source_lcao/module_lr/test/CMakeLists.txt b/source/source_lcao/module_lr/test/CMakeLists.txt index c6180ff87ed..27d8bcf7768 100644 --- a/source/source_lcao/module_lr/test/CMakeLists.txt +++ b/source/source_lcao/module_lr/test/CMakeLists.txt @@ -162,7 +162,4 @@ if(ENABLE_MPI) "OMP_NUM_THREADS=1;MKL_NUM_THREADS=1;OPENBLAS_NUM_THREADS=1") endif() -AddTest( - TARGET MODULE_LR_spectrum_weights - SOURCES test_spectrum_weights.cpp -) +addtest(TARGET MODULE_LR_spectrum_weights SOURCES test_spectrum_weights.cpp) diff --git a/source/source_lcao/module_ri/unittests/CMakeLists.txt b/source/source_lcao/module_ri/unittests/CMakeLists.txt index 68c87eed0ac..b034a4c54dc 100644 --- a/source/source_lcao/module_ri/unittests/CMakeLists.txt +++ b/source/source_lcao/module_ri/unittests/CMakeLists.txt @@ -43,7 +43,8 @@ target_link_options(MODULE_RI_invmat_ri PRIVATE -Wl,--gc-sections) addtest( TARGET MODULE_RI_hybrid_gauge_phase_test LIBS parameter base device - SOURCES test_hybrid_gauge_phase.cpp ../hybrid_gauge_phase.cpp ../mix_dmk_2d.cpp) + SOURCES test_hybrid_gauge_phase.cpp ../hybrid_gauge_phase.cpp + ../mix_dmk_2d.cpp) addtest( TARGET MODULE_RI_hybrid_image_domain_test diff --git a/source/source_md/module_snap/CMakeLists.txt b/source/source_md/module_snap/CMakeLists.txt index c10bf8ed1d0..ada55cffcdd 100644 --- a/source/source_md/module_snap/CMakeLists.txt +++ b/source/source_md/module_snap/CMakeLists.txt @@ -1,12 +1,5 @@ -target_sources( - md - PRIVATE - snap_calculator.cpp - snap_descriptor.cpp - snap_derivative.cpp - snap_model.cpp - snap_cg.cpp -) +target_sources(md PRIVATE snap_calculator.cpp snap_descriptor.cpp + snap_derivative.cpp snap_model.cpp snap_cg.cpp) if(BUILD_TESTING) add_subdirectory(unittest) diff --git a/source/source_md/module_snap/unittest/CMakeLists.txt b/source/source_md/module_snap/unittest/CMakeLists.txt index 86495fdb4ed..82bb9d374d1 100644 --- a/source/source_md/module_snap/unittest/CMakeLists.txt +++ b/source/source_md/module_snap/unittest/CMakeLists.txt @@ -1,21 +1,17 @@ -AddTest( - TARGET MODULE_MD_SNAP_model - SOURCES test_snap_model.cpp ../snap_model.cpp -) +addtest(TARGET MODULE_MD_SNAP_model SOURCES test_snap_model.cpp + ../snap_model.cpp) -AddTest( - TARGET MODULE_MD_SNAP_cg - SOURCES test_snap_cg.cpp ../snap_cg.cpp -) +addtest(TARGET MODULE_MD_SNAP_cg SOURCES test_snap_cg.cpp ../snap_cg.cpp) -AddTest( +addtest( TARGET MODULE_MD_SNAP_descriptor LIBS base device - SOURCES test_snap_descriptor.cpp ../snap_descriptor.cpp ../snap_derivative.cpp ../snap_model.cpp ../snap_cg.cpp -) + SOURCES test_snap_descriptor.cpp ../snap_descriptor.cpp + ../snap_derivative.cpp ../snap_model.cpp ../snap_cg.cpp) -AddTest( +addtest( TARGET MODULE_MD_SNAP_calculator LIBS base device - SOURCES test_snap_calculator.cpp ../snap_calculator.cpp ../snap_descriptor.cpp ../snap_derivative.cpp ../snap_model.cpp ../snap_cg.cpp -) + SOURCES test_snap_calculator.cpp ../snap_calculator.cpp + ../snap_descriptor.cpp ../snap_derivative.cpp ../snap_model.cpp + ../snap_cg.cpp) diff --git a/source/source_pw/module_dfpt/test_serial/CMakeLists.txt b/source/source_pw/module_dfpt/test_serial/CMakeLists.txt index 906b63bb92c..c935a57877f 100644 --- a/source/source_pw/module_dfpt/test_serial/CMakeLists.txt +++ b/source/source_pw/module_dfpt/test_serial/CMakeLists.txt @@ -144,10 +144,10 @@ if(ENABLE_LIBXC) SOURCES dfpt_xc_analytic_serial_test.cpp ../dfpt_xc_analytic.cpp ../dfpt_rho.cpp - ../dfpt_rho_mix.cpp - ../../../source_estate/module_charge/chg_tools.cpp + ../dfpt_rho_mix.cpp + ../../../source_estate/module_charge/chg_tools.cpp ../dfpt_pw_data.cpp - ../dfpt_pw_data_resp.cpp + ../dfpt_pw_data_resp.cpp ../dfpt_kq_basis.cpp ../../../source_cell/qlist.cpp ../../../source_cell/reciprocal_grid.cpp