source: BOL/Multi_atlas/METRICS/POUB/metrics.save @ 3684

Last change on this file since 3684 was 3684, checked in by idelkadi, 4 years ago

Repository under svn of a first version of Multiatlas diagnostics for LMDZ. This version is adapted to be able to run a LMDZ multiatlas on an individual account on the ciclad machine of the IPSL. In this version, the parts to be modified are identified so as to subsequently adapt it to other machines.
This version is still under development.

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