| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | #set -ex |
|---|
| 4 | |
|---|
| 5 | if [ $# != 2 ] ; then |
|---|
| 6 | cat <<eod |
|---|
| 7 | Use : serie_ARPCLIMAT.sh CASE/SUBCASE NWAVE |
|---|
| 8 | eod |
|---|
| 9 | exit 1 |
|---|
| 10 | fi |
|---|
| 11 | |
|---|
| 12 | DIRMUSC=$REP_MUSC |
|---|
| 13 | WORKDIR=`pwd` |
|---|
| 14 | |
|---|
| 15 | model=ARPCLIMAT |
|---|
| 16 | #model=AROME |
|---|
| 17 | |
|---|
| 18 | #case=ARMCU |
|---|
| 19 | #subcase=REF |
|---|
| 20 | #case=AYOTTE |
|---|
| 21 | #subcase=24SC |
|---|
| 22 | tmp=$1 |
|---|
| 23 | case="$(sed 's/\/.*//' <<< "$tmp")" |
|---|
| 24 | subcase="$(sed 's/^[^;]*\///' <<< "$tmp")" |
|---|
| 25 | name='SCM' |
|---|
| 26 | nwave=$2 |
|---|
| 27 | |
|---|
| 28 | PARAM=$WORKDIR/WAVE${nwave}/Par1D_Wave${nwave}.asc |
|---|
| 29 | |
|---|
| 30 | repout=$WORKDIR/WAVE${nwave}/${case}/${subcase} |
|---|
| 31 | DIRNAMELIST=$WORKDIR/WAVE$nwave/namelist |
|---|
| 32 | DIRCONFIG=$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 |
|---|
| 41 | clean='no' |
|---|
| 42 | |
|---|
| 43 | #Use for rerunning some simulations in case of some (random) crashes (useful on mac) |
|---|
| 44 | rerun='n' |
|---|
| 45 | |
|---|
| 46 | echo '***********************************************************************************' |
|---|
| 47 | echo 'Check in configsim.py that case, nlev and timestep is consistent with run_tuning.sh' |
|---|
| 48 | echo 'model ='$model |
|---|
| 49 | echo 'case = '$case |
|---|
| 50 | echo 'subcase = '$subcase |
|---|
| 51 | echo 'nlev = '$nlev |
|---|
| 52 | echo 'timestep = '$timestep |
|---|
| 53 | echo 'cycle = '$cycle |
|---|
| 54 | echo 'simuref = '$simuREF |
|---|
| 55 | echo 'namref = '$namref |
|---|
| 56 | echo 'wave = '$nwave |
|---|
| 57 | echo 'param = '$PARAM |
|---|
| 58 | echo 'repout ='$repout |
|---|
| 59 | echo '***********************************************************************************' |
|---|
| 60 | |
|---|
| 61 | if [ $rerun == 'n' ]; then |
|---|
| 62 | |
|---|
| 63 | mkdir -p $repout |
|---|
| 64 | rm -f $repout/* |
|---|
| 65 | mkdir -p $DIRNAMELIST |
|---|
| 66 | rm -f $DIRNAMELIST/* |
|---|
| 67 | mkdir -p $DIRCONFIG |
|---|
| 68 | rm -f $DIRCONFIG/* |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | rm -f param.asc |
|---|
| 72 | ln -s $PARAM param.asc |
|---|
| 73 | n=`wc -l param.asc | awk ' { print $1 } '` |
|---|
| 74 | nl=$(expr $n - 1) |
|---|
| 75 | echo 'nb de simu='$nl |
|---|
| 76 | |
|---|
| 77 | # Preparation des namelists |
|---|
| 78 | cp $namref namref |
|---|
| 79 | python prep_nam_tuning.py |
|---|
| 80 | mv namref.${name}* $DIRNAMELIST |
|---|
| 81 | mv namref $DIRNAMELIST |
|---|
| 82 | cp param.asc $DIRNAMELIST |
|---|
| 83 | |
|---|
| 84 | rm -f param.asc |
|---|
| 85 | |
|---|
| 86 | # Preparation des fichiers de config |
|---|
| 87 | python prep_config_tunning.py $nl $name $case $subcase $nwave $model $simuREF $cycle $MASTER $PGD $PREP $namsfx |
|---|
| 88 | mv config_* $DIRCONFIG |
|---|
| 89 | |
|---|
| 90 | # Preparation fichier de configuration pour les simulations |
|---|
| 91 | |
|---|
| 92 | cd $DIRMUSC |
|---|
| 93 | |
|---|
| 94 | mv configsim.py configsim.py.save |
|---|
| 95 | cat << EOF > configsim.py |
|---|
| 96 | import sys |
|---|
| 97 | import EMS_cases as CC |
|---|
| 98 | |
|---|
| 99 | model = '$model' |
|---|
| 100 | |
|---|
| 101 | allcases=False |
|---|
| 102 | |
|---|
| 103 | cases = ['$case'] |
|---|
| 104 | |
|---|
| 105 | nlev = $nlev |
|---|
| 106 | timestep = $timestep |
|---|
| 107 | |
|---|
| 108 | for 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 | |
|---|
| 114 | lsurfex = True |
|---|
| 115 | if model in ['AROME','ARPPNT']: |
|---|
| 116 | lsurfex = False |
|---|
| 117 | EOF |
|---|
| 118 | |
|---|
| 119 | # Iterations sur les simulations |
|---|
| 120 | rm -f $WORKDIR/err.log |
|---|
| 121 | |
|---|
| 122 | for i in `seq -f "%03g" 1 ${nl}` |
|---|
| 123 | #for i in `seq -f "%03g" 1 2` |
|---|
| 124 | do |
|---|
| 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 |
|---|
| 147 | done |
|---|
| 148 | |
|---|
| 149 | mv configsim.py.save configsim.py |
|---|
| 150 | |
|---|
| 151 | else |
|---|
| 152 | |
|---|
| 153 | # On relance les simulations qui ont planté |
|---|
| 154 | ERRIN=err.log |
|---|
| 155 | ERROUT=err2.log |
|---|
| 156 | rm -f $WORKDIR/$ERROUT |
|---|
| 157 | cd $DIRMUSC/ |
|---|
| 158 | |
|---|
| 159 | mv configsim.py configsim.py.save |
|---|
| 160 | cat << EOF > configsim.py |
|---|
| 161 | import sys |
|---|
| 162 | import EMS_cases as CC |
|---|
| 163 | |
|---|
| 164 | model = '$model' |
|---|
| 165 | |
|---|
| 166 | allcases=False |
|---|
| 167 | |
|---|
| 168 | cases = ['$case'] |
|---|
| 169 | |
|---|
| 170 | nlev = $nlev |
|---|
| 171 | timestep = $timestep |
|---|
| 172 | |
|---|
| 173 | for 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 | |
|---|
| 179 | lsurfex = True |
|---|
| 180 | if model in ['AROME','ARPPNT']: |
|---|
| 181 | lsurfex = False |
|---|
| 182 | EOF |
|---|
| 183 | |
|---|
| 184 | for i in `cat $WORKDIR/$ERRIN` |
|---|
| 185 | do |
|---|
| 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 |
|---|
| 198 | done |
|---|
| 199 | |
|---|
| 200 | mv configsim.py.save configsim.py |
|---|
| 201 | |
|---|
| 202 | fi |
|---|
| 203 | |
|---|
| 204 | cd $WORKDIR |
|---|