-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSingularity.jupyter3rttov
276 lines (256 loc) · 7.83 KB
/
Singularity.jupyter3rttov
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
BootStrap: localimage
From: jupyter3.sif
# Bootstrap: shub
# From: MBlaschek/singularity-jupyter:jupyter3
%help
Container Centos 6.10 (docker)
Jupyter Notebook/Lab Server
Options:
--NotebookApp.token='super-secret' Token when not using a password
--ip=0.0.0.0 port forwarding from VirtualBox
--NotebookApp.base_url='/ipython/' Directory path
--port=???? Server port
Create Notebook Password (HOME/.jupyter/jupyter_notebook_config.json):
jupyter notebook password
Check Jupyter paths:
jupyter --paths
Anaconda Python 3 (Xarray, cfgrib, eccodes)
Eccodes and CFgrib are Software from ECMWF
Run RTTOV 12.3 inside a container
Download Rttov from https://www.nwpsaf.eu/site/software/rttov/download/#Software
into rttov directory (local)
RTTOV apps:
rthelp [execute] Creates a rtdoc directory and copies Documentation there.
rtcoef [execute] Download RTTOV coeficient files (interactive)
atlas [execute] Download some Emissivity atlas data and BRDF atlas data
rttest [options] Run RTTOV test suite (reuqires coefficient files), options: fwd, hires, solar, ...
%setup
mkdir -p ${SINGULARITY_ROOTFS}/rttov
mkdir -p ${SINGULARITY_ROOTFS}/rtcoef
mkdir -p ${SINGULARITY_ROOTFS}/rtdoc
%files
# DOC
rttov/rttov-wrapper-python.pdf /rtdoc/RTTOV_Python_wrapper.pdf
rttov/users_guide_rttov12_v1.3.pdf /rtdoc/RTTOV_User_guide_v12_v1.3.pdf
# SRC
# RTTOV Source is not available like this
rttov/rttov123.tar.gz /rttov/rttov123.tar.gz
rttov/Makefile.local /rttov/Makefile.local
rttov/gfortran-anaconda /rttov/gfortran-anaconda
run.sh /usr/bin
%apprun rthelp
echo "RTTOV User guide and Python wrapper"
echo "Supply execute as Argument to copy to ./rtdoc"
echo "$@" | grep execute > /dev/null
if [ $? -eq 0 ]; then
mkdir -vp ./rtdoc
cp -ruv /rtdoc/* ./rtdoc/
fi
%apprun rtcoef
echo "Download RTTOV coefficient files to your host"
[ -z "$SINGULARITY_BIND" ] && echo -e "Bind /rtcoef to the container (RW) \n BASH ENV e.g.: export SINGULARITY_BIND=\"${PWD}/rtcoef:/rtcoef\""
echo "Supply execute as argument to run rttov_coef_download.sh"
echo "$@" | grep execute > /dev/null
if [ $? -eq 0 ]; then
mkdir -vp ./rtcoef
cp -nruv /rttov/rtcoef_backup/* ./rtcoef
cd ./rtcoef
# comment out directory check
sed -i '159,174 {s/^/#/}' rttov_coef_download.sh
exec ./rttov_coef_download.sh
fi
%apprun atlas
echo "Download Emissivity/ BRDF Atlas data"
echo "Goto: https://www.nwpsaf.eu/site/software/rttov/download/ and Download Emis data"
echo "Here only: UW IR atlas data and BRDF atlas data are downloaded"
[ -z "$SINGULARITY_BIND" ] && echo -e "Bind /emis_data to the container (RW) \n BASH ENV e.g.: export SINGULARITY_BIND=\"${PWD}/emis_data:/emis_data\""
echo "Supply execute as argument to run rttov_coef_download.sh"
echo "$@" | grep execute > /dev/null
if [ $? -eq 0 ]; then
if [ ! -d /emis_data ]; then
mkdir -f /emis_data
fi
cd /emis_data
wget https://www.nwpsaf.eu/downloads/emis_data/uw_ir_emis_atlas_hdf5.tar
tar xvf *.tar
wget https://nwp-saf.eumetsat.int/downloads/emis_data/telsem2_mw_atlas.tar.bz2
# wget https://www.nwpsaf.eu/downloads/emis_data/telsem2_mw_atlas.tbz
tar xjvf *.bz2
if [ ! -d /brdf_data ]; then
mkdir -f /brdf_data
fi
cd /brdf_data
wget https://www.nwpsaf.eu/downloads/brdf_data/cms_brdf_atlas_hdf5.tar
tar xvf *.tar
fi
%apprun rttest
echo "Running the test suite"
cat <<EOF
Options:
Default (no options) runs test_rttov12.sh
fwd : forward model
hires : hires IR sounders
solar : visible/near-IR solar
multi : multiple instruments together
pc : principal components
htfrtc : HTFRTC
EOF
[ -z "$SINGULARITY_BIND" ] && echo -e "Bind /rtcoef to the container \n e.g.: export SINGULARITY_BIND=\"${PWD}/rtcoef:/rtcoef\""
[ -z "$SINGULARITY_BIND" ] || echo "Found Bind: $SINGULARITY_BIND"
#
# Make Test directory
# /tmp/rttest
# /tmp/rttest/rttov_test
# /tmp/rttest/rtcoef_rttov??
#
mkdir -p /tmp/rttest
cd /tmp/rttest
#
# Copy tests
#
cp -urf /rttov/rttov_test . && echo "Tests copied to /tmp/rttest"
# Link Coefficients
ln -fvs /rtcoef rtcoef_rttov${RTTOV_VERSION} && echo "Coefficients linked"
ln -fvs /emis_data . && echo "Emis Atlas linked"
ln -fvs /brdf_data . && echo "BDRF Atlas linked"
cd rttov_test
echo
echo "#####################################################"
echo "Testting: "
echo "$@" | grep fwd > /dev/null
if [ $? -eq 0 ]; then
./test_fwd.sh ARCH=gfortran-anaconda BIN=../../usr/local/bin
fi
echo "$@" | grep hires > /dev/null
if [ $? -eq 0 ]; then
./test_rttov12_hires.sh ARCH=gfortran-anaconda BIN=../../usr/local/bin
fi
echo "$@" | grep solar > /dev/null
if [ $? -eq 0 ]; then
./test_solar.sh ARCH=gfortran-anaconda BIN=../../usr/local/bin
fi
echo "$@" | grep multi > /dev/null
if [ $? -eq 0 ]; then
./test_multi_instrument.sh ARCH=gfortran-anaconda BIN=../../usr/local/bin
fi
echo "$@" | grep pc > /dev/null
if [ $? -eq 0 ]; then
./test_pc.sh ARCH=gfortran-anaconda BIN=../../usr/local/bin
fi
if [ $# -eq 0 ]; then
./test_rttov12.sh ARCH=gfortran-anaconda BIN=../../usr/local/bin
fi
echo "rttest used /tmp/rttest"
echo "Finished"
%runscript
# mkdir -p $JUPYTER_RUNTIME_DIR
# mkdir -p $JUPYTER_DATA_DIR
# mkdir -p $JUPYTERLAB_DIR
exec /usr/bin/run.sh "$@"
%post
# Additonal
yum check-update && yum -y update
# gfortran
yum groupinstall -y "Development Tools"
yum install -y cmake doxygen graphviz chrpath
# install gfortran from anaconda
/opt/conda/bin/conda install gfortran_linux-64 gxx_linux-64 sphinx -y
# conda install libgfortran -y
# need netcdf.mod
/opt/conda/bin/conda install -c conda-forge netcdf-fortran -y
# Clean
yum clean all
# required for CMAKE
export PATH=/opt/conda/bin:$PATH
export LD_LIBRARY_PATH=/opt/conda/lib:$LD_LIBRARY_PATH
export RTTOV_VERSION=12
#
# Compile
#
cd /rttov
if [ ! -e rttov123.tar.gz ]; then
echo "Error, Download RTTOV https://www.nwpsaf.eu/site/software/rttov/download/#Software"
echo "Save into rttov/ directory"
exit 1
# wget ftp://srvx1.img.univie.ac.at/pub/upload/mblaschek/rttov123.tar.gz
fi
tar -xzf rttov*.tar.gz
#
# Potentiall add bug fixes tar's here end overwrite
#
if false; then
echo "No Bug fixes yet"
fi
#
# Copy Makefile.local (HDF, Netcdf libs from Conda)
#
mv Makefile.local ./build
mv gfortran-anaconda ./build/arch
#
# Compile using conda gfortran + hdf, netcdf, f2py
#
cd src/
../build/Makefile.PL RTTOV_HDF=1 RTTOV_F2PY=1 RTTOV_USER_LAPACK=0
make ARCH=gfortran-anaconda INSTALLDIR=../usr/local
#
# Backup std coef-files and make links
# Host can bind coef-files to container (/rtcoef)
#
cd ..
mv rtcoef_rttov${RTTOV_VERSION} rtcoef_backup
rm -rf rtcoef_rttov*
ln -s /rtcoef/ rtcoef_rttov${RTTOV_VERSION}
cp -rfv rtcoef_backup/* /rtcoef
# emis
mkdir /emis_data
rm -rf emis_data/
ln -s /emis_data/ emis_data
mkdir /brdf_data
rm -rf brdf_data/
ln -s /brdf_data brdf_data
#
# Fix links of F2py libs
#
cd wrapper
ln -sf /usr/local/lib/rttov_wrapper_f2py.so .
cd ../gui
ln -sf /usr/local/lib/rttov_gui_f2py.so .
cd ..
#
# Python Wrapper
#
cd wrapper
#
# make library accessable from python
#
echo "/rttov/wrapper" > /opt/conda/lib/python3.7/site-packages/rttov.pth
#
# Documentation of Python Interface
#
doxygen doxygen_config_wrapper
mv doxygen_doc_wrapper/html /rtdoc/wrapper
cd pyrttov_doc
make html
mv _build/html /rtdoc/pyrttov
cd ..
mkdir -p /rtdoc/pyexamples
cp *.py /rtdoc/pyexamples/
cd ..
mv *.pdf /rtdoc
# Clean
/opt/conda/bin/conda clean -a -y
%environment
# important part otherwise the server will try to access /run/user and fail
export JUPYTER_RUNTIME_DIR=$PWD/.runtime
# Make sure we use container kernels
export JUPYTER_DATA_DIR=$PWD/.kernels
# Development
export JUPYTERLAB_DIR=$PWD/.lab
#
export PATH=/opt/conda/bin:$PATH
export LD_LIBRARY_PATH=/opt/conda/lib:/usr/local/lib:$LD_LIBRARY_PATH
# RTTOV Options
export RTTOV_VERSION=12
export OMP_STACKSIZE=1000M
export RTTOV_DIR=/rttov
export RTTOV_COEF=/rtcoef