source: trunk/src/get_oaflux.sh @ 50

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

replace TROPFLUX by PROJECT

  • Property svn:executable set to *
File size: 4.5 KB
Line 
1#! /bin/sh
2#+
3#
4# .. program:: get_oaflux.sh
5#
6# .. _get_oaflux.sh:
7#
8# ==========================================
9# get_oaflux.sh -- Get OAFLUX reference file
10# ==========================================
11#
12# SYNOPSIS
13# ========
14#
15# ::
16#
17#  $ get_oaflux.sh
18#
19# DESCRIPTION
20# ===========
21#
22# Put in ${PROJECT_ID} OAFLUX reference file
23#
24# Once this tool executed :ref:`oaflux_mask_30N30S.pro` can be launched.
25#
26# Log file is written on :file:`${PROJECT_LOG}/get_oaflux.log.{YYYYMMDDTHHMMSSZ}`
27#
28#
29#     .. graphviz::
30#
31#        digraph get_oaflux {
32#           graph [
33#           rankdir="TB",
34#           ]
35#
36#           oaflux_ref [shape=diamond,fontname=Courier,label="ftp://ftp.whoi.edu/pub/science/oaflux/data_v3/monthly/turbulence/lh_oaflux_2004.nc.gz"];
37#
38#           file_oaflux [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/lh_oaflux_2004.nc"];
39#
40#           get_oaflux [shape=box,
41#           fontname=Courier,
42#           color=blue,
43#           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/get_oaflux.sh"
44#           label="${PROJECT}/src/get_oaflux.sh"];
45#           get_oaflux [shape=box,
46#           fontname=Courier,
47#           color=blue,
48#           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/get_oaflux.sh"
49#           label="${PROJECT}/src/get_oaflux.sh"];
50#
51#           {oaflux_ref} -> {get_oaflux} -> {file_oaflux}
52#
53#          }
54#
55#
56# EXAMPLES
57# ========
58#
59# If you are working on LOCEAN machine and you don't have any reference data,
60# you just have to run this tool ::
61#
62#  $ get_oaflux.sh
63#
64# And look at log file with ::
65#
66#  $ tlogd.sh get_oaflux
67#
68# and of course on files in ${PROJECT_ID}.
69#
70# TODO
71# ====
72#
73# SEE ALSO
74# ========
75#
76# :ref:`guide data OAFLUX <data_in_oaflux>`
77#
78# :ref:`project_profile.sh`
79#
80# :ref:`oaflux_mask_30N30S.pro`
81#
82# EVOLUTIONS
83# ==========
84#
85# - fplod 20110421T125407Z aedon.locean-ipsl.upmc.fr (Darwin)
86#
87#   * typo
88#
89# - fplod 20101216T152647Z aedon.locean-ipsl.upmc.fr (Darwin)
90#
91#   * creation
92#
93#-
94system=$(uname)
95case "${system}" in
96   AIX|IRIX64)
97      echo "www : no specific posix checking"
98   ;;
99   *)
100     set -o posix
101   ;;
102esac
103unset system
104#
105LANG=POSIX
106#
107command=$(basename ${0})
108log_date=$(date -u +"%Y%m%dT%H%M%SZ")
109#
110usage=" Usage : ${command}"
111#
112hostname=$(hostname)
113#
114# default
115# N.A. because no parameters
116#
117set -u
118#
119# test if wget available
120tool=wget
121type ${tool} 1> /dev/null 2>&1
122status=${?}
123if [ ${status} -ne 0 ]
124then
125   echo "${command} : eee : tool ${tool} not found"
126   exit 1
127fi
128unset status
129unset tool
130#
131# test if gunzip available
132tool=gunzip
133type ${tool} 1> /dev/null 2>&1
134status=${?}
135if [ ${status} -ne 0 ]
136then
137   echo "${command} : eee : tool ${tool} not found"
138   exit 1
139fi
140unset status
141unset tool
142#
143# check for ${PROJECT_LOG} definition
144if [ "${PROJECT_LOG}" = "" ]
145then
146   echo "${command} : eee : \${PROJECT_LOG} not defined"
147   exit 1
148fi
149#
150# check for ${PROJECT_LOG} existence
151if [ ! -d ${PROJECT_LOG} ]
152then
153   echo "${command} : eee : ${PROJECT_LOG} not found"
154   exit 1
155fi
156#
157# check for permission access on PROJECT_LOG
158if [ ! -x ${PROJECT_LOG} ]
159then
160   echo "${command} : eee : ${PROJECT_LOG} not reachable"
161   exit 1
162fi
163#
164# check for write permission on PROJECT_LOG
165if [ ! -w ${PROJECT_LOG} ]
166then
167   echo "${command} : eee : ${PROJECT_LOG} not writable"
168   exit 1
169fi
170#
171log=${PROJECT_LOG}/$(basename ${0} .sh).log.${log_date}
172echo "[Context]" 1>> ${log}
173echo "command=$(basename ${0})" 1>>${log}
174echo "hostname=${hostname}" 1>> ${log}
175echo "runtime=${log_date}" 1>> ${log}
176unset log_date
177echo "" 1>> ${log}
178#
179fileref=lh_oaflux_2004.nc
180fileref_gz=${fileref}.gz
181locref=ftp://ftp.whoi.edu/pub/science/oaflux/data_v3/monthly/turbulence/
182if  [ -f ${PROJECT_ID}/${fileref} ]
183then
184   echo "${command} : iii : ${PROJECT_ID}/${fileref} exist" 1>> ${log}
185   echo "${command} : iii : nothing done" 1>> ${log}
186else
187   wget --tries=1 --no-verbose -P ${PROJECT_ID} ${locref}/${fileref_gz} 1>> ${log} 2>&1
188   wget_status=${?}
189   if [ ${wget_status} -ne 0 ]
190   then
191      echo "${command} : eee : ${locref}/${fileref_gz} not found" >> ${log} 2>&1
192      # exit 1 #++
193   else
194      echo "${command} : iii : ${locref}/${fileref_gz} found" >> ${log} 2>&1
195   fi
196   unset wget_status
197   #
198   # decompress
199   gunzip ${PROJECT_ID}${fileref_gz}
200   gunzip_status=${?}
201   if [ ${gunzip_status} -ne 0 ]
202   then
203      echo "${command} : eee : ${locref}/${fileref_gz} not found" >> ${log} 2>&1
204      # exit 1 #++
205   else
206      echo "${command} : iii : ${locref}/${fileref_gz} found" >> ${log} 2>&1
207   fi
208fi
209unset fileref
210unset fileref_gz
211unset locref
212#
213unset command
214unset log
215unset hostname
216#
217# end
218exit 0
Note: See TracBrowser for help on using the repository browser.