[3684] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | set -vx |
---|
| 4 | force_create=1 |
---|
| 5 | |
---|
| 6 | comp=$1 |
---|
| 7 | local=`pwd` |
---|
| 8 | |
---|
| 9 | for season in YEAR ; do |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | cd $local |
---|
| 13 | |
---|
| 14 | if [ "$season" = "YEAR" ] ; then |
---|
| 15 | masks="ter oce NAtl Arct circA otrop glob eto weak conv subs NH SH" |
---|
| 16 | mask_figs="NAtl Arct circA glob ter oce otrop interH etoa etow etows circAa NAtla conv weak subs" |
---|
| 17 | masks="glob" |
---|
| 18 | mask_figs="glob" |
---|
| 19 | else |
---|
| 20 | masks="NAtl Arct circA Sibe USA" |
---|
| 21 | mask_figs="NAtl Arct circA Sibe USA" |
---|
| 22 | fi |
---|
| 23 | |
---|
| 24 | WRK_D=$local/XMGR$$/$season |
---|
| 25 | if [ -d $WRK_D ] ; then WRK_D=$WRK_D$$ ; fi |
---|
| 26 | mkdir -p $WRK_D |
---|
| 27 | cd $WRK_D |
---|
| 28 | ln -s ../../mas*nc . |
---|
| 29 | |
---|
| 30 | comp=`basename $1` |
---|
| 31 | if [ -d /prodigfs/ipslfs/dods/fabric/lmdz/MultiSimu ] ; then |
---|
| 32 | # Installation multi modele fabric |
---|
| 33 | COMP_D=/prodigfs/ipslfs/dods/fabric/lmdz/MultiSimu/$comp |
---|
| 34 | CMOR_DIR=/prodigfs/ipslfs/dods/fabric/lmdz/VLR/$season |
---|
| 35 | elif [ "$comp" = "$1" ] ; then |
---|
| 36 | # Installation locale |
---|
| 37 | COMP_D=. |
---|
| 38 | CMOR_DIR=. |
---|
| 39 | else |
---|
| 40 | # Path absolu |
---|
| 41 | COMP_D=$1 |
---|
| 42 | CMOR_DIR=. |
---|
| 43 | fi |
---|
| 44 | |
---|
| 45 | ############################################### |
---|
| 46 | # Liste des simulations de la comparasion $comp |
---|
| 47 | listsims="" ; listsimsy="" |
---|
| 48 | DEF_FILE=$COMP_D/def.txt ; if [ ! -f "$DEF_FILE" ] ; then echo renseigner echo $DEF_FILE ; exit ; fi |
---|
| 49 | for s in `awk ' {print $1"_"$2 } ' $DEF_FILE` ; do listsimsy="$listsimsy $s" ; done |
---|
| 50 | for s in `awk ' {print $1 } ' $DEF_FILE` ; do listsims="$listsims $s" ; done |
---|
| 51 | ############################################### |
---|
| 52 | |
---|
| 53 | echo $listsimsy |
---|
| 54 | ici=`pwd` |
---|
| 55 | |
---|
| 56 | for simy in OBS $listsimsy ; do |
---|
| 57 | sim=`echo $simy | sed -e 's/_[0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9]//'` |
---|
| 58 | years=`echo $simy | sed -e s/${sim}//` |
---|
| 59 | echo SIM $sim |
---|
| 60 | echo years $years |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | SIM_DIR=$CMOR_DIR/$GR/$sim$years |
---|
| 64 | ETOA_DIR=$SIM_DIR/METRICS |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | for mask in $masks ; do |
---|
| 68 | # mkdir -p XMGR$$/$mask |
---|
| 69 | xmgr=$ETOA_DIR/$mask |
---|
| 70 | mkdir -p $ETOA_DIR |
---|
| 71 | if [ ! -f "$xmgr" -o "$force_create" = "1" ] ; then |
---|
| 72 | \rm -f $xmgr ; touch $xmgr |
---|
| 73 | if [ ! -d $SIM_DIR ] ; then echo $SIM_DIR absent ; exit ; fi |
---|
| 74 | set +e ; \rm resu$sim ; set -e |
---|
| 75 | for var in rsut clhcalipso cllcalipso clmcalipso cltcalipso clt hfls hfss hurs huss pr ts tas sst psl rldscs rlds rlus rlutcs rlut rsdscs rsds rsdt rsuscs rsus rsutcs prw ; do |
---|
| 76 | if [ -f "$SIM_DIR/NC/$var.nc" ] ; then |
---|
| 77 | if [ "$mask" = "glob" ] ; then |
---|
| 78 | val=`cdo output -fldmean -selvar,$var $SIM_DIR/NC/$var.nc` |
---|
| 79 | elif [ ! -f "mask$mask.nc" ] ; then |
---|
| 80 | echo Le fichier mask$mask.nc n existe pas ; exit |
---|
| 81 | else |
---|
| 82 | if [ 1 = 1 ] ; then |
---|
| 83 | if [ 1 = 0 ] && [ $var = "hfls" ] && [ $simy == "OBS" ]; then |
---|
| 84 | cdo remapcon,mask$mask.nc $SIM_DIR/NC/$var.nc_ocean-only tmp.nc |
---|
| 85 | val=`cdo output -fldmean -selvar,$var -mul tmp.nc mask$mask.nc` |
---|
| 86 | else |
---|
| 87 | cdo remapcon,mask$mask.nc $SIM_DIR/NC/$var.nc tmp.nc |
---|
| 88 | val=`cdo output -fldmean -selvar,$var -mul tmp.nc mask$mask.nc` |
---|
| 89 | fi |
---|
| 90 | else |
---|
| 91 | cdo remapcon,maskotrop.nc $SIM_DIR/NC/$var.nc tmp.nc |
---|
| 92 | cdo remapcon,maskotrop.nc mask$mask.nc mask.nc |
---|
| 93 | val=`cdo output -fldmean -selvar,$var -mul tmp.nc mask.nc` |
---|
| 94 | fi |
---|
| 95 | fi |
---|
| 96 | echo $mask $sim $var $val |
---|
| 97 | echo $var $val >> $xmgr |
---|
| 98 | else |
---|
| 99 | echo $var 999999 >> $xmgr |
---|
| 100 | fi |
---|
| 101 | done |
---|
| 102 | rsut=`grep '^rsut ' $xmgr | awk ' { print $2 } '` |
---|
| 103 | rsutcs=`grep '^rsutcs ' $xmgr | awk ' { print $2 } '` |
---|
| 104 | rlut=`grep '^rlut ' $xmgr | awk ' { print $2 } '` |
---|
| 105 | rlutcs=`grep '^rlutcs ' $xmgr | awk ' { print $2 } '` |
---|
| 106 | hfls=`grep '^hfls ' $xmgr | awk ' { print $2 } '` |
---|
| 107 | hfss=`grep '^hfss ' $xmgr | awk ' { print $2 } '` |
---|
| 108 | rlds=`grep '^rlds ' $xmgr | awk ' { print $2 } '` |
---|
| 109 | rldscs=`grep '^rldscs ' $xmgr | awk ' { print $2 } '` |
---|
| 110 | rsds=`grep '^rsds ' $xmgr | awk ' { print $2 } '` |
---|
| 111 | rsdscs=`grep '^rsdscs ' $xmgr | awk ' { print $2 } '` |
---|
| 112 | rlus=`grep '^rlus ' $xmgr | awk ' { print $2 } '` |
---|
| 113 | rsus=`grep '^rsus ' $xmgr | awk ' { print $2 } '` |
---|
| 114 | rsuscs=`grep '^rsuscs ' $xmgr | awk ' { print $2 } '` |
---|
| 115 | rsdt=`grep '^rsdt ' $xmgr | awk ' { print $2 } '` |
---|
| 116 | echo $rsut $rsutcs | awk ' { print "crest" , $2 - $1 } ' >> $xmgr |
---|
| 117 | echo $rlut $rlutcs | awk ' { print "crelt" , $2 - $1 } ' >> $xmgr |
---|
| 118 | echo $rsut $rsutcs $rlut $rlutcs | awk ' { print "cret" , $2 - $1 +$4 -$3 } ' >> $xmgr |
---|
| 119 | echo $rsdt $rsut | awk ' { print "rst" , $1 - $2 } ' >> $xmgr |
---|
| 120 | echo $rsdt $rsutcs | awk ' { print "rstcs" , $1 - $2 } ' >> $xmgr |
---|
| 121 | echo $rsdt $rsut $rlut | awk ' { print "rt" , $1 - $2 -$3 } ' >> $xmgr |
---|
| 122 | echo $hfls $hfss | awk ' { print "trbs" , $1 + $2 } ' >> $xmgr |
---|
| 123 | echo $rlds $rlus | awk ' { print "rls" , $1 - $2 } ' >> $xmgr |
---|
| 124 | echo $rsds $rsus | awk ' { print "rss" , $1 - $2 } ' >> $xmgr |
---|
| 125 | echo $rlds $rlus $rsds $rsus | awk ' { print "rs" , $1 - $2 +$3 - $4 } ' >> $xmgr |
---|
| 126 | echo $rlds $rldscs $rsds $rsdscs $rsus $rsuscs | awk ' { print "cres" , $1 - $2 + $3 - $4 - $5 + $6 } ' >> $xmgr |
---|
| 127 | echo $rlds $rldscs $rsds $rsdscs $rsus $rsuscs $hfls | awk ' { print "crehfls" , $1 - $2 + $3 - $4 - $5 + $6 - $7 } ' >> $xmgr |
---|
| 128 | echo $rlds $rlus $rsds $rsus $hfls $hfss | awk ' { print "bils" , $1 - $2 + $3 - $4 - $5 - $6 } ' >> $xmgr |
---|
| 129 | fi |
---|
| 130 | done |
---|
| 131 | |
---|
| 132 | # Masques combinés |
---|
| 133 | set +e |
---|
| 134 | paste $ETOA_DIR/otrop $ETOA_DIR/eto | awk ' { if ( $2 == 999999 || $4 == 999999 ) print $1 , 999999 ; else print $1 , $4 - $2 } ' >| $ETOA_DIR/etoa |
---|
| 135 | paste $ETOA_DIR/weak $ETOA_DIR/subs | awk ' { if ( $2 == 999999 || $4 == 999999 ) print $1 , 999999 ; else print $1 , $4 - $2 } ' >| $ETOA_DIR/etows |
---|
| 136 | paste $ETOA_DIR/weak $ETOA_DIR/eto | awk ' { if ( $2 == 999999 || $4 == 999999 ) print $1 , 999999 ; else print $1 , $4 - $2 } ' >| $ETOA_DIR/etow |
---|
| 137 | paste $ETOA_DIR/otrop $ETOA_DIR/circA | awk ' { if ( $2 == 999999 || $4 == 999999 ) print $1 , 999999 ; else print $1 , $4 - $2 } ' >| $ETOA_DIR/circAa |
---|
| 138 | paste $ETOA_DIR/NAtl $ETOA_DIR/otrop | awk ' { if ( $2 == 999999 || $4 == 999999 ) print $1 , 999999 ; else print $1 , $4 - $2 } ' >| $ETOA_DIR/NAtla |
---|
| 139 | paste $ETOA_DIR/SH $ETOA_DIR/NH | awk ' { if ( $2 == 999999 || $4 == 999999 ) print $1 , 999999 ; else print $1 , $4 - $2 } ' >| $ETOA_DIR/interH |
---|
| 140 | set -e |
---|
| 141 | |
---|
| 142 | done |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | ######################################################################################### |
---|
| 146 | # Tracers |
---|
| 147 | ######################################################################################### |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | cat <<eod>| descr |
---|
| 152 | clhcalipso 1 High Clouds |
---|
| 153 | cllcalipso 1 Low Clouds |
---|
| 154 | clmcalipso 1 Mid Clouds |
---|
| 155 | cltcalipso 1 Total Clouds |
---|
| 156 | clt 1 LMDZ Total Clouds |
---|
| 157 | hfls -1 -LE |
---|
| 158 | hfss -1 -H |
---|
| 159 | hurs 1 RHsrf |
---|
| 160 | huss 1 Surface specific humidity |
---|
| 161 | pr 10 PR*10 |
---|
| 162 | prw 1 PRW |
---|
| 163 | psl 1 SLP |
---|
| 164 | ts 10 Ts*10 |
---|
| 165 | sst 10 sst*10 |
---|
| 166 | tas 10 T2m*10 |
---|
| 167 | rlds 1 LWdn srf |
---|
| 168 | rldscs 1 LWdn srf Clr |
---|
| 169 | rlus -1 LWup Srf |
---|
| 170 | rlutcs -1 LW TOA Clr |
---|
| 171 | rlut -1 LW TOA |
---|
| 172 | rsdscs 1 SWdn srf Clr |
---|
| 173 | rsds 1 SWdn srf |
---|
| 174 | rsdt 1 SWdn TOA |
---|
| 175 | rsuscs -1 SWup srf Clr |
---|
| 176 | rsus -1 SWup srf |
---|
| 177 | rsutcs -1 SW TOA Clr |
---|
| 178 | rstcs -1 SW TOA Clr |
---|
| 179 | rsut -1 SW TOA |
---|
| 180 | crest 1 SW CRE TOA |
---|
| 181 | crelt 1 LW CRE TOA |
---|
| 182 | cres 1 CRE srf |
---|
| 183 | crehfls 1 CRE - LE |
---|
| 184 | cret 1 CRE TOA |
---|
| 185 | rst 1 SW TOA |
---|
| 186 | rt 1 SW+LW TOA |
---|
| 187 | trbs -1 -(LE+H) |
---|
| 188 | rls 1 LW srf |
---|
| 189 | rss 1 SW srf |
---|
| 190 | rs 1 SW+LW srf |
---|
| 191 | bils 1 Srf budget |
---|
| 192 | eod |
---|
| 193 | |
---|
| 194 | # ------------------- debut boucle sur les figures ---------------------------- |
---|
| 195 | for mask in $mask_figs ; do |
---|
| 196 | # ------------------- debut boucle sur les figures ---------------------------- |
---|
| 197 | |
---|
| 198 | case $mask in |
---|
| 199 | NAtla|circAa|etoa|etow|etows|oce|otrop) listevars="ts bils crehfls cres rs rss crest hfls tas cllcalipso clhcalipso " ;; |
---|
| 200 | interH|glob|ter|NAtl|circA|conv|weak|subs) listevars="bils tas rt rlutcs crelt rsutcs crest cllcalipso clmcalipso clhcalipso pr" ;; |
---|
| 201 | Arct|Sibe|USA) listevars="tas rs rlds rsds crelt crest cllcalipso clmcalipso clhcalipso pr prw" ;; |
---|
| 202 | *) echo cas non prevu ; exit |
---|
| 203 | esac |
---|
| 204 | |
---|
| 205 | nvars=`echo $listevars | wc -w | awk ' { print $1 } '` |
---|
| 206 | case $mask in |
---|
| 207 | NAtl) yax="North Atlantic " ;; |
---|
| 208 | Arct) yax="Arctic ocean" ;; |
---|
| 209 | circA) yax="Circum Antartica " ;; |
---|
| 210 | Sibe) yax="Siberia " ;; |
---|
| 211 | USA) yax="US Gr. Plains " ;; |
---|
| 212 | glob) yax="Global " ;; |
---|
| 213 | ter) yax="Land " ;; |
---|
| 214 | oce) yax="Ocean " ;; |
---|
| 215 | otrop) yax="Tropical ocean " ;; |
---|
| 216 | interH) yax="Inter Hemispheric " ;; |
---|
| 217 | etoa) yax="ETOA " ;; |
---|
| 218 | etow) yax="ETO - Weak " ;; |
---|
| 219 | etows) yax="subs - Weak " ;; |
---|
| 220 | circAa) yax="Circum Antartic Anom. " ;; |
---|
| 221 | NAtla) yax="Nort Atlantic Anom. " ;; |
---|
| 222 | conv) yax="Convective regimes " ;; |
---|
| 223 | weak) yax="Weak convection " ;; |
---|
| 224 | subs) yax="Subsidences " |
---|
| 225 | esac |
---|
| 226 | cat <<...eod>| tmp.param |
---|
| 227 | g0 type Chart |
---|
| 228 | world -0.5, -35, $nvars, 35 |
---|
| 229 | yaxis label "$yax Fluxes (W/m2) " |
---|
| 230 | xaxis ticklabel font 0 |
---|
| 231 | xaxis ticklabel color 1 |
---|
| 232 | xaxis tick place both |
---|
| 233 | xaxis tick spec type both |
---|
| 234 | xaxis tick spec 11 |
---|
| 235 | xaxis ticklabel char size 1.3 |
---|
| 236 | xaxis ticklabel angle 90 |
---|
| 237 | yaxis tick major 10 |
---|
| 238 | yaxis tick minor ticks 1 |
---|
| 239 | legend 1.20, 0.8 |
---|
| 240 | ...eod |
---|
| 241 | |
---|
| 242 | ii=0 |
---|
| 243 | for var in $listevars ; do |
---|
| 244 | fact=`grep "^$var " descr | awk ' { print $2 } '` |
---|
| 245 | titre=`grep "^$var " descr | sed -e 's/'$var'//' -e 's/'$fact'//'` |
---|
| 246 | cat <<......eod>> tmp.param |
---|
| 247 | xaxis tick major $ii, $ii |
---|
| 248 | xaxis ticklabel $ii, "$titre" |
---|
| 249 | ......eod |
---|
| 250 | (( ii = $ii + 1 )) |
---|
| 251 | done |
---|
| 252 | |
---|
| 253 | |
---|
| 254 | prev="" |
---|
| 255 | ip=0 |
---|
| 256 | listex="" |
---|
| 257 | echo LISTESIMSY $listsimsy |
---|
| 258 | for simy in $listsimsy ; do |
---|
| 259 | sim=`echo $simy | sed -e 's/_[0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9]//'` |
---|
| 260 | years=`echo $simy | sed -e s/${sim}//` |
---|
| 261 | echo $sim |
---|
| 262 | SIM_DIR=$CMOR_DIR/$sim$years/METRICS |
---|
| 263 | ls $SIM_DIR |
---|
| 264 | OBS_DIR=$CMOR_DIR/OBS/METRICS |
---|
| 265 | mkdir -p $WRK_D/$mask |
---|
| 266 | if [ "$sim" = "$prev" ] ; then # Cas ou on a plusieurs decennies de la meme simu |
---|
| 267 | (( ip = $ip + 1 )) |
---|
| 268 | xmgr=$WRK_D/$mask/$sim.$ip |
---|
| 269 | listex="$listex $sim.$ip" |
---|
| 270 | else |
---|
| 271 | xmgr=$WRK_D/$mask/$sim |
---|
| 272 | ip=0 ; prev=$sim |
---|
| 273 | listex="$listex $sim" |
---|
| 274 | fi |
---|
| 275 | rm -f $xmgr ; touch $xmgr |
---|
| 276 | for var in $listevars ; do |
---|
| 277 | echo var $var |
---|
| 278 | fact=`grep "^$var " descr | awk ' { print $2 } '` |
---|
| 279 | paste $OBS_DIR/$mask $SIM_DIR/$mask | grep "^$var " | awk ' { if ( $4 == 999999 ) print 0 ; else print '$fact' * ( $4 - $2 ) } ' >> $xmgr |
---|
| 280 | done |
---|
| 281 | done |
---|
| 282 | |
---|
| 283 | |
---|
| 284 | |
---|
| 285 | size=`echo $listsims | wc -w | awk ' { print 3. / $1 } '` |
---|
| 286 | for ii in 0 1 2 3 4 5 6 7 8 9 10 11 12 ; do |
---|
| 287 | echo "s$ii type bar" >> tmp.param |
---|
| 288 | echo "s$ii symbol fill pattern 1" >> tmp.param |
---|
| 289 | echo "s$ii symbol size $size" >> tmp.param |
---|
| 290 | echo "s$ii line linestyle 0" >> tmp.param |
---|
| 291 | done |
---|
| 292 | |
---|
| 293 | cd $WRK_D/$mask |
---|
| 294 | pwd ; echo xmgrace $listex -param ../../../tmp.param -legend load -hardcopy -hdevice EPS -printfile tmp.eps |
---|
| 295 | xmgrace $listex -param ../../../tmp.param -legend load -hardcopy -hdevice EPS -printfile tmp.eps |
---|
| 296 | epstopdf tmp.eps |
---|
| 297 | OUT_D=$COMP_D/METRICS/$season ; mkdir -p $OUT_D |
---|
| 298 | \mv -f tmp.pdf $OUT_D/$mask.pdf ; convert -density 144 $OUT_D/$mask.pdf $OUT_D/$mask.png |
---|
| 299 | cd ../../.. |
---|
| 300 | |
---|
| 301 | done |
---|
| 302 | |
---|
| 303 | cp mask*png $OUT_D |
---|
| 304 | done |
---|