source: trunk/src/get_oaflux.sh @ 26

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

add OAFLUX and ERA-I in guides

  • Property svn:executable set to *
File size: 4.4 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 ${TROPFLUX_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:`${TROPFLUX_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="${TROPFLUX_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="${TROPFLUX}/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.pro"
49#           label="${TROPFLUX}/src/get_oaflux.pro"];
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 ${TROPFLUX_ID}.
69#
70# TODO
71# ====
72#
73# SEE ALSO
74# ========
75#
76# :ref:`guide data OAFLUX <data_in_oaflux>`
77#
78# :ref:`tropflux_profile.sh`
79#
80# EVOLUTIONS
81# ==========
82#
83# - fplod 20101216T152647Z aedon.locean-ipsl.upmc.fr (Darwin)
84#
85#   * creation
86#
87#-
88system=$(uname)
89case "${system}" in
90   AIX|IRIX64)
91      echo "www : no specific posix checking"
92   ;;
93   *)
94     set -o posix
95   ;;
96esac
97unset system
98#
99LANG=POSIX
100#
101command=$(basename ${0})
102log_date=$(date -u +"%Y%m%dT%H%M%SZ")
103#
104usage=" Usage : ${command}"
105#
106hostname=$(hostname)
107#
108# default
109# N.A. because no parameters
110#
111set -u
112#
113# test if wget available
114tool=wget
115type ${tool} 1> /dev/null 2>&1
116status=${?}
117if [ ${status} -ne 0 ]
118then
119   echo "${command} : eee : tool ${tool} not found"
120   exit 1
121fi
122unset status
123unset tool
124#
125# test if gunzip available
126tool=gunzip
127type ${tool} 1> /dev/null 2>&1
128status=${?}
129if [ ${status} -ne 0 ]
130then
131   echo "${command} : eee : tool ${tool} not found"
132   exit 1
133fi
134unset status
135unset tool
136#
137# check for ${TROPFLUX_LOG} definition
138if [ "${TROPFLUX_LOG}" = "" ]
139then
140   echo "${command} : eee : \${TROPFLUX_LOG} not defined"
141   exit 1
142fi
143#
144# check for ${TROPFLUX_LOG} existence
145if [ ! -d ${TROPFLUX_LOG} ]
146then
147   echo "${command} : eee : ${TROPFLUX_LOG} not found"
148   exit 1
149fi
150#
151# check for permission access on TROPFLUX_LOG
152if [ ! -x ${TROPFLUX_LOG} ]
153then
154   echo "${command} : eee : ${TROPFLUX_LOG} not reachable"
155   exit 1
156fi
157#
158# check for write permission on TROPFLUX_LOG
159if [ ! -w ${TROPFLUX_LOG} ]
160then
161   echo "${command} : eee : ${TROPFLUX_LOG} not writable"
162   exit 1
163fi
164#
165log=${TROPFLUX_LOG}/$(basename ${0} .sh).log.${log_date}
166echo "[Context]" 1>> ${log}
167echo "command=$(basename ${0})" 1>>${log}
168echo "hostname=${hostname}" 1>> ${log}
169echo "runtime=${log_date}" 1>> ${log}
170unset log_date
171echo "" 1>> ${log}
172#
173fileref=lh_oaflux_2004.nc
174fileref_gz=${fileref}.gz
175locref=ftp://ftp.whoi.edu/pub/science/oaflux/data_v3/monthly/turbulence/
176if  [ -f ${TROPFLUX_ID}/${fileref} ]
177then
178   echo "${command} : iii : ${TROPFLUX_ID}/${fileref} exist" 1>> ${log}
179   echo "${command} : iii : nothing done" 1>> ${log}
180else
181   wget --tries=1 --no-verbose -P ${TROPFLUX_ID} ${locref}/${fileref_gz} 1>> ${log} 2>&1
182   wget_status=${?}
183   if [ ${wget_status} -ne 0 ]
184   then
185      echo "${command} : eee : ${locref}/${fileref_gz} not found" >> ${log} 2>&1
186      # exit 1 #++
187   else
188      echo "${command} : iii : ${locref}/${fileref_gz} found" >> ${log} 2>&1
189   fi
190   unset wget_status
191   #
192   # decompress
193   gunzip ${TROPFLUX_ID}${fileref_gz}
194   gunzip_status=${?}
195   if [ ${gunzip_status} -ne 0 ]
196   then
197      echo "${command} : eee : ${locref}/${fileref_gz} not found" >> ${log} 2>&1
198      # exit 1 #++
199   else
200      echo "${command} : iii : ${locref}/${fileref_gz} found" >> ${log} 2>&1
201   fi
202fi
203unset fileref
204unset fileref_gz
205unset locref
206#
207unset command
208unset log
209unset hostname
210#
211# end
212exit 0
Note: See TracBrowser for help on using the repository browser.