source: trunk/detectbarotropicmode.sh @ 42

Last change on this file since 42 was 42, checked in by pinsard, 14 years ago

improvements of headers and unset in shell scripts

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