-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·203 lines (178 loc) · 6.01 KB
/
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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#! /bin/bash
## info: dossier 38x36 dans corrk --> option -i 38 -v 36
usefcm=1
#------------------------------------------------------------------
# On ciclad or climserv, load a recent gfortran compiler
hostname=`hostname`
case ${hostname:0:6} in
ciclad|camelo|merlin) module load gnu/7.2.0 ;
echo Loaded gnu/7.2.0 ;;
esac
#------------------------------------------------------------------
# Opening compiler setting file
if [ $# -eq 1 ]
then
setupfile=$1
else
setupfile="reglages_compiler.txt"
fi
if ! [ -e $setupfile ]
then
echo "Sorry, $setupfile file does not exist."
exit
fi
# Setting the variables
for skey in keyname keynx keyny keynz keytr keybir keybvi keydyn keyrestart keyquick ; do
if [ "`grep -c $skey $setupfile`" = 0 ] ; then
echo $skey is not specified in $setupfile;
exit
else
paramval=`grep $skey $setupfile | awk '{print $1}' | tail -n 1`
case $skey in
keyname) name=$paramval && echo $skey=$name ;;
keydyn) dyncore=$paramval && echo $skey=$dyncore ;;
keyrestart) isrestart=$paramval && echo $skey=$isrestart ;;
keynx) nx=$paramval && echo $skey=$nx ;;
keyny) ny=$paramval && echo $skey=$ny ;;
keynz) nz=$paramval && echo $skey=$nz ;;
keytr) tr=$paramval && echo $skey=$tr ;;
keybir) bir=$paramval && echo $skey=$bir ;;
keybvi) bvi=$paramval && echo $skey=$bvi ;;
keyquick) quick=$paramval && echo $skey=$quick ;;
*) echo "Unknown option"
exit;;
esac
fi
done
# Activating the dynamical core if necessary
case $dyncore in
0) cppkey="-cpp NODYN" ;;
1) cppkey="" ;;
*) echo "Wrong value of the -dyn option"
exit ;;
esac
# Simulation folder
zedate=`date --rfc-3339=seconds | sed s+' '+'_'+g | sed s+':'+'-'+g | awk -F '+' '{print $1}'`
dirname="exp_"$name"_"$zedate
echo "*** Simulation folder : $dirname"
#------------------------------------------------------------------
## script
##-------
thisfolder=$PWD
mod=$PWD/MODELES/
gcmexec="gcm_"$nx"x"$ny"x"$nz"_phystd_seq.e"
if [[ $quick == 0 ]]; then
echo "*** COMPILATION GCM *** ne pas interrompre ***"
## perform makbands here
## to be sure to take into account
## changes in bir and/or bvi
cd $mod/LMDZ.COMMON/libf/phystd/bands
\rm bands.$bir.$bvi > /dev/null 2> /dev/null
./makbands $bir $bvi > /dev/null 2> /dev/null
## OK now compile GCM
# In case a previous compilation went wrong...
\rm $mod/LMDZ.COMMON/libf/grid/dimensions.h 2> /dev/null
if [ $usefcm -eq 1 ] ; then
fcmpath=$mod/FCM_V1.2/bin
PATH=$PATH:$fcmpath
cd $mod/LMDZ.COMMON
\rm "bin/"$gcmexec 2> /dev/null
./makelmdz_fcm $cppkey -d $nx"x"$ny"x"$nz \
-b $bir"x"$bvi -t $tr -s 1 \
-io noioipsl \
-p std -arch gfortran_mod gcm > logcompilegcm 2> logcompilegcm
if [[ ! -f "bin/"$gcmexec ]] ; then
echo "Il y a eu un probleme. Voir : " $PWD/logcompilegcm ; exit
fi
else
cd $mod/LMDZ.COMMON ; \rm gcm.e 2> /dev/null
./makelmdz $cppkey -d $nx"x"$ny"x"$nz -b $bir"x"$bvi -t $tr -s 1 \
-io noioipsl \
-p std -arch gfortran_mod gcm > logcompilegcm 2> logcompilegcm
if [[ ! -f gcm.e ]] ; then
echo "Il y a eu un probleme. Voir : " $PWD/logcompilegcm ; exit
fi
fi
if [[ $isrestart == 0 ]]; then
echo "*** COMPILATION NEWSTART *** ne pas interrompre ***"
if [ $usefcm -eq 1 ] ; then
cd $mod/LMDZ.COMMON
newstartexec="newstart_"$nx"x"$ny"x"$nz"_phystd_seq.e"
\rm "bin/"$newstartexec 2> /dev/null
./makelmdz_fcm -d $nx"x"$ny"x"$nz -p std \
-io noioipsl \
-arch gfortran_mod newstart > logcompilenewstart 2> logcompilenewstart
if [[ ! -f "bin/"$newstartexec ]] ; then
echo "Il y a eu un probleme. Voir : " $PWD/logcompilenewstart ; exit
fi
else
cd $mod/LMDZ.COMMON ; \rm newstart.e 2> /dev/null
./makelmdz -d $nx"x"$ny"x"$nz -p std \
-io noioipsl \
-arch gfortran_mod newstart > logcompilenewstart 2> logcompilenewstart
if [[ ! -f newstart.e ]] ; then
echo "Il y a eu un probleme. Voir : " $PWD/logcompilenewstart ; exit
fi
fi
echo "*** INITIALISATION ***"
if [ $usefcm -eq 1 ] ; then
cd $mod/LMDZ.COMMON
ln -sf "bin/"$newstartexec newstart.e
fi
cd $thisfolder/INIT ; \rm restartfi.nc restart.nc > /dev/null 2> /dev/null
./newstart.e < planet_start > log_newstart 2> log_newstart
if [[ ! -f restart.nc ]] ; then
echo "Il y a eu un probleme. Voir : " $PWD/log_newstart ; exit
fi
fi
fi
echo "*** SIMULATION ***"
if [ $usefcm -eq 1 ] ; then
cd $mod/LMDZ.COMMON
\rm gcm.e 2> /dev/null
ln -sf "bin/"$gcmexec gcm.e
fi
# Create new folder where simulation is run
cd $thisfolder
mkdir $dirname
cp INIT/planet_start $dirname/reglages_init.txt
cp RUN/etu.def $dirname/reglages_run.txt
cp RUN/gases.def $dirname/reglages_gases.txt
cp $setupfile $dirname/$setupfile
sed 's/keyexp/'$dirname'/g' \
TOOLS/atlas.ipynb >> $dirname/atlas.ipynb
sed 's/keyexp/'$dirname'/g' \
TOOLS/atlas-dyn.ipynb >> $dirname/atlas-dyn.ipynb
for ifile in callphys.def gcm.e run.def startfi.nc \
start.nc traceur.def z2sig.def gases.def etu.def ; do
cp -L RUN/$ifile $dirname/. 2> /dev/null
done
cp -r RUN/def_benj_earth $dirname/.
cp -r RUN/def_saturn $dirname/.
if [[ $isrestart == 1 ]]; then
restartdir=`head -n 1 reglages_restart.txt`
if [[ ! -d $restartdir ]]; then
echo "Desole mais le dossier $restartdir n'existe pas ;"
exit
fi
echo "-----------------------------------------------------------"
echo "On redemarre de l'etat final de la simulation :"
echo $restartdir
echo "-----------------------------------------------------------"
if [[ ! -f $restartdir/restart.nc ]] ||
[[ ! -f $restartdir/restartfi.nc ]]; then
echo "Desole, mais cette simulation ne contient pas de fichiers"
echo "finaux ; elle ne s'est peut-etre pas termine correctement;"
exit
else
cp -f $restartdir/restart.nc $dirname/start.nc
cp -f $restartdir/restartfi.nc $dirname/startfi.nc
fi
fi
cd $dirname
ln -s ../RUN/DATAGENERIC .
### >>> run gcm command
time ./gcm.e | tee log_gcm | grep "Ls =" | grep '0\.'
### <<< run gcm command
mv diagfi.nc resultat.nc
echo "*** FIN ***"