source: trunk/src/get_pirata_netcdf.sh @ 79

Last change on this file since 79 was 50, checked in by pinsard, 13 years ago

replace TROPFLUX by PROJECT

File size: 4.8 KB
Line 
1#! /bin/sh
2#+
3#
4# .. program:: get_pirata_netcdf.sh
5#
6# .. _get_pirata_netcdf.sh:
7#
8# ==================================================
9# get_pirata_netcdf.sh -- get PIRATA reference files
10# ==================================================
11#
12#
13# SYNOPSIS
14# ========
15#
16# ::
17#
18#  $ get_pirata_netcdf.sh
19#
20# DESCRIPTION
21# ===========
22#
23# ``get_pirata_netcdf.sh`` get PIRATA reference files
24#
25# bf
26#   buoyancy flux
27# d
28#   sigma-theta
29# dyn
30#   dynamic height
31# emp
32#   e-p
33# iso
34#   20C depth
35# met
36#   wind (u,v,speed,direction),  airT, hum rel, SST   (= w + airt + rh)
37# pos
38#   lon, lat
39# rad
40#   shortwave down
41# rf
42#   rain heat flux
43# w
44#   wind
45#
46# Log file is written on :file:`${PROJECT_LOG}/get_pirata_netcdf.log.{YYYYMMDDTHHMMSSZ}`
47#
48#     .. graphviz::
49#
50#        digraph get_pirata_netcdf {
51#           graph [
52#           rankdir="TB",
53#           ]
54#
55#           pirata_ref [shape=diamond,fontname=Courier,label="ftp://ftp.pmel.noaa.gov/cdf/sites/daily/*_*_dy.cdf"];
56#
57#           file_pirata  [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/*_*_dy.cdf"];
58#
59#           get_pirata_netcdf [shape=box,
60#           fontname=Courier,
61#           color=blue,
62#           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/get_pirata_netcdf.sh"
63#           label="${PROJECT}/src/get_pirata_netcdf.sh"];
64#
65#           {pirata_ref} -> {get_pirata_netcdf} -> {file_pirata}
66#
67#          }
68#
69# EXAMPLES
70# ========
71#
72# You don't have any PIRATA reference data, you just have to run this tool ::
73#
74#  $ get_pirata_netcdf.sh
75#
76# And look at log file with ::
77#
78#  $ tlogd.sh get_pirata_netcdf
79#
80# and of course on files in ${PROJECT_ID}.
81#
82# SEE ALSO
83# ========
84#
85# :ref:`guide data PIRATA <data_in_pirata>`
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 20110421T125622Z aedon.locean-ipsl.upmc.fr (Darwin)
104#
105#   * consolidation
106#
107# - fplod 20101213T160729Z 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}
186unset log_date
187echo "" 1>> ${log}
188#
189varlist="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"
190sitelist="          0n0e"
191sitelist="${sitelist} 10s10w 6s10w 0n10w"
192sitelist="${sitelist} 0n23w 4n23w 12n23w 21n23w"
193sitelist="${sitelist} 19s34w 14s32w 8s30w 0n35w"
194sitelist="${sitelist} 4n38w 8n38w 12n38w 15n38w 20n38w"
195#
196locref="ftp://ftp.pmel.noaa.gov/cdf/sites/daily"
197#
198list_url=""
199#
200# build URL = f(site,var)
201for site in ${sitelist}
202do
203   for var in ${varlist}
204   do
205       list_url="${list_url} ${locref}/${var}${site}_dy.cdf"
206   done
207done
208unset site
209unset var
210unset varlist
211unset sitelist
212unset locref
213#
214# if file is not already in ${PROJECT_ID}, get it
215for url in ${list_url}
216do
217  file=${PROJECT_ID}/$(basename ${url})
218  if [ ! -f ${file} ]
219  then
220     wget --tries=1 --no-verbose -P ${PROJECT_ID} \
221        --user=taopmelftp \
222        --password=G10b@LCh@Ng3 \
223        ${url} >> ${log} 2>&1
224     wget_status=${?}
225     if [ ${wget_status} -ne 0 ]
226     then
227        echo "${command} : eee : ${url} not found" >> ${log} 2>&1
228        # ++ exit 1
229     else
230        echo "${command} : iii : ${url} found" >> ${log} 2>&1
231     fi
232     unset wget_status
233  else
234     echo "iii : ${file} exists" >> ${log}
235  fi
236done
237unset file
238unset url
239unset list_url
240#
241unset command
242unset log
243unset hostname
244unset usage
245#
246# end
247set
248exit 0
Note: See TracBrowser for help on using the repository browser.