source: trunk/src/get_pirata_netcdf.sh @ 199

Last change on this file since 199 was 199, checked in by pinsard, 11 years ago

fix svn properties

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