source: trunk/detectbarotropicmode.sh

Last change on this file was 48, 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.2 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-block:: 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 [ ${#} -gt 0 ]
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#
110# check GEOMAG environement
111if [ ! -d ${GEOMAG_LOG} ]
112then
113    echo " eee : \${GEOMAG_LOG} not found"
114    exit 1
115fi
116# ++ blindage en tout genre
117#
118case ${grid} in
119    gridT)
120        echo "iii : grid=${orcares}"
121    ;;
122    *)
123        echo "eee : pb \${grid} = ${grid}"
124        exit 1
125    ;;
126esac
127#
128case ${orcares} in
129    ORCA025)
130        echo "iii : orcares=${orcares}"
131    ;;
132    *)
133        echo "eee : pb \${orcares} = ${orcares}"
134        exit 1
135    ;;
136esac
137#
138case ${drakkar_exp} in
139    G42)
140        echo "iii : drakkar_exp=${drakkar_exp}"
141    ;;
142    *)
143        echo "eee : pb \${drakkar_exp} = ${drakkar_exp}"
144        exit 1
145    ;;
146esac
147#
148# ++ conversion of latitude and longitude in x and y indexes
149case ${orcares} in
150    ORCA025)
151        xmin=529
152        xmax=689
153        ymin=266
154        ymax=372
155        echo "iii : forcage xmin xmax ymin ymax : ${xmin} ${xmax} ${ymin} ${ymax}"
156    ;;
157    *)
158        echo "eee : pb conversion lat,long to x,y"
159        exit 1
160    ;;
161esac
162#
163# extract ssh and create a new set of files
164list_ssh=""
165for file in `cat ${list}`
166do
167    echo "iii : extraction from ${file}" # ++ voir seulement si debug demandé
168    filessh=${GEOMAG_OD}/`basename ${file} .nc`_ssh.nc
169    rm -f ${filessh} 2> /dev/null
170    ncks --dimension x,${xmin},${xmax} --dimension y,${ymin},${ymax}  -v sossheig,nav_lon,nav_lat \
171    ${file} ${filessh}
172    status_ncks=${?}
173    if [ ${status_ncks} -ne 0 ]
174    then
175        echo "eee : pb with ncks ${file}"
176        exit 1
177    else
178        list_ssh="${list_ssh} ${filessh}"
179    fi
180done
181line=`head -n 1 ${list}`
182bfile=`basename ${line}`
183datemin=`echo ${bfile}  | awk -F "_" '{print $2}'`
184line=`tail -n 1 ${list}`
185bfile=`basename ${line}`
186datemax=`echo ${bfile}  | awk -F "_" '{print $2}'`
187#
188# concatenation
189filetot=${GEOMAG_OD}/${orcares}-${drakkar_exp}_${datemin}_${datemax}_${grid}_ssh.nc
190rm -f ${filetot} 2> /dev/null
191ncrcat ${list_ssh} ${filetot}
192status_ncrcat=${?}
193if [ ${status_ncrcat} -ne 0 ]
194then
195    echo "eee : pb with ncrcat"
196    exit 1
197else
198    echo "iii : result in ${filetot}"
199fi
200#
201# ++ global attributes
202# ++ convention
203# ++ nedtcf output or ascii
204# clean
205rm ${list_ssh}
206#
207# end
208exit 0
Note: See TracBrowser for help on using the repository browser.