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