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