[15] | 1 | #! /bin/sh |
---|
| 2 | #+ |
---|
| 3 | # |
---|
| 4 | # .. program:: get_oaflux.sh |
---|
| 5 | # |
---|
[16] | 6 | # .. _get_oaflux.sh: |
---|
| 7 | # |
---|
[15] | 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 | # |
---|
[50] | 22 | # Put in ${PROJECT_ID} OAFLUX reference file |
---|
[15] | 23 | # |
---|
| 24 | # Once this tool executed :ref:`oaflux_mask_30N30S.pro` can be launched. |
---|
| 25 | # |
---|
[50] | 26 | # Log file is written on :file:`${PROJECT_LOG}/get_oaflux.log.{YYYYMMDDTHHMMSSZ}` |
---|
[15] | 27 | # |
---|
[16] | 28 | # |
---|
| 29 | # .. graphviz:: |
---|
| 30 | # |
---|
[15] | 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 | # |
---|
[50] | 38 | # file_oaflux [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/lh_oaflux_2004.nc"]; |
---|
[15] | 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" |
---|
[50] | 44 | # label="${PROJECT}/src/get_oaflux.sh"]; |
---|
[15] | 45 | # get_oaflux [shape=box, |
---|
| 46 | # fontname=Courier, |
---|
| 47 | # color=blue, |
---|
[48] | 48 | # URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/get_oaflux.sh" |
---|
[50] | 49 | # label="${PROJECT}/src/get_oaflux.sh"]; |
---|
[15] | 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 | # |
---|
[50] | 68 | # and of course on files in ${PROJECT_ID}. |
---|
[15] | 69 | # |
---|
| 70 | # TODO |
---|
| 71 | # ==== |
---|
| 72 | # |
---|
| 73 | # SEE ALSO |
---|
| 74 | # ======== |
---|
| 75 | # |
---|
| 76 | # :ref:`guide data OAFLUX <data_in_oaflux>` |
---|
| 77 | # |
---|
[50] | 78 | # :ref:`project_profile.sh` |
---|
[15] | 79 | # |
---|
[33] | 80 | # :ref:`oaflux_mask_30N30S.pro` |
---|
| 81 | # |
---|
[15] | 82 | # EVOLUTIONS |
---|
| 83 | # ========== |
---|
| 84 | # |
---|
[48] | 85 | # - fplod 20110421T125407Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 86 | # |
---|
| 87 | # * typo |
---|
| 88 | # |
---|
[15] | 89 | # - fplod 20101216T152647Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 90 | # |
---|
| 91 | # * creation |
---|
| 92 | # |
---|
| 93 | #- |
---|
| 94 | system=$(uname) |
---|
| 95 | case "${system}" in |
---|
| 96 | AIX|IRIX64) |
---|
| 97 | echo "www : no specific posix checking" |
---|
| 98 | ;; |
---|
| 99 | *) |
---|
| 100 | set -o posix |
---|
| 101 | ;; |
---|
| 102 | esac |
---|
| 103 | unset system |
---|
| 104 | # |
---|
| 105 | LANG=POSIX |
---|
| 106 | # |
---|
| 107 | command=$(basename ${0}) |
---|
| 108 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
| 109 | # |
---|
| 110 | usage=" Usage : ${command}" |
---|
| 111 | # |
---|
| 112 | hostname=$(hostname) |
---|
| 113 | # |
---|
| 114 | # default |
---|
| 115 | # N.A. because no parameters |
---|
| 116 | # |
---|
| 117 | set -u |
---|
| 118 | # |
---|
| 119 | # test if wget available |
---|
| 120 | tool=wget |
---|
| 121 | type ${tool} 1> /dev/null 2>&1 |
---|
| 122 | status=${?} |
---|
| 123 | if [ ${status} -ne 0 ] |
---|
| 124 | then |
---|
| 125 | echo "${command} : eee : tool ${tool} not found" |
---|
| 126 | exit 1 |
---|
| 127 | fi |
---|
| 128 | unset status |
---|
| 129 | unset tool |
---|
| 130 | # |
---|
| 131 | # test if gunzip available |
---|
| 132 | tool=gunzip |
---|
| 133 | type ${tool} 1> /dev/null 2>&1 |
---|
| 134 | status=${?} |
---|
| 135 | if [ ${status} -ne 0 ] |
---|
| 136 | then |
---|
| 137 | echo "${command} : eee : tool ${tool} not found" |
---|
| 138 | exit 1 |
---|
| 139 | fi |
---|
| 140 | unset status |
---|
| 141 | unset tool |
---|
| 142 | # |
---|
[50] | 143 | # check for ${PROJECT_LOG} definition |
---|
| 144 | if [ "${PROJECT_LOG}" = "" ] |
---|
[15] | 145 | then |
---|
[50] | 146 | echo "${command} : eee : \${PROJECT_LOG} not defined" |
---|
[15] | 147 | exit 1 |
---|
| 148 | fi |
---|
| 149 | # |
---|
[50] | 150 | # check for ${PROJECT_LOG} existence |
---|
| 151 | if [ ! -d ${PROJECT_LOG} ] |
---|
[15] | 152 | then |
---|
[50] | 153 | echo "${command} : eee : ${PROJECT_LOG} not found" |
---|
[15] | 154 | exit 1 |
---|
| 155 | fi |
---|
| 156 | # |
---|
[50] | 157 | # check for permission access on PROJECT_LOG |
---|
| 158 | if [ ! -x ${PROJECT_LOG} ] |
---|
[15] | 159 | then |
---|
[50] | 160 | echo "${command} : eee : ${PROJECT_LOG} not reachable" |
---|
[15] | 161 | exit 1 |
---|
| 162 | fi |
---|
| 163 | # |
---|
[50] | 164 | # check for write permission on PROJECT_LOG |
---|
| 165 | if [ ! -w ${PROJECT_LOG} ] |
---|
[15] | 166 | then |
---|
[50] | 167 | echo "${command} : eee : ${PROJECT_LOG} not writable" |
---|
[15] | 168 | exit 1 |
---|
| 169 | fi |
---|
| 170 | # |
---|
[50] | 171 | log=${PROJECT_LOG}/$(basename ${0} .sh).log.${log_date} |
---|
[15] | 172 | echo "[Context]" 1>> ${log} |
---|
| 173 | echo "command=$(basename ${0})" 1>>${log} |
---|
| 174 | echo "hostname=${hostname}" 1>> ${log} |
---|
| 175 | echo "runtime=${log_date}" 1>> ${log} |
---|
| 176 | unset log_date |
---|
| 177 | echo "" 1>> ${log} |
---|
| 178 | # |
---|
| 179 | fileref=lh_oaflux_2004.nc |
---|
| 180 | fileref_gz=${fileref}.gz |
---|
| 181 | locref=ftp://ftp.whoi.edu/pub/science/oaflux/data_v3/monthly/turbulence/ |
---|
[50] | 182 | if [ -f ${PROJECT_ID}/${fileref} ] |
---|
[15] | 183 | then |
---|
[50] | 184 | echo "${command} : iii : ${PROJECT_ID}/${fileref} exist" 1>> ${log} |
---|
[15] | 185 | echo "${command} : iii : nothing done" 1>> ${log} |
---|
| 186 | else |
---|
[50] | 187 | wget --tries=1 --no-verbose -P ${PROJECT_ID} ${locref}/${fileref_gz} 1>> ${log} 2>&1 |
---|
[15] | 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 |
---|
[50] | 199 | gunzip ${PROJECT_ID}${fileref_gz} |
---|
[15] | 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 |
---|
| 208 | fi |
---|
| 209 | unset fileref |
---|
| 210 | unset fileref_gz |
---|
| 211 | unset locref |
---|
| 212 | # |
---|
| 213 | unset command |
---|
| 214 | unset log |
---|
| 215 | unset hostname |
---|
| 216 | # |
---|
| 217 | # end |
---|
| 218 | exit 0 |
---|