source: trunk/src/get_rama_netcdf.sh

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

fix thanks to coding rules; typo

  • Property svn:keywords set to Id URL
File size: 5.8 KB
Line 
1#! /bin/sh
2#+
3#
4# .. program:: get_rama_netcdf.sh
5#
6# .. _get_rama_netcdf.sh:
7#
8# ==================
9# get_rama_netcdf.sh
10# ==================
11#
12# SYNOPSIS
13# ========
14#
15# .. code-block:: bash
16#
17#    get_rama_netcdf.sh
18#
19# DESCRIPTION
20# ===========
21#
22# ``get_rama_netcdf.sh`` get RAMA reference files
23#
24# bf
25#   buoyancy flux
26# d
27#   sigma-theta
28# dyn
29#   dynamic height
30# emp
31#   e-p
32# iso
33#   20C depth
34# met
35#   wind (u,v,speed,direction),  airT, hum rel, SST   (= w + airt + rh)
36# pos
37#   lon, lat
38# rad
39#   shortwave down
40# rf
41#   rain heat flux
42# w
43#   wind
44#
45# Log file is written on
46# :file:`${PROJECT_LOG}/get_rama_netcdf.log.{YYYYMMDDTHHMMSS}Z`.
47#
48#     .. graphviz::
49#
50#        digraph get_rama_netcdf {
51#
52#           rama_ref [shape=diamond,
53#           fontname=Courier,
54#           label="ftp://ftp.pmel.noaa.gov/cdf/sites/daily/*_*_dy.cdf"];
55#
56#           file_rama [shape=ellipse,
57#           fontname=Courier,
58#           label="${PROJECT_ID}/*_*_dy.cdf"];
59#
60#           get_rama_netcdf [shape=box,
61#           fontname=Courier,
62#           color=blue,
63#           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/get_rama_netcdf.sh"
64#           label="${PROJECT}/src/get_rama_netcdf.sh"];
65#
66#           {rama_ref} -> {get_rama_netcdf} -> {file_rama}
67#
68#          }
69#
70# EXAMPLES
71# ========
72#
73# You don't have any RAMA reference data, you just have to run this tool :
74#
75# .. code-block:: bash
76#
77#    get_rama_netcdf.sh
78#
79# And look at log file with :
80#
81# .. code-block:: bash
82#
83#    tlogd.sh get_rama_netcdf
84#
85# and of course on files in ${PROJECT_ID}.
86#
87# SEE ALSO
88# ========
89#
90# :ref:`guide data RAMA <data_in_rama>`
91#
92# :ref:`project_profile.sh`
93#
94# TODO
95# ====
96#
97# list of variables and sites in DESCRIPTION
98#
99# do we really need all these variables and sites
100#
101# Liste complète de RAMA:
102#
103# .. code-block:: bash
104#
105#    sitelist="16s55e    12s55e    8s55e    4s55e    1.5s55e    0n55e    1.5n55e    4n55e"
106#    sitelist="${sitelist} 15n65e"
107#    sitelist="${sitelist} 12s67e     8s67e    4s67e    1.5s67e    0n67e     1.5n67e    4n67e    8n67e"
108#    sitelist="${sitelist} 16s80.5e 12s80.5e 8s80.5e 4s80.5e 1.5s80.5e 0n80.5e 1.5n80.5e 4n80.5e"
109#    sitelist="${sitelist} 1.5s90e 0n90e 1.5n90e 4n90e 8n90e 12n90e 15n90e
110#    sitelist="${sitelist} 16s95e 12s95e 8s95e  5s95e"
111#
112# study wget status (no exit now on non null wget status)
113#
114# EVOLUTIONS
115# ==========
116#
117# $Id$
118#
119# - fplod 20110421T133632Z aedon.locean-ipsl.upmc.fr (Darwin)
120#
121#   * consolidation
122#
123# - fplod 20101213T160928Z aedon.locean-ipsl.upmc.fr (Darwin)
124#
125#   * minimal header
126#
127# - jv 2008
128#
129#   * creation
130#
131#-
132system=$(uname)
133case "${system}" in
134    AIX|IRIX64)
135        echo "www : no specific posix checking"
136    ;;
137    *)
138        set -o posix
139    ;;
140esac
141unset system
142#
143LANG=POSIX
144#
145command=$(basename ${0})
146log_date=$(date -u +"%Y%m%dT%H%M%SZ")
147#
148usage=" Usage : ${command}"
149#
150hostname=$(hostname)
151#
152# default
153# N.A. because no parameters
154#
155set -u
156#
157# test if wget available
158tool=wget
159type ${tool} 1> /dev/null 2>&1
160status=${?}
161if [ ${status} -ne 0 ]
162then
163    echo "${command} : eee : tool ${tool} not found"
164    exit 1
165fi
166unset status
167unset tool
168#
169# check for ${PROJECT_LOG} definition
170if [ "${PROJECT_LOG}" = "" ]
171then
172    echo "${command} : eee : \${PROJECT_LOG} not defined"
173    exit 1
174fi
175#
176# check for ${PROJECT_LOG} existence
177if [ ! -d ${PROJECT_LOG} ]
178then
179    echo "${command} : eee : ${PROJECT_LOG} not found"
180    exit 1
181fi
182#
183# check for permission access on PROJECT_LOG
184if [ ! -x ${PROJECT_LOG} ]
185then
186    echo "${command} : eee : ${PROJECT_LOG} not reachable"
187    exit 1
188fi
189#
190# check for write permission on PROJECT_LOG
191if [ ! -w ${PROJECT_LOG} ]
192then
193    echo "${command} : eee : ${PROJECT_LOG} not writable"
194    exit 1
195fi
196#
197log=${PROJECT_LOG}/$(basename ${0} .sh).log.${log_date}
198echo "[Context]" 1>> ${log}
199echo "command=$(basename ${0})" 1>>${log}
200echo "hostname=${hostname}" 1>> ${log}
201echo "runtime=${log_date}" 1>> ${log}
202echo "log=${log}" 1>> ${log}
203unset log_date
204echo "" 1>> ${log}
205#
206varlist="adcp airt bf bp cur d dyn emp evap heat iso lw lwnet met pos qlat qnet qsen rad rain rf rh s ssd sss sst swnet t tau w"
207#
208sitelist="12s55e 8s55e 8s67e 8s80.5e 4s80.5e 1.5s80.5e 0n80.5e 1.5n80.5e 1.5s90e 0n90e 1.5n90e 4n90e 8n90e 12n90e 15n90e 5s95e"
209
210#
211#Liste complète de RAMA:
212#sitelist="                   16s55e    12s55e    8s55e    4s55e    1.5s55e    0n55e    1.5n55e    4n55e"
213#sitelist="${sitelist}                                                                               15n65e"
214#sitelist="${sitelist}                    12s67e     8s67e    4s67e    1.5s67e    0n67e     1.5n67e    4n67e    8n67e"
215#sitelist="${sitelist}  16s80.5e 12s80.5e 8s80.5e 4s80.5e 1.5s80.5e 0n80.5e 1.5n80.5e 4n80.5e"
216#sitelist="${sitelist}               1.5s90e 0n90e 1.5n90e 4n90e 8n90e 12n90e 15n90e
217#sitelist="${sitelist}  16s95e 12s95e 8s95e  5s95e"
218#
219#
220locref="ftp://ftp.pmel.noaa.gov/cdf/sites/daily"
221#
222list_url=""
223#
224# build URL = f(site,var)
225for site in ${sitelist}
226do
227    for var in ${varlist}
228    do
229        list_url="${list_url} ${locref}/${var}${site}_dy.cdf"
230    done
231done
232unset site
233unset var
234unset varlist
235unset sitelist
236unset locref
237#
238# if file is not already in ${PROJECT_ID}, get it
239for url in ${list_url}
240do
241    file=${PROJECT_ID}/$(basename ${url})
242    if [ ! -f ${file} ]
243    then
244        wget --tries=1 --no-verbose -P ${PROJECT_ID} \
245        --user=taopmelftp \
246        --password=G10b@LCh@Ng3 \
247        ${url} >> ${log} 2>&1
248        wget_status=${?}
249        if [ ${wget_status} -ne 0 ]
250        then
251            echo "${command} : eee : ${url} not found" >> ${log} 2>&1
252            # ++ exit 1
253        else
254            echo "${command} : iii : ${url} found" >> ${log} 2>&1
255        fi
256        unset wget_status
257    else
258        echo "iii : ${file} exists" >> ${log}
259    fi
260done
261unset file
262unset url
263unset list_url
264#
265unset command
266unset log
267unset hostname
268unset usage
269#
270# end
271set
272exit 0
Note: See TracBrowser for help on using the repository browser.