[4] | 1 | #! /bin/sh |
---|
| 2 | #+ |
---|
| 3 | # |
---|
| 4 | # .. program:: get_tao_netcdf.sh |
---|
| 5 | # |
---|
| 6 | # .. _get_tao_netcdf.sh: |
---|
| 7 | # |
---|
| 8 | # ============================================ |
---|
| 9 | # get_tao_netcdf.sh -- get TAO reference files |
---|
| 10 | # ============================================ |
---|
| 11 | # |
---|
| 12 | # SYNOPSIS |
---|
| 13 | # ======== |
---|
| 14 | # |
---|
| 15 | # :: |
---|
| 16 | # |
---|
| 17 | # $ get_tao_netcdf.sh |
---|
| 18 | # |
---|
| 19 | # DESCRIPTION |
---|
| 20 | # =========== |
---|
| 21 | # |
---|
| 22 | # ``get_tao_netcdf.sh`` get TAO reference files |
---|
| 23 | # |
---|
[48] | 24 | # bf |
---|
| 25 | # buoyancy flux |
---|
| 26 | # d |
---|
| 27 | # sigma-theta |
---|
| 28 | # dyn |
---|
| 29 | # dynamic height |
---|
| 30 | # emp |
---|
| 31 | # e-p |
---|
| 32 | # iso |
---|
| 33 | # 20C depth |
---|
| 34 | # met |
---|
| 35 | # wind (u,v,speed,direction), airT, hum rel, SST (= w + airt + rh) |
---|
| 36 | # pos |
---|
| 37 | # lon, lat |
---|
| 38 | # rad |
---|
| 39 | # shortwave down |
---|
| 40 | # rf |
---|
| 41 | # rain heat flux |
---|
| 42 | # w |
---|
| 43 | # wind |
---|
| 44 | # |
---|
[50] | 45 | # Log file is written on :file:`${PROJECT_LOG}/get_tao_netcdf.log.{YYYYMMDDTHHMMSSZ}` |
---|
[48] | 46 | # |
---|
| 47 | # .. graphviz:: |
---|
| 48 | # |
---|
| 49 | # digraph get_tao_netcdf { |
---|
| 50 | # graph [ |
---|
| 51 | # rankdir="TB", |
---|
| 52 | # ] |
---|
| 53 | # |
---|
| 54 | # tao_ref [shape=diamond,fontname=Courier,label="ftp://ftp.pmel.noaa.gov/cdf/sites/daily/*_*_dy.cdf"]; |
---|
| 55 | # |
---|
[50] | 56 | # file_tao [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/*_*_dy.cdf"]; |
---|
[48] | 57 | # |
---|
| 58 | # get_tao_netcdf [shape=box, |
---|
| 59 | # fontname=Courier, |
---|
| 60 | # color=blue, |
---|
| 61 | # URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/get_tao_netcdf.sh" |
---|
[50] | 62 | # label="${PROJECT}/src/get_tao_netcdf.sh"]; |
---|
[48] | 63 | # |
---|
| 64 | # {tao_ref} -> {get_tao_netcdf} -> {file_tao} |
---|
| 65 | # |
---|
| 66 | # } |
---|
| 67 | # |
---|
| 68 | # EXAMPLES |
---|
| 69 | # ======== |
---|
| 70 | # |
---|
| 71 | # You don't have any TAO reference data, you just have to run this tool :: |
---|
| 72 | # |
---|
| 73 | # $ get_tao_netcdf.sh |
---|
| 74 | # |
---|
| 75 | # And look at log file with :: |
---|
| 76 | # |
---|
| 77 | # $ tlogd.sh get_tao_netcdf |
---|
| 78 | # |
---|
[50] | 79 | # and of course on files in ${PROJECT_ID}. |
---|
[48] | 80 | # |
---|
[4] | 81 | # SEE ALSO |
---|
| 82 | # ======== |
---|
| 83 | # |
---|
| 84 | # :ref:`guide data TAO <data_in_tao>` |
---|
| 85 | # |
---|
[50] | 86 | # :ref:`project_profile.sh` |
---|
[48] | 87 | # |
---|
[4] | 88 | # TODO |
---|
| 89 | # ==== |
---|
| 90 | # |
---|
[48] | 91 | # list of variables and sites in DESCRIPTION |
---|
[4] | 92 | # |
---|
[48] | 93 | # do we really need all these variables and sites |
---|
[4] | 94 | # |
---|
[48] | 95 | # study wget status (no exit now on non null wget status) |
---|
[4] | 96 | # |
---|
| 97 | # EVOLUTIONS |
---|
| 98 | # ========== |
---|
| 99 | # |
---|
[48] | 100 | # $Id$ |
---|
| 101 | # |
---|
| 102 | # - fplod 20110421T154046Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 103 | # |
---|
| 104 | # * consolidation |
---|
| 105 | # |
---|
[4] | 106 | # - fplod 20101213T161152Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 107 | # |
---|
| 108 | # * minimal header |
---|
| 109 | # |
---|
| 110 | # - jv 2008 |
---|
| 111 | # |
---|
| 112 | # * creation |
---|
| 113 | # |
---|
| 114 | #- |
---|
[48] | 115 | system=$(uname) |
---|
| 116 | case "${system}" in |
---|
| 117 | AIX|IRIX64) |
---|
| 118 | echo "www : no specific posix checking" |
---|
| 119 | ;; |
---|
| 120 | *) |
---|
| 121 | set -o posix |
---|
| 122 | ;; |
---|
| 123 | esac |
---|
| 124 | unset system |
---|
| 125 | # |
---|
| 126 | LANG=POSIX |
---|
| 127 | # |
---|
| 128 | command=$(basename ${0}) |
---|
| 129 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
| 130 | # |
---|
| 131 | usage=" Usage : ${command}" |
---|
| 132 | # |
---|
| 133 | hostname=$(hostname) |
---|
| 134 | # |
---|
| 135 | # default |
---|
| 136 | # N.A. because no parameters |
---|
| 137 | # |
---|
| 138 | set -u |
---|
| 139 | # |
---|
| 140 | # test if wget available |
---|
| 141 | tool=wget |
---|
| 142 | type ${tool} 1> /dev/null 2>&1 |
---|
| 143 | status=${?} |
---|
| 144 | if [ ${status} -ne 0 ] |
---|
| 145 | then |
---|
| 146 | echo "${command} : eee : tool ${tool} not found" |
---|
| 147 | exit 1 |
---|
| 148 | fi |
---|
| 149 | unset status |
---|
| 150 | unset tool |
---|
| 151 | # |
---|
[50] | 152 | # check for ${PROJECT_LOG} definition |
---|
| 153 | if [ "${PROJECT_LOG}" = "" ] |
---|
[48] | 154 | then |
---|
[50] | 155 | echo "${command} : eee : \${PROJECT_LOG} not defined" |
---|
[48] | 156 | exit 1 |
---|
| 157 | fi |
---|
| 158 | # |
---|
[50] | 159 | # check for ${PROJECT_LOG} existence |
---|
| 160 | if [ ! -d ${PROJECT_LOG} ] |
---|
[48] | 161 | then |
---|
[50] | 162 | echo "${command} : eee : ${PROJECT_LOG} not found" |
---|
[48] | 163 | exit 1 |
---|
| 164 | fi |
---|
| 165 | # |
---|
[50] | 166 | # check for permission access on PROJECT_LOG |
---|
| 167 | if [ ! -x ${PROJECT_LOG} ] |
---|
[48] | 168 | then |
---|
[50] | 169 | echo "${command} : eee : ${PROJECT_LOG} not reachable" |
---|
[48] | 170 | exit 1 |
---|
| 171 | fi |
---|
| 172 | # |
---|
[50] | 173 | # check for write permission on PROJECT_LOG |
---|
| 174 | if [ ! -w ${PROJECT_LOG} ] |
---|
[48] | 175 | then |
---|
[50] | 176 | echo "${command} : eee : ${PROJECT_LOG} not writable" |
---|
[48] | 177 | exit 1 |
---|
| 178 | fi |
---|
| 179 | # |
---|
[50] | 180 | log=${PROJECT_LOG}/$(basename ${0} .sh).log.${log_date} |
---|
[48] | 181 | echo "[Context]" 1>> ${log} |
---|
| 182 | echo "command=$(basename ${0})" 1>>${log} |
---|
| 183 | echo "hostname=${hostname}" 1>> ${log} |
---|
| 184 | echo "runtime=${log_date}" 1>> ${log} |
---|
| 185 | unset log_date |
---|
| 186 | echo "" 1>> ${log} |
---|
| 187 | # |
---|
[3] | 188 | varlist="adcp airt bf bp cur d dyn emp evap heat iso lw lwnet met pos qlat qnet qsen rad rain rf rh s ssd sss sst swnet t tau w" |
---|
[48] | 189 | # |
---|
| 190 | sitelist=" 2n137e 5n137e 8n137e" |
---|
| 191 | sitelist="${sitelist} 0n147e 2n147e 5n147e" |
---|
| 192 | sitelist="${sitelist} 5s156e 2s156e 0n156e 2n156e 5n156e 8n156e" |
---|
| 193 | sitelist="${sitelist} 8s165e 5s165e 2s165e 0n165e 2n165e 5n165e 8n165e" |
---|
| 194 | sitelist="${sitelist} 8s180w 5s180w 2s180w 0n180w 2n180w 5n180w 8n180w" |
---|
| 195 | sitelist="${sitelist} 8s170w 5s170w 2s170w 0n170w 2n170w 5n170w 8n170w" |
---|
| 196 | sitelist="${sitelist} 8s155w 5s155w 2s155w 0n155w 2n155w 5n155w 8n155w" |
---|
| 197 | sitelist="${sitelist} 5s140w 2s140w 0n140w 2n140w 5n140w 9n140w" |
---|
| 198 | sitelist="${sitelist} 8s125w 5s125w 2s125w 0n125w 2n125w 5n125w 8n125w" |
---|
| 199 | sitelist="${sitelist} 8s110w 5s110w 2s110w 0n110w 2n110w 5n110w 8n110w" |
---|
| 200 | sitelist="${sitelist} 8s95w 5s95w 2s95w 0n95w 2n95w 5n95w 8n95w " |
---|
| 201 | # |
---|
| 202 | locref="ftp://ftp.pmel.noaa.gov/cdf/sites/daily" |
---|
| 203 | # |
---|
| 204 | list_url="" |
---|
| 205 | # |
---|
| 206 | # build URL = f(site,var) |
---|
| 207 | for site in ${sitelist} |
---|
| 208 | do |
---|
| 209 | for var in ${varlist} |
---|
| 210 | do |
---|
| 211 | list_url="${list_url} ${locref}/${var}${site}_dy.cdf" |
---|
| 212 | done |
---|
[3] | 213 | done |
---|
[48] | 214 | unset site |
---|
| 215 | unset var |
---|
| 216 | unset varlist |
---|
| 217 | unset sitelist |
---|
| 218 | unset locref |
---|
| 219 | # |
---|
[50] | 220 | # if file is not already in ${PROJECT_ID}, get it |
---|
[48] | 221 | for url in ${list_url} |
---|
| 222 | do |
---|
[50] | 223 | file=${PROJECT_ID}/$(basename ${url}) |
---|
[48] | 224 | if [ ! -f ${file} ] |
---|
| 225 | then |
---|
[50] | 226 | wget --tries=1 --no-verbose -P ${PROJECT_ID} \ |
---|
[48] | 227 | --user=taopmelftp \ |
---|
| 228 | --password=G10b@LCh@Ng3 \ |
---|
| 229 | ${url} >> ${log} 2>&1 |
---|
| 230 | wget_status=${?} |
---|
| 231 | if [ ${wget_status} -ne 0 ] |
---|
| 232 | then |
---|
| 233 | echo "${command} : eee : ${url} not found" >> ${log} 2>&1 |
---|
| 234 | # ++ exit 1 |
---|
| 235 | else |
---|
| 236 | echo "${command} : iii : ${url} found" >> ${log} 2>&1 |
---|
| 237 | fi |
---|
| 238 | unset wget_status |
---|
| 239 | else |
---|
| 240 | echo "iii : ${file} exists" >> ${log} |
---|
| 241 | fi |
---|
| 242 | done |
---|
| 243 | unset file |
---|
| 244 | unset url |
---|
| 245 | unset list_url |
---|
| 246 | # |
---|
| 247 | unset command |
---|
| 248 | unset log |
---|
| 249 | unset hostname |
---|
| 250 | unset usage |
---|
| 251 | # |
---|
| 252 | # end |
---|
| 253 | set |
---|
| 254 | exit 0 |
---|