[3684] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | #set -vx |
---|
| 4 | |
---|
[4340] | 5 | source ~/env_Multi_atlas.sh |
---|
[4330] | 6 | |
---|
[3882] | 7 | local=`pwd -P` |
---|
| 8 | cd $local |
---|
| 9 | |
---|
[3684] | 10 | #################################################################### |
---|
| 11 | # Frederic Hourdin. 2015/09/07 |
---|
| 12 | # Script de pseudo Cmorisation (passage au format CMIP des sorties |
---|
| 13 | # du modele. |
---|
| 14 | #################################################################### |
---|
| 15 | |
---|
| 16 | #################################################################### |
---|
| 17 | # Defaults : |
---|
| 18 | #################################################################### |
---|
| 19 | |
---|
[3882] | 20 | runstxt=${local}/runs.txt |
---|
[3684] | 21 | while test -n "${1}"; do |
---|
| 22 | case $1 in |
---|
| 23 | "-runsfile") runstxt=$2 ; shift ;; |
---|
| 24 | *) comp=$1 ;; |
---|
| 25 | esac |
---|
| 26 | shift |
---|
| 27 | done |
---|
| 28 | |
---|
| 29 | MainDIR=$DODSDIR/$login/lmdz/SE |
---|
| 30 | INDIR=$DODSDIR/$login/lmdz/SE/ORIG |
---|
| 31 | COMP_D=$DODSDIR/$login/lmdz/MultiSimu/$comp |
---|
| 32 | |
---|
| 33 | if [ ! -f $COMP_D/def.txt ] ; then |
---|
| 34 | echo comparaison multi modele $COMP_D non prevue |
---|
| 35 | exit |
---|
| 36 | fi |
---|
| 37 | if [ ! -f $runstxt ] ; then |
---|
| 38 | echo Fichier listant les simulations inexistants |
---|
| 39 | exit |
---|
| 40 | fi |
---|
| 41 | |
---|
| 42 | WRK=$MainDIR/WORK/CMOR |
---|
| 43 | |
---|
| 44 | #################################################################### |
---|
| 45 | # Interactive options |
---|
| 46 | #################################################################### |
---|
| 47 | force_create=0 # if = 0/1, the existing files are not / are reprocessed |
---|
[4697] | 48 | listevar="sfcWind,hfls,hfss,huss,hurs,pr,rldscs,rlds,rlus,rsdscs,rsds,rsuscs,rsus,rsutcs,rsut,rlut,rlutcs,rsdt,sfcWind,tas,ts,sst,tauu,tauv,psl,zg500,hfns,ta,ua,va,wap,hus,hur,clcalipso,cllcalipso,clmcalipso,clhcalipso,cltcalipso,clt,prw,cll,clm,clh,tasmax,tasmin,uas,vas,pres" |
---|
[3684] | 49 | |
---|
| 50 | ulimit -s unlimited |
---|
| 51 | \rm -rf $WRK ; mkdir -p $WRK ; touch out$$ |
---|
| 52 | ################################################################################ |
---|
| 53 | # Loop on avaliable simulations |
---|
| 54 | ################################################################################ |
---|
| 55 | |
---|
| 56 | cd $INDIR |
---|
| 57 | #for file in *_histmth.nc ; do |
---|
| 58 | |
---|
| 59 | for SE in `awk ' { print $1"_SE_"$2 } ' $COMP_D/def.txt` ; do |
---|
| 60 | sim=`echo $SE | sed -e 's/_SE_/ /' | awk ' { print $1 } '` |
---|
| 61 | years=`echo $SE | sed -e 's/_SE_/ /' | awk ' { print $2 } '` |
---|
| 62 | echo SEsim $SE $sim |
---|
| 63 | simdir=`grep -w "^$sim " $runstxt | awk ' { print $2 } '` |
---|
| 64 | simorig=`basename $simdir` |
---|
| 65 | echo SEsim simorig $simorig |
---|
| 66 | echo SEsim basename $simdir |
---|
| 67 | file=$simdir/ATM/Analyse/SE/${simorig}_SE_${years}_1M_histmth.nc |
---|
| 68 | if [ ! -f $file ] ; then |
---|
| 69 | echo PB fichier $file inexistant |
---|
[3882] | 70 | file=$INDIR/${simorig}_SE_${years}_1M_histmth.nc |
---|
| 71 | echo $file |
---|
| 72 | fi |
---|
| 73 | if [ -f $file ] ; then |
---|
| 74 | file=$INDIR/${simorig}_SE_${years}_1M_histmth.nc |
---|
| 75 | echo $file |
---|
[3684] | 76 | echo FILE $file |
---|
| 77 | cd $WRK |
---|
[4697] | 78 | dirout=$MainDIR/CMOR/${sim}_${years} |
---|
[3684] | 79 | echo $sim $years $dirout |
---|
| 80 | |
---|
| 81 | echo SEsim $dirout |
---|
| 82 | mkdir -p $dirout |
---|
| 83 | |
---|
| 84 | for var in `echo $listevar | sed -e 's/,/ /g'` ; do |
---|
| 85 | |
---|
| 86 | case $var in |
---|
| 87 | clcalipso|cltcalipso|clhcalipso|clmcalipso|cllcalipso) filei=`echo $file | sed -e 's/histmth/histmthCOSP/'` ;; |
---|
| 88 | *) filei=$file |
---|
| 89 | esac |
---|
| 90 | |
---|
| 91 | if [ -f "$filei" ] ; then |
---|
| 92 | |
---|
| 93 | fact=1. |
---|
| 94 | case $var in |
---|
| 95 | hfls) varo=flat ; fact=-1. ;; |
---|
| 96 | hfss) varo=sens ; fact=-1. ;; |
---|
| 97 | pr) varo=precip ;; |
---|
| 98 | sfcWind) varo=wind10m ;; |
---|
| 99 | rldscs) varo=LWdnSFCclr ;; |
---|
| 100 | rlds) varo=LWdnSFC ;; |
---|
| 101 | rlus) varo=LWupSFC ;; |
---|
| 102 | rsdscs) varo=SWdnSFCclr ;; |
---|
| 103 | rsds) varo=SWdnSFC ;; |
---|
| 104 | rsuscs) varo=SWupSFCclr ;; |
---|
| 105 | rsus) varo=SWupSFC ;; |
---|
| 106 | rsutcs) varo=SWupTOAclr ;; |
---|
| 107 | rsut) varo=SWupTOA ;; |
---|
| 108 | rsdt) varo=SWdnTOA ;; |
---|
| 109 | rlut) varo=topl ;; |
---|
| 110 | rlutcs) varo=topl0 ;; |
---|
| 111 | sfcWind) varo=wind10m ;; |
---|
| 112 | tas) varo=t2m ;; |
---|
| 113 | uas) varo=u10m ;; |
---|
| 114 | vas) varo=v10m ;; |
---|
| 115 | tasmax) varo=ave_t2m_daily_max ;; |
---|
| 116 | tasmin) varo=ave_t2m_daily_min ;; |
---|
| 117 | ts) varo=tsol ;; |
---|
| 118 | sst) varo=tsol_oce ;; |
---|
| 119 | huss) varo=q2m ;; |
---|
| 120 | hurs) varo=rh2m ;; |
---|
| 121 | tauu) varo=taux_oce ;; |
---|
| 122 | tauv) varo=tauy_oce ;; |
---|
| 123 | psl) varo=slp ; fact=0.01 ;; |
---|
| 124 | zg500) varo=z500 ;; |
---|
| 125 | hfns) varo=bils ;; |
---|
| 126 | prw) varo=prw ;; |
---|
| 127 | ta) varo=temp ;; |
---|
| 128 | ua) varo=vitu ;; |
---|
| 129 | va) varo=vitv ;; |
---|
| 130 | wap) varo=vitw ;; |
---|
| 131 | hus) varo=ovap ;; |
---|
[4697] | 132 | pres) varo=pres ;; |
---|
[3684] | 133 | hur) varo=rhum ; fact=100. ;; |
---|
| 134 | clcalipso) varo=clcalipso ; fact=100. ;; |
---|
| 135 | cltcalipso) varo=cltcalipso ; fact=100. ;; |
---|
| 136 | clhcalipso) varo=clhcalipso ; fact=100. ;; |
---|
| 137 | clmcalipso) varo=clmcalipso ; fact=100. ;; |
---|
| 138 | cllcalipso) varo=cllcalipso ; fact=100. ;; |
---|
| 139 | cll) varo=cldl ; fact=100. ;; |
---|
| 140 | clm) varo=cldm ; fact=100. ;; |
---|
| 141 | clh) varo=cldh ; fact=100. ;; |
---|
| 142 | clt) varo=cldt ; fact=100. ;; |
---|
| 143 | *) echo "var $var non prevu" ; exit |
---|
| 144 | esac |
---|
| 145 | |
---|
[4697] | 146 | outfile=$dirout/${var}.nc |
---|
| 147 | soutf=`wc -l ${outfile} |awk '{print $1}'` |
---|
| 148 | if [ $force_create = 1 ] || [ "${soutf}" == "0" ] ; then rm -f $outfile ; fi |
---|
[3684] | 149 | if [ ! -f $outfile ] ; then |
---|
[4697] | 150 | \rm -f tmp$$.nc |
---|
[3684] | 151 | if [ $fact = 1. ]; then |
---|
[4697] | 152 | if [ $var == ta ] || [ $var == ua ] || [ $var == va ] || [ $var == wap ] || [ $var == hus ] || [ $var == hur ]; then |
---|
| 153 | opt="selvar,${varo},pres" |
---|
| 154 | else |
---|
[3684] | 155 | opt="selvar,$varo" |
---|
[4697] | 156 | fi |
---|
[3684] | 157 | else |
---|
| 158 | opt="mulc,$fact -selvar,$varo" |
---|
| 159 | fi |
---|
[4697] | 160 | echo cdo $opt $filei ${outfile} |
---|
| 161 | cdo $opt $filei ${outfile} >> out$$ |
---|
[3684] | 162 | if [ $var != $varo ]; then |
---|
[4697] | 163 | echo ncrename -v $varo,$var ${outfile} |
---|
| 164 | ncrename -v $varo,$var ${outfile} >> out$$ |
---|
[3684] | 165 | fi |
---|
[4697] | 166 | |
---|
| 167 | fi # -f $filei |
---|
| 168 | fi |
---|
[3684] | 169 | done |
---|
| 170 | fi |
---|
| 171 | done |
---|