source: BOL/Multi_atlas/season.sh @ 3737

Last change on this file since 3737 was 3737, 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.
Modifications following changes and simplification of access from CICLAD / ClimServ?? to the different "thredds"

  • Property svn:executable set to *
File size: 4.5 KB
Line 
1#!/bin/bash
2####################################################################
3# Frederic Hourdin. 2015/09/07
4# Script de calcl de moyennes saisonnieres sur une grille reduite
5# en utilisant cdo. Preparation des tracers d'atlas.
6####################################################################
7
8login=`whoami`
9ulimit -s unlimited
10GR=VLR
11
12hostname=`hostname`
13if [ ${hostname:0:5} = cicla ] ; then
14DODSDIR=/modfs/ipslfs/dods
15fi
16if [ ${hostname:0:5} = camel ] ; then
17DODSDIR=/modfs/ipslfs/dods
18fi
19if [ ${hostname:0:5} = irene ] ; then
20DODSDIR=
21fi
22if [ ${hostname:0:5} = jean- ] ; then
23DODSDIR=
24fi
25
26MAINDIR=$DODSDIR/$login/lmdz
27
28force_create=0
29
30####################################################################
31# Interactive options
32####################################################################
33
34COMP_D=""
35listeseas="JJA,YEAR"
36listeseas="JJA,YEAR,DJF"
37listesim=""
38listeseas="YEAR,DJF,JJA,JJAS"
39
40
41while (($# > 0))
42   do
43   case $1 in
44     "-h") cat <<........fin
45        Usage : cmor.sh [ -s sim1,sim2... -seas DJF,YEAR -f]
46        -f forces execution even if the output file already exists
47........fin
48        shift ; exit ;;
49     "-s") listesim=`echo $2 | sed -e 's/,/ /g'` ; shift ; shift ;;
50     "-f") force_create=1 ; shift ;;
51     "-comp") COMP_D=/modfs/ipslfs/dods/fabric/lmdz/MultiSimu/$2 ; shift ; shift ;;
52     "-seas") listeseas=$2 ; shift ; shift ;;
53     *) ./cmor.sh -h ; shift ; exit ;;
54   esac
55done
56
57i=1
58while [ "`ps -ux | grep season.sh | grep bin | wc -l`" != "2" ] ; do
59   echo Mise en attente de season.sh deja en cours d execution $i
60   sleep 2 ; (( i = $i + 1 ))
61   if [ "$i" = "3600" ] ; then exit ; fi
62done
63
64
65####################################################################
66# About the grid
67####################################################################
68case $GR in
69   VLR) remapf="/home/hourdin/CMIP5/Anal/Feb21_2012_tsol_OBS_AVE_ANM.nc" ;;
70   *) echo "grille $GR non prevue" ; exit
71esac
72mkdir -p $MAINDIR/$GR/GR
73if [ ! -f $MAINDIR/$GR/GR/LAT ] ; then
74   ncks -v LAT $remapf  | grep 'LAT\[' | sed -e '/LAT_bn/d' | cut -d= -f2 | awk ' { print $1 } ' >| $MAINDIR/$GR/GR/LAT
75fi
76if [ "$remapf" != "" ] ; then remap="-remapcon,$remapf" ; fi
77   
78
79################################################################################
80# Loop on seasons
81for SEAS in `echo $listeseas | sed -e 's/,/ /g'` ; do
82################################################################################
83echo $SEAS
84
85case $SEAS in
86   YEAR)  months="" ;;
87   DJF)   months="-selmon,1,2,12" ;;
88   JJA)   months="-selmon,6,7,8" ;; 
89   JJAS)   months="-selmon,6,7,8,9" ;; 
90   *) echo "Cas $cas non prevu" ; exit
91esac
92
93
94################################################################################
95# Boucle sur les simulations
96################################################################################
97
98cd $MAINDIR/SE/CMOR ; \rm ferret*
99
100if [ "$COMP_D" != "" ] ; then
101listesim=`awk ' { print $1"_"$2 } ' $COMP_D/def.txt`
102fi
103echo listesim $listesim
104
105
106if [ "$listesim" = "" ] ; then listesim=`ls` ; fi
107
108for sim in $listesim ; do
109
110 IN_DIR=$MAINDIR/SE/CMOR/$sim
111 echo $IN_DIR
112
113 if [ -d $IN_DIR ] ; then
114
115   echo seasons.sh : mise a jour pour $sim
116   if [ $force_create = 1 ] ; then
117       rm -rf $MAINDIR/$GR/$SEAS/$sim
118   fi
119   OUT_DIR=$MAINDIR/$GR/$SEAS/$sim/NC   ; mkdir -p $OUT_DIR
120
121   cd $IN_DIR
122# boucle sur les variables (chacune correspondant à un .nc)
123   for f in *nc ; do
124      var=`basename $f .nc`
125# Pour le 3D, on prend directement les moyennes zonales
126
127# facteurs mutliplicatifs si besoin
128      mulc=1.
129      case $var in
130         pr) mulc=86400. ;;
131         autre) mulc=achanger ;;
132         dernier) mulc=bou
133      esac
134
135# Moyenne saisonniere (et zonale pour les champs 3D)
136      if [ ! -f $OUT_DIR/$f -a -f $IN_DIR/$f ] ; then
137         echo cdo mulc,$mulc -timavg $months $remap $IN_DIR/$f $OUT_DIR/$f
138         cdo mulc,$mulc -timavg $months $remap $IN_DIR/$f $OUT_DIR/$f
139      else
140         echo $OUT_DIR/$f : deja cree
141      fi
142
143   done
144
145
146########################################################################
147# Regroupement des variables 2D dans all.nc
148########################################################################
149   cd $OUT_DIR
150   liste3d=""
151   listef=""
152   if [ "`ls -rt *nc | tail -1`" != "all.nc" ] ; then
153      for f in `ls *nc | sed -e 's/all.nc//'` ; do
154         var=`basename $f .nc`
155         case $var in
156            ua|va|wap|ta|hus|hur) liste3d="$liste3d $f" ;;
157            *) listef="$listef $f"
158         esac
159      done
160      \rm -f all.nc
161      echo cdo merge $listef all.nc
162      cdo merge $listef all.nc
163   fi
164
165 else
166    echo ERREUR: repertoire $IN_DIR absent
167 fi # Boucle sur $sim
168done
169
170done
Note: See TracBrowser for help on using the repository browser.