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