#!/bin/bash
#SBATCH -J cfx-96
#SBATCH --qos=qos_cpu_large
#SBATCH -p CPU-Large
#SBATCH -N 3
#SBATCH -n 96
#SBATCH --exclusive

# 环境变量（保留必要配置，删除SSH相关）
export LD_LIBRARY_PATH=/home/nic/pirate/test/software/test/cfx/32:$LD_LIBRARY_PATH
export LC_ALL=C
export CFX=/home/nic/pirate/test/software/ansys-install/v221/CFX/bin/cfx5solve

# 关键修改：禁用SSH，改用SLURM原生MPI
unset CFX5RSH  # 清空SSH设置，强制使用MPI启动
export I_MPI_HYDRA_BOOTSTRAP=slurm  # Intel MPI用SLURM启动，无需SSH

cd ${SLURM_SUBMIT_DIR}
mkdir -p output

# 【核心修改】直接用mpirun启动CFX求解器，完全绕开SSH
# 格式：mpirun -np 总核数 cfx5solve -def 输入文件 -ccl 集群文件 -par-dist "hosts:核数"
cd output
mpirun -np 96 \
$CFX -def ../$INPUTFILE -ccl ../a4.ccl \
-par-dist "`srun hostname | sort -u | awk '{printf "%s:%d,", $0, 32}' | sed 's/,$//'`" \
-start-method "Intel MPI Distributed Parallel"
