source: BOL/Multi_atlas/cmor.sh @ 4221

Last change on this file since 4221 was 3882, checked in by musat, 3 years ago

Changements PATHS ciclad, runs.txt et sed HTML
Ajout possibilite acces simulations sur l espace "SE" dans cmor.sh
Ajout acces OBS a partir de l espace fabric multi_ZONE.sh
IM

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