source: trunk/detectbarotropicmode.sh @ 47

Last change on this file since 47 was 47, checked in by pinsard, 10 years ago

fix thanks to coding rules

  • Property svn:executable set to *
  • Property svn:keyword set to Id
File size: 4.1 KB
Line 
1#! /bin/sh
2#
3#+
4#
5# .. _detectbarotropicmode.sh:
6#
7# =======================
8# detectbarotropicmode.sh
9# =======================
10#
11# -------------------------------------------
12# build file for detection of barotropic mode
13# -------------------------------------------
14#
15# SYNOPSIS
16# ========
17#
18# .. code-blcok:: bash
19#
20#    detectbarotropicmode.sh -l list -r resolution -exp experience -g grid \
21#    -latmin latmin -latmax latmax -longmin longmin -longmax longmax
22#
23# DESCRIPTION
24# ===========
25#
26#
27# EXAMPLES
28# ========
29#
30# For detection on DRAKKAR G42 experiment with ORCA025 resolution on T points
31# in the box [-50,30] [295,335]:
32#
33# .. code-block :: bash
34#
35#    detectbarotropicmode.sh -l ${GEOMAG_OD}/list_G42 -r ORCA025 -exp G42 -g gridT \
36#    -latmin -50 -latmax -30 -longmin 295 -longmax 335
37#
38# EVOLUTIONS
39# ==========
40#
41# $Id$
42#
43# pas fini ++
44#
45# - reee522 2007-11-26T11:33:42Z rhodes (IRIX64)
46#
47#   * externalization of copy of data file in getmodelout.sh
48#
49# - reee522 2007-11-26T10:55:44Z rhodes (IRIX64)
50#
51#   * add ncks, ncrcat and some informations inspired by
52#     http://dods.ipsl.jussieu.fr/projets_ES/misc/myls
53#
54# - fplod 2007-11-23T17:02:56Z aedon.locean-ipsl.upmc.fr (Darwin)
55#
56#   * creation
57#
58#-
59#
60command=detectbarotropicmode.sh
61#
62usage=" Usage : ${command} -l list -r orcares -exp drakkar_exp -g grid -latmin latmin -latmax latmax -longmin longmin -longmax longmax"
63#
64set +u
65while [ ! -z "${1}" ]
66do
67   case ${1} in
68      -l)
69         list=${2}
70         shift
71      ;;
72      -r)
73         orcares=${2}
74         shift
75      ;;
76      -exp)
77         drakkar_exp=${2}
78         shift
79      ;;
80      -g)
81         grid=${2}
82         shift
83      ;;
84      -latmin)
85         latmin=${2}
86         shift
87      ;;
88      -latmax)
89         latmax=${2}
90         shift
91      ;;
92      -longmin)
93         longmin=${2}
94         shift
95      ;;
96      -longmax)
97         longmax=${2}
98         shift
99      ;;
100      *)
101         # other choice
102         echo "eee : unknown option ${1}"
103         echo "${usage}"
104      ;;
105   esac
106   # next flag
107   shift
108done
109#
110set -u
111#
112# check GEOMAG environement
113if [ ! -d ${GEOMAG_LOG} ]
114then
115   echo " eee : \${GEOMAG_LOG} not found"
116   exit 1
117fi
118# ++ blindage en tout genre
119#
120case ${grid} in
121   gridT)
122      echo "iii : grid=${orcares}"
123   ;;
124   *)
125      echo "eee : pb \${grid} = ${grid}"
126      exit 1
127   ;;
128esac
129#
130case ${orcares} in
131   ORCA025)
132      echo "iii : orcares=${orcares}"
133   ;;
134   *)
135      echo "eee : pb \${orcares} = ${orcares}"
136      exit 1
137   ;;
138esac
139#
140case ${drakkar_exp} in
141   G42)
142      echo "iii : drakkar_exp=${drakkar_exp}"
143   ;;
144   *)
145      echo "eee : pb \${drakkar_exp} = ${drakkar_exp}"
146      exit 1
147   ;;
148esac
149#
150# ++ conversion of latitude and longitude in x and y indexes
151case ${orcares} in
152   ORCA025)
153      xmin=529
154      xmax=689
155      ymin=266
156      ymax=372
157      echo "iii : forcage xmin xmax ymin ymax : ${xmin} ${xmax} ${ymin} ${ymax}"
158   ;;
159   *)
160      echo "eee : pb conversion lat,long to x,y"
161      exit 1
162   ;;
163esac
164#
165# extract ssh and create a new set of files
166list_ssh=""
167for file in `cat ${list}`
168do
169   echo "iii : extraction from ${file}" # ++ voir seulement si debug demandé
170   filessh=${GEOMAG_OD}/`basename ${file} .nc`_ssh.nc
171   rm -f ${filessh} 2> /dev/null
172   ncks --dimension x,${xmin},${xmax} --dimension y,${ymin},${ymax}  -v sossheig,nav_lon,nav_lat \
173      ${file} ${filessh}
174   status_ncks=${?}
175   if [ ${status_ncks} -ne 0 ]
176   then
177      echo "eee : pb with ncks ${file}"
178      exit 1
179   else
180      list_ssh="${list_ssh} ${filessh}"
181   fi
182done
183line=`head -n 1 ${list}`
184bfile=`basename ${line}`
185datemin=`echo ${bfile}  | awk -F "_" '{print $2}'`
186line=`tail -n 1 ${list}`
187bfile=`basename ${line}`
188datemax=`echo ${bfile}  | awk -F "_" '{print $2}'`
189#
190# concatenation
191filetot=${GEOMAG_OD}/${orcares}-${drakkar_exp}_${datemin}_${datemax}_${grid}_ssh.nc
192rm -f ${filetot} 2> /dev/null
193ncrcat ${list_ssh} ${filetot}
194status_ncrcat=${?}
195if [ ${status_ncrcat} -ne 0 ]
196then
197   echo "eee : pb with ncrcat"
198   exit 1
199else
200   echo "iii : result in ${filetot}"
201fi
202#
203# ++ global attributes
204# ++ convention
205# ++ nedtcf output or ascii
206# clean
207rm ${list_ssh}
208#
209# end
210exit 0
Note: See TracBrowser for help on using the repository browser.