source: trunk/src/get_oaflux.sh @ 169

Last change on this file since 169 was 164, checked in by pinsard, 12 years ago

fix for developper documentation

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