[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 | # |
---|
| 33 | # oaflux_ref [shape=diamond,fontname=Courier,label="ftp://ftp.whoi.edu/pub/science/oaflux/data_v3/monthly/turbulence/lh_oaflux_2004.nc.gz"]; |
---|
| 34 | # |
---|
[50] | 35 | # file_oaflux [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/lh_oaflux_2004.nc"]; |
---|
[15] | 36 | # |
---|
| 37 | # get_oaflux [shape=box, |
---|
| 38 | # fontname=Courier, |
---|
| 39 | # color=blue, |
---|
| 40 | # URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/get_oaflux.sh" |
---|
[50] | 41 | # label="${PROJECT}/src/get_oaflux.sh"]; |
---|
[15] | 42 | # get_oaflux [shape=box, |
---|
| 43 | # fontname=Courier, |
---|
| 44 | # color=blue, |
---|
[48] | 45 | # URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/get_oaflux.sh" |
---|
[50] | 46 | # label="${PROJECT}/src/get_oaflux.sh"]; |
---|
[15] | 47 | # |
---|
| 48 | # {oaflux_ref} -> {get_oaflux} -> {file_oaflux} |
---|
| 49 | # |
---|
| 50 | # } |
---|
| 51 | # |
---|
| 52 | # |
---|
| 53 | # EXAMPLES |
---|
| 54 | # ======== |
---|
| 55 | # |
---|
| 56 | # If you are working on LOCEAN machine and you don't have any reference data, |
---|
| 57 | # you just have to run this tool :: |
---|
| 58 | # |
---|
| 59 | # $ get_oaflux.sh |
---|
| 60 | # |
---|
| 61 | # And look at log file with :: |
---|
| 62 | # |
---|
| 63 | # $ tlogd.sh get_oaflux |
---|
| 64 | # |
---|
[50] | 65 | # and of course on files in ${PROJECT_ID}. |
---|
[15] | 66 | # |
---|
| 67 | # TODO |
---|
| 68 | # ==== |
---|
| 69 | # |
---|
[77] | 70 | # get ftp://ftp.whoi.edu/pub/science/oaflux/data_v3/daily/radiation_1985-2007/sw_isccp_yyyy.nc.gz and generate $PROJECT_ID/swr_oafluxgrid_1985_2007.nc somewhere else |
---|
| 71 | # |
---|
[15] | 72 | # SEE ALSO |
---|
| 73 | # ======== |
---|
| 74 | # |
---|
| 75 | # :ref:`guide data OAFLUX <data_in_oaflux>` |
---|
| 76 | # |
---|
[50] | 77 | # :ref:`project_profile.sh` |
---|
[15] | 78 | # |
---|
[33] | 79 | # :ref:`oaflux_mask_30N30S.pro` |
---|
| 80 | # |
---|
[15] | 81 | # EVOLUTIONS |
---|
| 82 | # ========== |
---|
| 83 | # |
---|
[48] | 84 | # - fplod 20110421T125407Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 85 | # |
---|
| 86 | # * typo |
---|
| 87 | # |
---|
[15] | 88 | # - fplod 20101216T152647Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 89 | # |
---|
| 90 | # * creation |
---|
| 91 | # |
---|
| 92 | #- |
---|
| 93 | system=$(uname) |
---|
| 94 | case "${system}" in |
---|
| 95 | AIX|IRIX64) |
---|
| 96 | echo "www : no specific posix checking" |
---|
| 97 | ;; |
---|
| 98 | *) |
---|
| 99 | set -o posix |
---|
| 100 | ;; |
---|
| 101 | esac |
---|
| 102 | unset system |
---|
| 103 | # |
---|
| 104 | LANG=POSIX |
---|
| 105 | # |
---|
| 106 | command=$(basename ${0}) |
---|
| 107 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
| 108 | # |
---|
| 109 | usage=" Usage : ${command}" |
---|
| 110 | # |
---|
| 111 | hostname=$(hostname) |
---|
| 112 | # |
---|
| 113 | # default |
---|
| 114 | # N.A. because no parameters |
---|
| 115 | # |
---|
| 116 | set -u |
---|
| 117 | # |
---|
| 118 | # test if wget available |
---|
| 119 | tool=wget |
---|
| 120 | type ${tool} 1> /dev/null 2>&1 |
---|
| 121 | status=${?} |
---|
| 122 | if [ ${status} -ne 0 ] |
---|
| 123 | then |
---|
| 124 | echo "${command} : eee : tool ${tool} not found" |
---|
| 125 | exit 1 |
---|
| 126 | fi |
---|
| 127 | unset status |
---|
| 128 | unset tool |
---|
| 129 | # |
---|
| 130 | # test if gunzip available |
---|
| 131 | tool=gunzip |
---|
| 132 | type ${tool} 1> /dev/null 2>&1 |
---|
| 133 | status=${?} |
---|
| 134 | if [ ${status} -ne 0 ] |
---|
| 135 | then |
---|
| 136 | echo "${command} : eee : tool ${tool} not found" |
---|
| 137 | exit 1 |
---|
| 138 | fi |
---|
| 139 | unset status |
---|
| 140 | unset tool |
---|
| 141 | # |
---|
[50] | 142 | # check for ${PROJECT_LOG} definition |
---|
| 143 | if [ "${PROJECT_LOG}" = "" ] |
---|
[15] | 144 | then |
---|
[50] | 145 | echo "${command} : eee : \${PROJECT_LOG} not defined" |
---|
[15] | 146 | exit 1 |
---|
| 147 | fi |
---|
| 148 | # |
---|
[50] | 149 | # check for ${PROJECT_LOG} existence |
---|
| 150 | if [ ! -d ${PROJECT_LOG} ] |
---|
[15] | 151 | then |
---|
[50] | 152 | echo "${command} : eee : ${PROJECT_LOG} not found" |
---|
[15] | 153 | exit 1 |
---|
| 154 | fi |
---|
| 155 | # |
---|
[50] | 156 | # check for permission access on PROJECT_LOG |
---|
| 157 | if [ ! -x ${PROJECT_LOG} ] |
---|
[15] | 158 | then |
---|
[50] | 159 | echo "${command} : eee : ${PROJECT_LOG} not reachable" |
---|
[15] | 160 | exit 1 |
---|
| 161 | fi |
---|
| 162 | # |
---|
[50] | 163 | # check for write permission on PROJECT_LOG |
---|
| 164 | if [ ! -w ${PROJECT_LOG} ] |
---|
[15] | 165 | then |
---|
[50] | 166 | echo "${command} : eee : ${PROJECT_LOG} not writable" |
---|
[15] | 167 | exit 1 |
---|
| 168 | fi |
---|
| 169 | # |
---|
[50] | 170 | log=${PROJECT_LOG}/$(basename ${0} .sh).log.${log_date} |
---|
[15] | 171 | echo "[Context]" 1>> ${log} |
---|
| 172 | echo "command=$(basename ${0})" 1>>${log} |
---|
| 173 | echo "hostname=${hostname}" 1>> ${log} |
---|
| 174 | echo "runtime=${log_date}" 1>> ${log} |
---|
| 175 | unset log_date |
---|
| 176 | echo "" 1>> ${log} |
---|
| 177 | # |
---|
| 178 | fileref=lh_oaflux_2004.nc |
---|
| 179 | fileref_gz=${fileref}.gz |
---|
| 180 | locref=ftp://ftp.whoi.edu/pub/science/oaflux/data_v3/monthly/turbulence/ |
---|
[50] | 181 | if [ -f ${PROJECT_ID}/${fileref} ] |
---|
[15] | 182 | then |
---|
[50] | 183 | echo "${command} : iii : ${PROJECT_ID}/${fileref} exist" 1>> ${log} |
---|
[15] | 184 | echo "${command} : iii : nothing done" 1>> ${log} |
---|
| 185 | else |
---|
[50] | 186 | wget --tries=1 --no-verbose -P ${PROJECT_ID} ${locref}/${fileref_gz} 1>> ${log} 2>&1 |
---|
[15] | 187 | wget_status=${?} |
---|
| 188 | if [ ${wget_status} -ne 0 ] |
---|
| 189 | then |
---|
| 190 | echo "${command} : eee : ${locref}/${fileref_gz} not found" >> ${log} 2>&1 |
---|
| 191 | # exit 1 #++ |
---|
| 192 | else |
---|
| 193 | echo "${command} : iii : ${locref}/${fileref_gz} found" >> ${log} 2>&1 |
---|
| 194 | fi |
---|
| 195 | unset wget_status |
---|
| 196 | # |
---|
| 197 | # decompress |
---|
[50] | 198 | gunzip ${PROJECT_ID}${fileref_gz} |
---|
[15] | 199 | gunzip_status=${?} |
---|
| 200 | if [ ${gunzip_status} -ne 0 ] |
---|
| 201 | then |
---|
| 202 | echo "${command} : eee : ${locref}/${fileref_gz} not found" >> ${log} 2>&1 |
---|
| 203 | # exit 1 #++ |
---|
| 204 | else |
---|
| 205 | echo "${command} : iii : ${locref}/${fileref_gz} found" >> ${log} 2>&1 |
---|
| 206 | fi |
---|
| 207 | fi |
---|
| 208 | unset fileref |
---|
| 209 | unset fileref_gz |
---|
| 210 | unset locref |
---|
| 211 | # |
---|
| 212 | unset command |
---|
| 213 | unset log |
---|
| 214 | unset hostname |
---|
| 215 | # |
---|
| 216 | # end |
---|
| 217 | exit 0 |
---|