source: trunk/src/refdataget.sh @ 91

Last change on this file since 91 was 91, checked in by pinsard, 10 years ago

fix thanks to coding rules

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.4 KB
Line 
1#! /bin/sh
2#+
3#
4# .. _refdataget.sh:
5#
6# =============
7# refdataget.sh
8# =============
9#
10# ----------------------
11# get all reference data
12# ----------------------
13#
14# SYNOPSIS
15# ========
16#
17# ``refdataget.sh``
18#
19# DESCRIPTION
20# ===========
21#
22# Put in ${IRCAAM_ID} all the reference data files
23#
24# This includes :
25#
26# - ARPEGE data
27#   4 parameters (rlut_d zg_d pr_d) in 5 simulations experiences
28#   (CtIV CtCl AfNQIVIV AsNQIVIV TrNQIVIV) between 1971 and 2000.
29#
30#   You will need password from authorized people to access to ARPEGE
31#   simulation files.
32#
33# - OLR observation between 1974 and now.
34#
35# If one of these files already exists (same name), it won't be download again
36# to avoid big transfert.
37#
38# It might be usefull to check revision of original data ...
39#
40# EXAMPLES
41# ========
42#
43# If you are working on LOCEAN machine and you don't have any reference data,
44# you just have to run this tool :
45#
46# .. code-block:: bash
47#
48#    refdataget.sh
49#
50# And look at log file with :
51#
52# .. code-block:: bash
53#
54#    tlogd.sh refdataget
55#
56# and of course on files in ${IRCAAM_ID}.
57#
58# CAUTIONS
59# ========
60#
61# how to know if there is enough place before ?
62#
63# SEE ALSO
64# ========
65#
66# :ref:`ircaam_profile.sh`
67#
68# TODO
69# ====
70#
71# ++ les fichiers de benjamin
72#
73# ++ la carte du monde
74#
75# ++ pb avec la saisie du mot de passe
76#
77# ++ et si je travaille sur une machine climserv ?
78#
79# ++ ajouter des options par dataset
80#
81# ++ unset
82#
83# EVOLUTIONS
84# ==========
85#
86# $Id$
87#
88# - fplod 2009-01-08T10:40:55Z aedon.locean-ipsl.upmc.fr (Darwin)
89#
90#   * creation from varamma_ws/src/paper01_pre.sh
91#
92#-
93system=$(uname)
94case "${system}" in
95    AIX|IRIX64)
96        echo " www : no specific posix checking"
97    ;;
98    *)
99        set -o posix
100    ;;
101esac
102unset system
103#
104LANG=POSIX
105#
106command=$(basename ${0})
107log_date=$(date -u +"%Y%m%dT%H%M%SZ")
108#
109usage=" Usage : ${command}"
110#
111hostname=$(hostname)
112#
113set -u
114#
115# check for ${IRCAAM_LOG} definition
116if [ "${IRCAAM_LOG}" = "" ]
117then
118    echo " eee : \${IRCAAM_LOG} not defined"
119    exit 1
120fi
121#
122# check for ${IRCAAM_LOG} existence
123if [ ! -d ${IRCAAM_LOG} ]
124then
125    echo " eee : ${IRCAAM_LOG} not found"
126    exit 1
127fi
128#
129# check for permission access on IRCAAM_LOG
130if [ ! -x ${IRCAAM_LOG} ]
131then
132    echo " eee : ${IRCAAM_LOG} not reachable"
133    exit 1
134fi
135#
136# check for write permission on IRCAAM_LOG
137if [ ! -w ${IRCAAM_LOG} ]
138then
139    echo " eee : ${IRCAAM_LOG} not writable"
140    exit 1
141fi
142#
143log=${IRCAAM_LOG}/$(basename ${0} .sh).log.${log_date}
144echo "[Context]" 1>> ${log}
145echo "command=${command}" 1>> ${log}
146echo "hostname=${hostname}" 1>> ${log}
147echo "runtime=${log_date}" 1>> ${log}
148#
149# check for write permission on IRCAAM_ID
150if [ ! -w ${IRCAAM_ID} ]
151then
152    echo " eee : ${IRCAAM_ID} not writable"
153    exit 1
154fi
155
156# ARPEGE
157list_param="rlut_d zg_d pr_d"
158list_simu="CtIV CtCl AfNQIVIV AsNQIVIV TrNQIVIV"
159year_min=1971
160year_max=2000
161dirrefb="http://www.cnrm.meteo.fr/dods-ensembles/Datasets/IRCAAM/"
162#
163read -s -p "enter ircaam-dods password : " dods_passwd
164#
165for simu in ${list_simu}
166do
167    case ${simu} in
168        CtIV|CtCl|AfNQIVIV)
169            dirref="${dirrefb}/Sim/"
170        ;;
171        AsNQIVIV)
172            dirref="${dirrefb}/Sim_As/"
173        ;;
174        TrNQIVIV)
175            dirref="${dirrefb}/Sim_Tr/"
176        ;;
177        *)
178            echo "eee : wrong \${simu}"
179            exit 1
180        ;;
181    esac
182    dirref="${dirref}/${simu}/"
183    for param in ${list_param}
184    do
185      year_i=${year_min}
186      while [ ${year_i} -le ${year_max} ]
187      do
188          year_c=$(printf "%4.4d" ${year_i}')
189          fileref=${param}.${simu}.${year_c}06-09.nc
190          if  [ -f ${IRCAAM_ID}/${fileref} ]
191          then
192              echo "iii : ${IRCAAM_ID}/${fileref} exist" ${log} 2>&1
193              echo "iii : nothing done" >> ${log} 2>&1
194          else
195              wget --no-verbose --user=ircaam-dods --password=${dods_passwd} \
196              -P ${IRCAAM_ID} \
197              ${dirref}/${fileref} >> ${log} 2>&1
198              # ++ ok ?
199              # ++ si climserv faire ln -s ${dirref}/${fileref} ${IRCAAM_ID}/
200          fi
201          year_i=$(( ${year_i} + 1 ))
202      done
203      unset year_i
204    done
205    unset param
206done
207# OLR
208fileref=olr.day.mean.nc
209dirref=ftp://ftp.climserv.ipsl.polytechnique.fr/noaa-olr/
210if  [ -f ${IRCAAM_ID}/${fileref} ]
211then
212    echo "iii : ${IRCAAM_ID}/${fileref} exist"  >> ${log} 2>&1
213    echo "iii : nothing done" >> ${log} 2>&1
214else
215    wget --no-verbose -P ${IRCAAM_ID} ${dirref}/${fileref} >> ${log}
216   # ++ ok ?
217fi
218unset fileref
219unset dirref
220#
221# end
222set
223exit 0
Note: See TracBrowser for help on using the repository browser.