-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_daint.sh
executable file
·156 lines (122 loc) · 4.39 KB
/
run_daint.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
# Load settings from defaults, config and user
# ============================================
# Load general defaults
source tools.sh
source defaults.sh
# Load config and user settings once here, just to have access to SB_PARTS
if [[ ! -f config ]]; then
echo "ERROR : No config file found."
echo "- Either use one from simulation_configs e.g. with \`ln -s simulation_configs/SIMULATION_EU_CORDEX_50km ./config\`"
echo "- or write your own ./config"
exit 1
fi
source config
if [[ ! -f user_settings ]]; then
echo "WARNING : No user_setting file found. You could start from the user_settings_example file if needed."
else
source user_settings
fi
# Load Defaults from parts if a non empty "Defaults" directory is found
for part in ${SB_PARTS}; do
if [[ -d ${part}/Defaults ]]; then
if [[ "$(ls -A ${part}/Defaults)" ]]; then
for f in ${part}/Defaults/*; do
source $f
done
fi
fi
done
# Reload config and user settings to ensure user_settings > config > defaults
source config
[[ -f user_settings ]] && source user_settings
# Daint specific settings
# =======================
export PARTITION="normal"
export RUNCMD="srun"
export CORES_PER_NODE=12
# Handle dates
# ============
# Convert dates to formats capable of handling addition of arbitrary time intervals
export LM_INI_DATE=$(date -d "${LM_INI_DATE}" +%c)
export LM_FIN_DATE=$(date -d "${LM_FIN_DATE}" +%c)
# Start date of the simulation (not the chunk)
# If not set by the user, set it to the LM_INI_DATE
if [[ -z "${LM_START_DATE}" ]]; then
export LM_START_DATE=${LM_INI_DATE}
else
export LM_START_DATE=$(date -d "${LM_START_DATE}" +%c)
fi
# Begin date of current step
# If set in 60_chain, keep the value, otherwise, use LM_START_DATE
if [[ -z "${LM_BEGIN_DATE}" ]]; then
export LM_BEGIN_DATE=$(date -d "${LM_START_DATE}" +%c)
fi
# End date of current step
if [[ -z "${LM_CHAIN_INTERVAL}" ]]; then
export LM_END_DATE=${LM_FIN_DATE}
else
END_DATE=$(date -d "${LM_BEGIN_DATE}+${LM_CHAIN_INTERVAL}" +%c)
if (( $(date -d "$END_DATE" +%s) > $(date -d "$LM_FIN_DATE" +%s) )); then
export LM_END_DATE=${LM_FIN_DATE}
else
export LM_END_DATE=${END_DATE}
fi
fi
# Store dates components
export LM_YYYY_INI=$(date -d "${LM_INI_DATE}" +%Y)
export LM_MM_INI=$(date -d "${LM_INI_DATE}" +%m)
export LM_DD_INI=$(date -d "${LM_INI_DATE}" +%d)
export LM_ZZ_INI=$(date -d "${LM_INI_DATE}" +%H)
export LM_YYYY_BEGIN=$(date -d "${LM_BEGIN_DATE}" +%Y)
export LM_MM_BEGIN=$(date -d "${LM_BEGIN_DATE}" +%m)
export LM_DD_BEGIN=$(date -d "${LM_BEGIN_DATE}" +%d) # - ML - unused
export LM_ZZ_BEGIN=$(date -d "${LM_BEGIN_DATE}" +%H) # - ML - unused
export LM_YYYY_END=$(date -d "${LM_END_DATE}" +%Y)
export LM_MM_END=$(date -d "${LM_END_DATE}" +%m)
export LM_DD_END=$(date -d "${LM_END_DATE}" +%d)
export LM_ZZ_END=$(date -d "${LM_END_DATE}" +%H)
# Compute HSTART, HSTOP and RUNTIME_S
export LM_NL_HSTART=$(diff_hours "${LM_INI_DATE}" "${LM_BEGIN_DATE}")
export LM_NL_HSTOP=$(diff_hours "${LM_INI_DATE}" "${LM_END_DATE}")
export LM_NL_RUNTIME_S=$(( (LM_NL_HSTOP-LM_NL_HSTART) * 3600 ))
# Dates for filenames or log messages
export LM_BEGIN_DATE_FR=$(date -d "${LM_BEGIN_DATE}" +%FT%R)
export LM_END_DATE_FR=$(date -d "${LM_END_DATE}" +%FT%R)
export LM_BEGIN_DATE_DG=$(date -d "${LM_BEGIN_DATE}" +%Y%m%d%H%M%S)
export LM_END_DATE_DG=$(date -d "${LM_END_DATE}" +%Y%m%d%H%M%S)
# Init matter
# ===========
if [[ "${LM_BEGIN_DATE}" == "${LM_START_DATE}" ]]; then
export status_file=$(realpath "./status.log")
# do some cleaning
rm -f ${status_file}
fi
# Submit jobs
# ===========
if [[ "${LM_BEGIN_DATE}" != "${LM_START_DATE}" ]]; then
echo "" >> ${status_file}
fi
echo "====> jobs for the priod ${LM_BEGIN_DATE_FR} -- ${LM_END_DATE_FR} <====" >> ${status_file}
echo "" >> ${status_file}
export LM_RUN_OUTPUT="run_${LM_BEGIN_DATE_DG}_${LM_END_DATE_DG}.out"
for part in ${SB_PARTS} ; do
export short=${part#[0-9]*_}
export SHORT=$(echo ${short} | tr '[:lower:]' '[:upper:]')
# Enter part directory
# --------------------
pushd ${part} >&/dev/null
# Submit job
# ----------
if [[ -e submit.sh ]]; then
jobid=$(./submit.sh)
else
jobid=$(submit)
fi
# Store job id
# ------------
eval export current_${short}_id=\${jobid}
# Exit part directory
# -------------------
popd >&/dev/null
done