source: trunk/src/refdataget.sh @ 80

Last change on this file since 80 was 80, checked in by pinsard, 14 years ago

improve environnement definition

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