Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 11 additions & 12 deletions examples/13_dos/01_pw_Al/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ 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
[[ ! -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
echo "job succeeded!"
exit 0
fi
23 changes: 11 additions & 12 deletions examples/13_dos/02_lcao_Si2/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ 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
[[ ! -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
echo "job succeeded!"
exit 0
fi
10 changes: 5 additions & 5 deletions examples/32_bsse/01_water/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 13 additions & 13 deletions generate_build_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]}"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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 - </dev/null 2>&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))
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."
4 changes: 2 additions & 2 deletions interfaces/ShengBTE_interface/01_pw/3rd/run_stru.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ for i in STRU_*; do
mkdir SCF-$stru
cd SCF-$stru
pwd
cat >INPUT <<EOF
cat > INPUT << EOF
INPUT_PARAMETERS
#Parameters (General)
suffix DIA-50-$stru
Expand All @@ -32,7 +32,7 @@ mixing_beta 0.7

stru_file STRU_$stru
EOF
cat >KPT <<EOF
cat > KPT << EOF
K_POINTS
0
Gamma
Expand Down
4 changes: 2 additions & 2 deletions interfaces/ShengBTE_interface/02_lcao/3rd/run_stru.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ for i in STRU_*; do
mkdir SCF-$stru
cd SCF-$stru
pwd
cat >INPUT <<EOF
cat > INPUT << EOF
INPUT_PARAMETERS
#Parameters (General)
suffix DIA-50-$stru
Expand All @@ -33,7 +33,7 @@ mixing_beta 0.7

stru_file STRU_$stru
EOF
cat >KPT <<EOF
cat > KPT << EOF
K_POINTS
0
Gamma
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ np=$(awk '/cpu cores/ { print $NF; exit }' /proc/cpuinfo)
echo "nprocs in this machine is $np"

for ranks in 2 3 4; do
if ((ranks > np)); then
continue
fi
echo "TEST in parallel, nprocs=$ranks"
if ! mpirun -np "$ranks" "${1:-./MODULE_AO_parallel_orbitals_composition_test}"; then
echo -e "\e[1;33m [ FAILED ] \e[0m execute UT with $ranks ranks."
exit 1
fi
if ((ranks > np)); then
continue
fi
echo "TEST in parallel, nprocs=$ranks"
if ! mpirun -np "$ranks" "${1:-./MODULE_AO_parallel_orbitals_composition_test}"; then
echo -e "\e[1;33m [ FAILED ] \e[0m execute UT with $ranks ranks."
exit 1
fi
done
8 changes: 4 additions & 4 deletions source/source_basis/module_pw/test/test_gnu.sh
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions source/source_basis/module_pw/test/test_intel.sh
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
#!/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
echo "1 processor:"
./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

Expand Down
22 changes: 11 additions & 11 deletions tests/17_DS_DFTU/run_scf_nscf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ---"
Expand All @@ -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}"
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
Loading
Loading