-
Notifications
You must be signed in to change notification settings - Fork 4
/
libIGCM_post.sh
executable file
·79 lines (66 loc) · 2.3 KB
/
libIGCM_post.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
#!/bin/bash
# Script called by libIGCM for executing the C-ESM-EP code
# Setup parameters are read from libIGCM_post.param (as written by
# libIGCM_install.sh when called by libIGCM ins_job)
# Run-time parameters are provided as arguments. They are date begin and end
# for the time slice to process. In these dates, only years are used
# Execution occurs in the directory of the script, which is a C-ESM-EP code
# 'lite' directory
#set -x
begin=$1
end=$2
cd $(dirname $0)
out=$(pwd)/libIGCM_post.out
# Read setup parameters
read CesmepCode comparison DateBegin CesmepPeriod CesmepSlices \
cache components < libIGCM_post.param
# Analyze if last batch of simulation outputs allow to compute a new
# atlas slice (where slices are aligned with DateBegin and have a
# duration of CesmepPeriod). i.e. that it exists a slice ending in
# the provided data period, If there is multiple such slices, we use
# the last one
DateBegin=${DateBegin:0:4}
begin=${begin:0:4}
end=${end:0:4}
if [ $CesmepPeriod != 0 ] ; then
compute_new_slice=false
slice_end=$(( DateBegin + CesmepPeriod -1 ))
nb=0
while [ $slice_end -le $end ]; do
if [ $slice_end -ge $begin -a $slice_end -le $end ] ; then
compute_new_slice=true
fi
new_end=$(( slice_end + CesmepPeriod ))
if [ $new_end -le $slice_end ] ; then
echo "Issue: cannot increment with CesmepPeriod=$CesmepPeriod "
exit 1
fi
slice_end=$new_end
done
slice_end=$(( slice_end - CesmepPeriod ))
if [ $compute_new_slice = false ] ; then
echo "Not enough data for computing a new atlas slice ">$out
echo "DateBegin=$DateBegin, CesmepPeriod=$CesmepPeriod, begin=$begin, end=$end " >> $out
exit 0
fi
else
slice_end=$end
fi
# Complement settings with runtime parameters
fixed_settings=$comparison/libIGCM_fixed_settings.py
settings=$comparison/libIGCM_settings.py
cat $fixed_settings > $settings
cat <<-EOF >> $settings
end = $slice_end
data_end = $end
EOF
export CESMEP_CLIMAF_CACHE=$cache
echo "Launching atlas for a period ending at $slice_end" > $out
submit_dir=$(basename $(cd ..; pwd))
python3 run_C-ESM-EP.py $comparison $components ${slice_end}_${submit_dir} >> $out 2>&1
if [ $? -ne 0 ] ;then
echo "Issue launching C-ESM-EP atlas - see $out"
exit 1
else
echo "C-ESM-EP atlas succesfully launched - see $out"
fi