-
Notifications
You must be signed in to change notification settings - Fork 1
/
1Nfinal_run.sh
executable file
·105 lines (82 loc) · 2.56 KB
/
1Nfinal_run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
#SBATCH -N 1
#SBATCH -n 64
#SBATCH -w hepnode0
#SBATCH --exclusive
#SBATCH --output=./output/slurm-%j.out
echo "******final_run.sh*******"
cat $0
echo "******final_run.sh*******"
source ./env.sh
message=$2
# days=$3
run ( ) {
if [ $(hostname) != "hepnode0" ]; then
export UCX_RC_PATH_MTU=2048
export I_MPI_HYDRA_RMK=slurm
export I_MPI_PIN=off
export OMP_NUM_THREADS=1
fi
export I_MPI_PIN=off
case_name=$1
node=$2
proc=$3
# days=$4
adv_exe_absolute_path=$(readlink -f ./build/gmcore_adv_driver.exe)
swm_exe_absolute_path=$(readlink -f ./build/gmcore_swm_driver.exe)
normal_exe_absolute_path=$(readlink -f ./build/gmcore_driver.exe)
prefix="./run/GMCORE-TESTBED/"
suffix="/namelist"
namelist_relative_path="${prefix}${case_name}/${suffix}"
namelist_absolute_path=$(readlink -f ${namelist_relative_path} )
echo namelist_absolute_path: ${namelist_absolute_path}
data_path="/data/gomars_output/$(whoami)/${case_name}/N${2}n${3}/"${message}"-$(date +"%y-%m-%d")"
# now_dir="/data/gomars_output/$(whoami)/${case_name}/N${2}n${3}/"${message}"-$(date +"%y-%m-%d")/opt.nc"
days=$(grep 'run_days' ${namelist_absolute_path} | sed 's/.*= *\([0-9]*\).*/\1/')
check_file="/data/gomars_output/public/N${2}n${3}/${case_name}_${days}days/baseline.nc"
check_dir="/data/gomars_output/public/N${2}n${3}/"
if [ -f "$check_file" ]; then
echo "exist!"
else
echo "not exist, use default path at N1n16!"
echo "!!! You should notice days!"
check_file="/data/gomars_output/public/N1n16/${case_name}_${days}days/baseline.nc"
fi
cd ..
current_dir=$(pwd)
cd gmcore/
if [ ! -d ${data_path} ]; then
mkdir -p ${data_path}
fi
pushd ${data_path}
if [[ $namelist_absolute_path == *"adv"* ]]; then
echo "adv case"
exe_absolute_path=$adv_exe_absolute_path
elif [[ $namelist_absolute_path == *"swm"* ]]; then
echo "swm case"
exe_absolute_path=$swm_exe_absolute_path
else
echo "normal case"
exe_absolute_path=$normal_exe_absolute_path
fi
# bash -c "mpirun -n $3 -ppn $( expr $3 / $2 ) $exe_absolute_path $namelist_absolute_path" #doesn't work
mpirun -n $3 -ppn $( expr $3 / $2 ) $exe_absolute_path $namelist_absolute_path
# mpirun -n $3 -ppn $( expr $3 / $2 ) ${current_dir}/bind_cpu.sh $exe_absolute_path $namelist_absolute_path
now_dir="/data/gomars_output/$(whoami)/${case_name}/N${2}n${3}/"${message}"-$(date +"%y-%m-%d")/opt.nc"
popd
}
if [ -z $1 ]; then
echo "Usage: $0 <case_list> <message>"
exit 1
fi
cmd_array=()
while IFS= read -r cmd
do
cmd_array+=("$cmd")
done < $1
for cmd in "${cmd_array[@]}"
do
pushd ./gmcore
run $cmd $2
popd
done