source: trunk/src/get_tao_netcdf.sh @ 203

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

fix thanks to coding rules

  • Property svn:keywords set to Id URL
File size: 5.3 KB
Line 
1#! /bin/sh
2#+
3#
4# .. program:: get_tao_netcdf.sh
5#
6# .. _get_tao_netcdf.sh:
7#
8# =================
9# get_tao_netcdf.sh
10# =================
11#
12# SYNOPSIS
13# ========
14#
15# .. code-block:: bash
16#
17#    get_tao_netcdf.sh
18#
19# DESCRIPTION
20# ===========
21#
22# ``get_tao_netcdf.sh`` get TAO 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 :file:`${PROJECT_LOG}/get_tao_netcdf.log.{YYYYMMDDTHHMMSSZ}`
46#
47#     .. graphviz::
48#
49#        digraph get_tao_netcdf {
50#
51#           tao_ref [shape=diamond,fontname=Courier,label="ftp://ftp.pmel.noaa.gov/cdf/sites/daily/*_*_dy.cdf"];
52#
53#           file_tao  [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/*_*_dy.cdf"];
54#
55#           get_tao_netcdf [shape=box,
56#           fontname=Courier,
57#           color=blue,
58#           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/get_tao_netcdf.sh"
59#           label="${PROJECT}/src/get_tao_netcdf.sh"];
60#
61#           {tao_ref} -> {get_tao_netcdf} -> {file_tao}
62#
63#          }
64#
65# EXAMPLES
66# ========
67#
68# You don't have any TAO reference data, you just have to run this tool :
69#
70# .. code-block:: bash
71#
72#    get_tao_netcdf.sh
73#
74# And look at log file with :
75#
76# .. code-block:: bash
77#
78#    tlogd.sh get_tao_netcdf
79#
80# and of course on files in ${PROJECT_ID}.
81#
82# SEE ALSO
83# ========
84#
85# :ref:`guide data TAO <data_in_tao>`
86#
87# :ref:`project_profile.sh`
88#
89# TODO
90# ====
91#
92# list of variables and sites in DESCRIPTION
93#
94# do we really need all these variables and sites
95#
96# study wget status (no exit now on non null wget status)
97#
98# EVOLUTIONS
99# ==========
100#
101# $Id$
102#
103# - fplod 20110421T154046Z aedon.locean-ipsl.upmc.fr (Darwin)
104#
105#   * consolidation
106#
107# - fplod 20101213T161152Z aedon.locean-ipsl.upmc.fr (Darwin)
108#
109#   * minimal header
110#
111# - jv 2008
112#
113#   * creation
114#
115#-
116system=$(uname)
117case "${system}" in
118    AIX|IRIX64)
119        echo "www : no specific posix checking"
120    ;;
121    *)
122        set -o posix
123    ;;
124esac
125unset system
126#
127LANG=POSIX
128#
129command=$(basename ${0})
130log_date=$(date -u +"%Y%m%dT%H%M%SZ")
131#
132usage=" Usage : ${command}"
133#
134hostname=$(hostname)
135#
136# default
137# N.A. because no parameters
138#
139set -u
140#
141# test if wget available
142tool=wget
143type ${tool} 1> /dev/null 2>&1
144status=${?}
145if [ ${status} -ne 0 ]
146then
147    echo "${command} : eee : tool ${tool} not found"
148    exit 1
149fi
150unset status
151unset tool
152#
153# check for ${PROJECT_LOG} definition
154if [ "${PROJECT_LOG}" = "" ]
155then
156    echo "${command} : eee : \${PROJECT_LOG} not defined"
157    exit 1
158fi
159#
160# check for ${PROJECT_LOG} existence
161if [ ! -d ${PROJECT_LOG} ]
162then
163    echo "${command} : eee : ${PROJECT_LOG} not found"
164    exit 1
165fi
166#
167# check for permission access on PROJECT_LOG
168if [ ! -x ${PROJECT_LOG} ]
169then
170    echo "${command} : eee : ${PROJECT_LOG} not reachable"
171    exit 1
172fi
173#
174# check for write permission on PROJECT_LOG
175if [ ! -w ${PROJECT_LOG} ]
176then
177    echo "${command} : eee : ${PROJECT_LOG} not writable"
178    exit 1
179fi
180#
181log=${PROJECT_LOG}/$(basename ${0} .sh).log.${log_date}
182echo "[Context]" 1>> ${log}
183echo "command=$(basename ${0})" 1>>${log}
184echo "hostname=${hostname}" 1>> ${log}
185echo "runtime=${log_date}" 1>> ${log}
186echo "log=${log}" 1>> ${log}
187unset log_date
188echo "" 1>> ${log}
189#
190varlist="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"
191#
192sitelist="                                        2n137e 5n137e 8n137e"
193sitelist="${sitelist}                      0n147e 2n147e 5n147e"
194sitelist="${sitelist}        5s156e 2s156e 0n156e 2n156e 5n156e 8n156e"
195sitelist="${sitelist} 8s165e 5s165e 2s165e 0n165e 2n165e 5n165e 8n165e"
196sitelist="${sitelist} 8s180w 5s180w 2s180w 0n180w 2n180w 5n180w 8n180w"
197sitelist="${sitelist} 8s170w 5s170w 2s170w 0n170w 2n170w 5n170w 8n170w"
198sitelist="${sitelist} 8s155w 5s155w 2s155w 0n155w 2n155w 5n155w 8n155w"
199sitelist="${sitelist}        5s140w 2s140w 0n140w 2n140w 5n140w 9n140w"
200sitelist="${sitelist} 8s125w 5s125w 2s125w 0n125w 2n125w 5n125w 8n125w"
201sitelist="${sitelist} 8s110w 5s110w 2s110w 0n110w 2n110w 5n110w 8n110w"
202sitelist="${sitelist} 8s95w  5s95w  2s95w  0n95w  2n95w  5n95w  8n95w "
203#
204locref="ftp://ftp.pmel.noaa.gov/cdf/sites/daily"
205#
206list_url=""
207#
208# build URL = f(site,var)
209for site in ${sitelist}
210do
211    for var in ${varlist}
212    do
213        list_url="${list_url} ${locref}/${var}${site}_dy.cdf"
214    done
215done
216unset site
217unset var
218unset varlist
219unset sitelist
220unset locref
221#
222# if file is not already in ${PROJECT_ID}, get it
223for url in ${list_url}
224do
225    file=${PROJECT_ID}/$(basename ${url})
226    if [ ! -f ${file} ]
227    then
228        wget --tries=1 --no-verbose -P ${PROJECT_ID} \
229        --user=taopmelftp \
230        --password=G10b@LCh@Ng3 \
231        ${url} >> ${log} 2>&1
232        wget_status=${?}
233        if [ ${wget_status} -ne 0 ]
234        then
235            echo "${command} : eee : ${url} not found" >> ${log} 2>&1
236            # ++ exit 1
237        else
238            echo "${command} : iii : ${url} found" >> ${log} 2>&1
239        fi
240        unset wget_status
241    else
242        echo "iii : ${file} exists" >> ${log}
243    fi
244done
245unset file
246unset url
247unset list_url
248#
249unset command
250unset log
251unset hostname
252unset usage
253#
254# end
255set
256exit 0
Note: See TracBrowser for help on using the repository browser.