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