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