source: lmdz_wrf/trunk/tools/make_met-aquaplanet.bash @ 188

Last change on this file since 188 was 187, checked in by lfita, 11 years ago

Adding scripts for the generation of the aqua-planet initial conditions

  • Property svn:executable set to *
File size: 4.8 KB
Line 
1#!/bin/bash
2## g.e. # ./make_met-aquaplanet.bash  met_em.d01.1979-01-01_00\:00\:00.nc SST control 273.15:27.
3## g.e. # ./make_met-aquaplanet.bash  met_em.d01.1979-01-01_00\:00\:00.nc SST KEQ 273.15:27.:1.:60.0:15.:15.
4## g.e. # ./make_met-aquaplanet.bash  met_em.d01.1979-01-01_00\:00\:00.nc SST HS 315.0:0.0:60.0
5if test $1 = '-h'; then
6  echo "******************************"
7  echo "***  Shell script to make  ***"
8  echo "*** an aqua-planet met_em  ***"
9  echo "******************************"
10  echo "make_met-aquaplanet.bash [met_emfile](met_em file to transform) [SSTname](name of the SST) [sstkind](kind of SST profile from Neale & Hoskins, 2001) [ref:amp/addvalues](amplitude or additional values when required (KEQ, KW1), HS: Held & Suarez, 1994 conditions (uses [ref]:[amp]:[perAmp, as /\Ty])"
11  echo "[addvalues]=[reference]:[amp]:[perAmp]:[L0]:[dL]:[dl]"
12  echo "  [ref]: value for the non-perturbation"
13  echo "  [amp]: anomaly amplitude (in [units])"
14  echo "  [perAmp]: perturbation anomaly amplitude (in [units])"
15  echo "  [L0]: longitude of maximum anomaly (in deg)"
16  echo "  [dL]: decayment in longitude (in deg)"
17  echo "  [dl]: decayment in latitude (in deg)"
18else
19  rootsh=`pwd`
20  export PATH=/u/lflmd/bin/gcc_Python-2.7.5/bin:${PATH}
21  errormsg='ERROR -- error -- ERROR -- error'
22
23  met_emfile=$1
24  sstname=$2
25  sstkind=$3
26  addvalues=$4
27
28  if test ! ${sstkind} = 'original'; then 
29    ofile='aqua_met-em_'${sstkind}'.nc'
30  else
31    ofile='aqua_met-em.nc'
32  fi
33
34  rm ${ofile} > /dev/null
35
36  zerovars='LANDMASK:HGT_M:HGT_U:HGT_V:SLPX:SLPY:CON:VAR:OA1:OA2:OA3:OA4:OL1:OL2:OL3:OL4:SKINTEMP:SEAICE'
37# Fixing p_top at 0.0001 hPa)
38##  zTopvars='PRES:GHT:RH:VV:UU:TT'
39  zTopvars='PRES@0.0001'
40
41##  keepvars='XLAT_M:XLONG_M:XLAT_U:XLONG_U:XLAT_V:XLONG_V:CLAT:CLONG:MAPFAC_M:MAPFAC_V:MAPFAC_U:MAPFAC_MX:MAPFAC_VX:MAPFAC_UX:MAPFAC_MY:MAPFAC_VY:MAPFAC_UY:E:F:SINALPHA:COSALPHA'
42  keepvars=''
43  specificvars='LANDUSEF|1:LU_INDEX|1:SOILTEMP|0:SOILCTOP|0:SCT_DOM|14:SOILCBOT|0:SCB_DOM|14:ALBEDO12M|8:GREENFRAC|0:SNOALB|0:SLOPECAT|0'
44#  specificvars=''
45  thresvars='SST|273.15|below|275.:'
46
47  cp ${met_emfile} ${ofile}
48
49  # zerovars
50  ##
51  ivar=1
52  echo "zeroing..."
53  zerov=`echo ${zerovars} | tr ':' ' '`
54  for var in ${zerov}; do
55    echo "  "${var}"..."
56    python ${HOME}/climatescripts/python/nc_var.py -f ${ofile} -v ${var} -o valmod -S mulc,0.
57    ivar=`expr ${ivar} + 1`
58##    exit
59  done # end of zeroingvars
60
61  # giving values
62  ##
63  echo "giving values..."
64  givv=`echo ${specificvars} | tr ':' ' '`
65  for var in ${givv}; do
66    varn=`echo ${var} | tr '|' ' ' | awk '{print $1}'`
67    varv=`echo ${var} | tr '|' ' ' | awk '{print $2}'`
68    echo "  "${varn}"..."
69    python ${HOME}/climatescripts/python/nc_var.py -f ${ofile} -v ${varn} -o valmod -S mulc,0.
70    python ${HOME}/climatescripts/python/nc_var.py -f ${ofile} -v ${varn} -o valmod -S sumc,${varv} 
71    ivar=`expr ${ivar} + 1`
72##    exit
73  done # end of givingvars
74
75  # threshold values
76  ##
77  echo "threshold values..."
78  givv=`echo ${thresvars} | tr ':' ' '`
79  for var in ${givv}; do
80    varn=`echo ${var} | tr '|' ' ' | awk '{print $1}'`
81    vart=`echo ${var} | tr '|' ' ' | awk '{print $2}'`
82    vark=`echo ${var} | tr '|' ' ' | awk '{print $3}'`
83    varv=`echo ${var} | tr '|' ' ' | awk '{print $4}'`
84    if test ${vark} = 'below'; then
85      echo "  "${varn}" values below "${vart}" to "${varv}"..."
86      python ${HOME}/climatescripts/python/nc_var.py -f ${ofile} -v ${varn} -o valmod -S lowthres,${vart},${varv} 
87    else
88      echo "  "${varn}" values above "${vart}" to "${varv}"..."
89      python ${HOME}/climatescripts/python/nc_var.py -f ${ofile} -v ${varn} -o valmod -S upthres,${vart},${varv}   
90    fi
91    ivar=`expr ${ivar} + 1`
92##    exit
93  done # end of thresvars
94
95# Imposing SST
96##
97  if test ! ${sstkind} = 'original'; then 
98    python sfcVAR_global_modification.py -f ${ofile} -v ${sstname} -k ${sstkind} -L XLONG_M -l XLAT_M -s ${addvalues}
99    npy=$?
100    if test ! ${npy} -eq 0; then
101      echo ${errormsg}
102      echo "  Pythhon 'sfcVAR_global_modification.py' does not work!"
103      echo ${errormsg}
104      exit
105    fi
106  fi
107
108# Without including extra level
109 exit
110
111# Ztop variables
112##
113  echo "  Adding top variables at p=0 i.." 
114  ztopvars=`echo ${zTopvars} | tr ':' ' '`
115  for zvar in ${ztopvars}; do
116    zvarn=`echo ${zvar} | tr '@' ' ' | awk '{print $1}'`
117    zvarv=`echo ${zvar} | tr '@' ' ' | awk '{print $2}'`
118    echo "    "${zvar}
119    python ${HOME}/PY/nc_var.py -f ${ofile} -v ${zvarn} -o addvals -S '1:last:1:'${zvarv}
120  done
121  python ${HOME}/PY/nc_var.py -f ${ofile} -o gaddattrk -S 'BOTTOM-TOP_GRID_DIMENSION|39|Inp32'
122
123# Giving the geopotential and temperature at the top (assuming p_top 0.0001 hPa)
124  python values_Zlevel.py -f ${ofile} -z -1 -g GHT -H HGT_M -L XLONG_M -l XLAT_M -p PRES -r RH -t TT -P -1,-1
125
126  echo "Aqua-planet like '"${ofile}"' file generated"
127
128fi
Note: See TracBrowser for help on using the repository browser.