source: models/ARPCLIMAT/serie_ARPCLIMAT.sh @ 99

Last change on this file since 99 was 99, checked in by htune, 7 years ago

modified serie_ARPCLIMAT.sh and created setup_ARPCLIMAT.sh so that bench.sh ARPCLIMAT has the same result as bench_ARPCLIMAT.sh (Najda)

  • Property svn:executable set to *
File size: 5.2 KB
Line 
1#!/bin/sh
2
3#set -ex
4
5if [ $# != 2 ] ; then
6cat <<eod
7Use : serie_ARPCLIMAT.sh CASE/SUBCASE NWAVE
8eod
9exit 1
10fi
11
12DIRMUSC=$REP_MUSC
13WORKDIR=`pwd`
14
15model=ARPCLIMAT
16#model=AROME
17
18#case=ARMCU
19#subcase=REF
20#case=AYOTTE
21#subcase=24SC
22tmp=$1
23case="$(sed 's/\/.*//' <<< "$tmp")"
24subcase="$(sed 's/^[^;]*\///' <<< "$tmp")"
25name='SCM'
26nwave=$2
27
28PARAM=$WORKDIR/WAVE${nwave}/Par1D_Wave${nwave}.asc
29
30repout=$WORKDIR/WAVE${nwave}/${case}/${subcase}
31DIRNAMELIST=$WORKDIR/WAVE$nwave/namelist
32DIRCONFIG=$WORKDIR/WAVE$nwave/config
33
34
35# A few variables in the environment to specify the simulation configuration (model component)
36# Please edit param_ARPCLIMAT
37
38. ./param_ARPCLIMAT
39
40# Type of cleaning : no, nc, lfa, nclfa, all
41clean='no'
42
43#Use for rerunning some simulations in case of some (random) crashes (useful on mac)
44rerun='n'
45
46echo '***********************************************************************************'
47echo 'Check in configsim.py that case, nlev and timestep is consistent with run_tuning.sh'
48echo 'model ='$model
49echo 'case = '$case
50echo 'subcase = '$subcase
51echo 'nlev = '$nlev
52echo 'timestep = '$timestep
53echo 'cycle = '$cycle
54echo 'simuref = '$simuREF
55echo 'namref = '$namref
56echo 'wave = '$nwave
57echo 'param = '$PARAM
58echo 'repout ='$repout
59echo '***********************************************************************************'
60
61if [ $rerun == 'n' ]; then
62
63mkdir -p $repout
64rm -f $repout/*
65mkdir -p $DIRNAMELIST
66rm -f $DIRNAMELIST/*
67mkdir -p $DIRCONFIG
68rm -f $DIRCONFIG/*
69
70
71rm -f param.asc
72ln -s $PARAM param.asc
73n=`wc -l param.asc | awk ' { print $1 } '`
74nl=$(expr $n - 1)
75echo 'nb de simu='$nl
76
77# Preparation des namelists
78cp $namref namref
79python prep_nam_tuning.py
80mv namref.${name}* $DIRNAMELIST
81mv namref $DIRNAMELIST
82cp param.asc $DIRNAMELIST
83
84rm -f param.asc
85
86# Preparation des fichiers de config
87python prep_config_tunning.py $nl $name $case $subcase $nwave $model $simuREF $cycle $MASTER $PGD $PREP $namsfx
88mv config_* $DIRCONFIG
89
90# Preparation fichier de configuration pour les simulations
91
92cd $DIRMUSC
93
94mv configsim.py configsim.py.save
95cat << EOF > configsim.py
96import sys
97import EMS_cases as CC
98
99model = '$model'
100
101allcases=False
102
103cases = ['$case']
104
105nlev = $nlev
106timestep = $timestep
107
108for cc in cases:
109  if not(cc in CC.cases):
110    print 'case', cc, 'not available'
111    print 'available cases:', CC.cases
112    sys.exit()
113
114lsurfex = True
115if model in ['AROME','ARPPNT']:
116    lsurfex = False
117EOF
118
119# Iterations sur les simulations
120rm -f $WORKDIR/err.log
121
122for i in `seq -f "%03g" 1 ${nl}`
123#for i in `seq -f "%03g" 1 2`
124do
125  if [ $model == 'ARPCLIMAT' ]; then
126    ln -s $DIRMUSC/SURFEX/${cycle}/${simuREF} $DIRMUSC/SURFEX/${cycle}/${simuREF}.${name}_${nwave}-$i
127  fi
128  run_MUSC_cases.py $DIRCONFIG/config_${cycle}_${simuREF}.${name}_${nwave}-$i.py $case $subcase
129# Pour être cohérent avec le calcul fait sur les LES
130  cdo houravg $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/netcdf/Out_klevel.nc $repout/${name}_${nwave}-$i.nc || echo $i >> $WORKDIR/err.log
131  if [ $model == 'ARPCLIMAT' ]; then
132    rm -f $DIRMUSC/SURFEX/${cycle}/${simuREF}.${name}_${nwave}-$i
133  fi
134  if [ $clean == 'nc' ]; then
135    rm -rf $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/netcdf/*.nc
136  fi
137  if [ $clean == 'lfa' ]; then
138    rm -rf $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/LFAf/*.lfa
139  fi
140  if [ $clean == 'nclfa' ]; then
141    rm -rf $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/netcdf/*.nc
142    rm -rf $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/LFAf/*.lfa
143  fi
144  if [ $clean == 'all' ]; then
145    rm -rf $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i
146  fi
147done
148
149mv configsim.py.save configsim.py
150
151else
152
153# On relance les simulations qui ont planté
154ERRIN=err.log
155ERROUT=err2.log
156rm -f $WORKDIR/$ERROUT
157cd $DIRMUSC/
158
159mv configsim.py configsim.py.save
160cat << EOF > configsim.py
161import sys
162import EMS_cases as CC
163
164model = '$model'
165
166allcases=False
167
168cases = ['$case']
169
170nlev = $nlev
171timestep = $timestep
172
173for cc in cases:
174  if not(cc in CC.cases):
175    print 'case', cc, 'not available'
176    print 'available cases:', CC.cases
177    sys.exit()
178
179lsurfex = True
180if model in ['AROME','ARPPNT']:
181    lsurfex = False
182EOF
183
184for i in `cat $WORKDIR/$ERRIN`
185do
186  if [ $model == 'ARPCLIMAT' ]; then
187    ln -s $DIRMUSC/SURFEX/${cycle}/${simuREF} $DIRMUSC/SURFEX/${cycle}/${simuREF}.${name}_${nwave}-$i
188  fi
189  run_MUSC_cases.py $DIRCONFIG/config_${cycle}_${simuREF}.${name}_${nwave}-$i.py $case $subcase
190# Pour être cohérent avec le calcul fait sur les LES
191  cdo houravg $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/netcdf/Out_klevel.nc $repout/tmp_${name}_${nwave}-$i.nc || echo $i >> $WORKDIR/$ERROUT
192  cd  $repout
193  ncks -v wpvp_conv,wpthp_conv,wpthp_pbl,wpup_conv,wpup_pbl,wpqp_conv,wpqp_pbl -d levh,1,91 tmp_${name}_${nwave}-$i.nc ${name}_${nwave}-$i.nc
194
195  if [ $model == 'ARPCLIMAT' ]; then
196    rm -f $DIRMUSC/SURFEX/${cycle}/${simuREF}.${name}_${nwave}-$i
197  fi
198done
199
200mv configsim.py.save configsim.py
201
202fi
203
204cd $WORKDIR
Note: See TracBrowser for help on using the repository browser.