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 | #- |
---|
88 | system=$(uname) |
---|
89 | case "${system}" in |
---|
90 | AIX|IRIX64) |
---|
91 | echo "www : no specific posix checking" |
---|
92 | ;; |
---|
93 | *) |
---|
94 | set -o posix |
---|
95 | ;; |
---|
96 | esac |
---|
97 | unset system |
---|
98 | # |
---|
99 | LANG=POSIX |
---|
100 | # |
---|
101 | command=$(basename ${0}) |
---|
102 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
103 | # |
---|
104 | usage=" Usage : ${command}" |
---|
105 | # |
---|
106 | hostname=$(hostname) |
---|
107 | # |
---|
108 | # default |
---|
109 | # N.A. because no parameters |
---|
110 | # |
---|
111 | set -u |
---|
112 | # |
---|
113 | # test if wget available |
---|
114 | tool=wget |
---|
115 | type ${tool} 1> /dev/null 2>&1 |
---|
116 | status=${?} |
---|
117 | if [ ${status} -ne 0 ] |
---|
118 | then |
---|
119 | echo "${command} : eee : tool ${tool} not found" |
---|
120 | exit 1 |
---|
121 | fi |
---|
122 | unset status |
---|
123 | unset tool |
---|
124 | # |
---|
125 | # test if gunzip available |
---|
126 | tool=gunzip |
---|
127 | type ${tool} 1> /dev/null 2>&1 |
---|
128 | status=${?} |
---|
129 | if [ ${status} -ne 0 ] |
---|
130 | then |
---|
131 | echo "${command} : eee : tool ${tool} not found" |
---|
132 | exit 1 |
---|
133 | fi |
---|
134 | unset status |
---|
135 | unset tool |
---|
136 | # |
---|
137 | # check for ${TROPFLUX_LOG} definition |
---|
138 | if [ "${TROPFLUX_LOG}" = "" ] |
---|
139 | then |
---|
140 | echo "${command} : eee : \${TROPFLUX_LOG} not defined" |
---|
141 | exit 1 |
---|
142 | fi |
---|
143 | # |
---|
144 | # check for ${TROPFLUX_LOG} existence |
---|
145 | if [ ! -d ${TROPFLUX_LOG} ] |
---|
146 | then |
---|
147 | echo "${command} : eee : ${TROPFLUX_LOG} not found" |
---|
148 | exit 1 |
---|
149 | fi |
---|
150 | # |
---|
151 | # check for permission access on TROPFLUX_LOG |
---|
152 | if [ ! -x ${TROPFLUX_LOG} ] |
---|
153 | then |
---|
154 | echo "${command} : eee : ${TROPFLUX_LOG} not reachable" |
---|
155 | exit 1 |
---|
156 | fi |
---|
157 | # |
---|
158 | # check for write permission on TROPFLUX_LOG |
---|
159 | if [ ! -w ${TROPFLUX_LOG} ] |
---|
160 | then |
---|
161 | echo "${command} : eee : ${TROPFLUX_LOG} not writable" |
---|
162 | exit 1 |
---|
163 | fi |
---|
164 | # |
---|
165 | log=${TROPFLUX_LOG}/$(basename ${0} .sh).log.${log_date} |
---|
166 | echo "[Context]" 1>> ${log} |
---|
167 | echo "command=$(basename ${0})" 1>>${log} |
---|
168 | echo "hostname=${hostname}" 1>> ${log} |
---|
169 | echo "runtime=${log_date}" 1>> ${log} |
---|
170 | unset log_date |
---|
171 | echo "" 1>> ${log} |
---|
172 | # |
---|
173 | fileref=lh_oaflux_2004.nc |
---|
174 | fileref_gz=${fileref}.gz |
---|
175 | locref=ftp://ftp.whoi.edu/pub/science/oaflux/data_v3/monthly/turbulence/ |
---|
176 | if [ -f ${TROPFLUX_ID}/${fileref} ] |
---|
177 | then |
---|
178 | echo "${command} : iii : ${TROPFLUX_ID}/${fileref} exist" 1>> ${log} |
---|
179 | echo "${command} : iii : nothing done" 1>> ${log} |
---|
180 | else |
---|
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 |
---|
202 | fi |
---|
203 | unset fileref |
---|
204 | unset fileref_gz |
---|
205 | unset locref |
---|
206 | # |
---|
207 | unset command |
---|
208 | unset log |
---|
209 | unset hostname |
---|
210 | # |
---|
211 | # end |
---|
212 | exit 0 |
---|