-
Notifications
You must be signed in to change notification settings - Fork 0
/
wget_script.sh
executable file
·125 lines (123 loc) · 4.55 KB
/
wget_script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash -
#title :wget_script.sh
#description :get hadgem vars
#author :CEMAC - Helen
#date :20200228
#version :0.4
#usage :./wget_script.sh
#notes :
#bash_version :4.2.46(2)-release
#============================================================================
#============================================================================
# default vars
rcp=rcp85
ens=r2i1p1
year=2013
# Constant
if [ $rcp == rcp45 ]; then
sixhvdate=20121017
Omonvdate=20120229
ALmonvdate=20111129
lmskvdate=20120215
elif [ $rcp == rcp85 ]; then
sixhvdate=20121019
Omonvdate=20111129
ALmonvdate=20120114
lmskvdate=20120215
else
echo "please look up version dates and place them in code here"
#sixhvdate=
#Omonvdate=
#ALmonvdate=
fi
# Constant for HadGEM2-ES runs
TframeOmon=200512-210012
model=HadGEM2-ES
url=http://esgf-data1.ceda.ac.uk/thredds/fileServer/esg_dataroot/cmip5/output1/MOHC/${model}
print_usage() {
echo "
wget_script.sh
A CEMAC script to download required variables for running WRF from Hadgem
Usage:
.\ wget_script.sh -y -r -e
No options runs a default production configuration:
Today, Viz off, 48 hours.
Options:
-y year
-r rcp
-e ensemble member (r2i1p1)
-h HELP: prints this message!
**
Code my be modified such as altering version dates for alternative experiments
obtained via https://esgf-node.llnl.gov/search/cmip5/
**
version: 0.4 (beta un-released)
------------------------------------------------
"
}
while getopts 'y:r:e:h' flag; do
case "${flag}" in
y) year="${OPTARG}" ;;
r) rsp="${OPTARG}" ;;
e) ens="${OPTARG}" ;;
h) print_usage
exit 1 ;;
*) print_usage
exit 1 ;;
esac
done
# -----------------------------------------------------------------------------
# Calculate vars
# calculate Tframe fro 6 hour files
yearm1=$((year-1))
Tframe6hr=${yearm1}122106-${year}122100
# Calculate
if (($year >= 2006 && $year <= 2030)); then
TframeALmon=200512-203011
elif (($year >= 2031 && $year <= 2055)); then
TframeALmon=203012-205511
elif (($year >= 2056 && $year <= 2080)); then
TframeALmon=205512-208011
elif (($year >= 2080 && $year <= 2105)); then
TframeALmon=208012-210011
fi
if [ ! -e staging ]; then
mkdir staging
fi
if [ ! -e ../${rcp}/${ens} ]; then
mkdir ${rcp}/${ens}
fi
cd staging
wget -s ${url}/${rcp}/6hr/atmos/6hrLev/${ens}/v${sixhvdate}/hus/hus_6hrLev_${model}_${rcp}_${ens}_${Tframe6hr}.nc
wget -s ${url}/${rcp}/6hr/atmos/6hrLev/${ens}/v${sixhvdate}/psl/psl_6hrLev_${model}_${rcp}_${ens}_${Tframe6hr}.nc
wget -s ${url}/${rcp}/6hr/atmos/6hrLev/${ens}/v${sixhvdate}/ps/ps_6hrLev_${model}_${rcp}_${ens}_${Tframe6hr}.nc
wget -s ${url}/${rcp}/6hr/atmos/6hrLev/${ens}/v${sixhvdate}/ta/ta_6hrLev_${model}_${rcp}_${ens}_${Tframe6hr}.nc
wget -s ${url}/${rcp}/6hr/atmos/6hrLev/${ens}/v${sixhvdate}/va/va_6hrLev_${model}_${rcp}_${ens}_${Tframe6hr}.nc
wget -s ${url}/${rcp}/6hr/atmos/6hrLev/${ens}/v${sixhvdate}/ua/ua_6hrLev_${model}_${rcp}_${ens}_${Tframe6hr}.nc
# monthly files only need to be downloaded every 30 years
if [ ! -e tsl_Lmon_${model}_${rcp}_${ens}_${TframeALmon}.nc ]; then
wget -s ${url}/${rcp}/mon/land/Lmon/${ens}/v${ALmonvdate}/tsl/tsl_Lmon_${model}_${rcp}_${ens}_${TframeALmon}.nc
wget -s ${url}/${rcp}/mon/land/Lmon/${ens}/v${ALmonvdate}/mrlsl/mrlsl_Lmon_${model}_${rcp}_${ens}_${TframeALmon}.nc
wget -s ${url}/${rcp}/mon/atmos/Amon/${ens}/v${ALmonvdate}/ts/ts_Amon_${model}_${rcp}_${ens}_${TframeALmon}.nc
wget -s ${url}/${rcp}/mon/atmos/Amon/${ens}/v${ALmonvdate}/zg/zg_Amon_${model}_${rcp}_${ens}_${TframeALmon}.nc
wget -s ${url}/${rcp}/mon/landIce/LImon/${ens}/v${ALmonvdate}/snw/snw_LImon_${model}_${rcp}_${ens}_${TframeALmon}.nc
fi
# ocean files cover whole period
if [ ! -e sic_OImon_${model}_${rcp}_${ens}_${TframeOmon}.nc ]; then
if [ ! -e ../${rcp}/${ens}/sic/sic_OImon_${model}_${rcp}_${ens}_${TframeOmon}.nc ]; then
if [ ! -e ${rcp}/${ens}/sic/ocean_complete.txt ]; then
wget -s ${url}/${rcp}/mon/seaIce/OImon/${ens}/v${Omonvdate}/sic/sic_OImon_${model}_${rcp}_${ens}_${TframeOmon}.nc
wget -s ${url}/${rcp}/mon/ocean/Omon/${ens}/v${Omonvdate}/tos/tos_Omon_${model}_${rcp}_${ens}_${TframeOmon}.nc
fi
fi
fi
if [ ! -e ../sftlf_fx_${model}_${rcp}_r0i0p0.nc ]; then
if [ ! -e ../${rcp}/${ens}/lmask/sftlf_fx_${model}_${rcp}_${ens}_r0i0p0.nc ]; then
wget -s ${url}/${rcp}/fx/atmos/fx/r0i0p0/v${lmskvdate}/sftlf/sftlf_fx_${model}_${rcp}_r0i0p0.nc
if [ ! -e ../${rcp}/${ens}/lmask ]; then
mkdir -p ../${rcp}/${ens}/lmask
fi
mv sftlf_fx_${model}_${rcp}_r0i0p0.nc ../${rcp}/${ens}/lmask/
fi
fi
cd ..