-
Notifications
You must be signed in to change notification settings - Fork 5
/
install.csh
executable file
·519 lines (390 loc) · 13.7 KB
/
install.csh
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
#!/bin/csh
# -----------------------------------------------------------------------------
# Set some general parameters
# -----------------------------------------------------------------------------
# Usage
if ( $#argv == 0 ) then
echo "install.sh [lib|core|goodies|links|all|docu|clean|tag] "
exit 0
endif
# Set the mode
set mode = $1
# Set path to SVN repository
set svnpath=https://svn.iac.ethz.ch/pub/lagranto.ecmwf/
# Set paths for development and for synchronisation (operational)
set path_devel = "${DYN_TOOLS}//lagranto.ecmwf/"
set path_sync = "${DYN_TOOLS}/lagranto/"
# Set Fortran compiler
setenv FORTRAN pgf90
# Set netcdf format (ive, cdo)
set ncdf = cdo
# Init netCDF library depending on the Fortran compiler
if ( "${FORTRAN}" == "pgf90" ) then
module load netcdf/4.2.1-pgf90
module list
else if ( "${FORTRAN}" == "gfortran" ) then
module load gfortran
module load netcdf/4.2.1
else if ( "${FORTRAN}" == "ifort" ) then
module load ifort/10.1.017
module load netcdf/4.1.1-ifort
else
echo "Fortran Compiler ${FORTRAN} not supported... Exit"
exit 1
endif
# -----------------------------------------------------------------------------
# Create a new tag in SVN repository
# -----------------------------------------------------------------------------
if ( "${mode}" == "tag" ) then
svn info
if ( "${#argv}" != 2 ) then
echo "Usage: install.csh tag id <id=tag number>"
else
set tagnr = $2
endif
svn copy ${svnpath}/trunk ${svnpath}/tags/${tagnr} -m "Release ${tagnr}"
exit 0
endif
# -----------------------------------------------------------------------------
# Set internal parameters and detailed installation mode
# -----------------------------------------------------------------------------
# Set LAGRANTO environment variable
setenv LAGRANTO ${path_devel}
# Set netCDF paths
setenv NETCDF_LIB `nc-config --flibs`
setenv NETCDF_INC `nc-config --fflags`
# Set list of core programs
set core = "create_startf caltra trace select density lidar"
# Set list of goodies
set tools = "traj2num lsl2rdf changet extract getmima gettidiff getvars list2lsl lsl2list mergetra newtime reformat timeres trainfo difference datelist tracal"
# Set list of libraries
set libs = "iotra ioinp inter times libcdfio libcdfplus"
# Core programs
foreach prog ( $core )
if ( "${prog}" == "${mode}" ) then
set core = ${prog}
set mode = "core"
endif
end
# Goodies
foreach tool ( $tools )
if ( "${tool}" == "${mode}" ) then
set tools = ${tool}
set mode = "goodies"
endif
end
# Libraries
foreach lib ( $libs )
if ( "${lib}" == "${mode}" ) then
set libs = ${lib}
set mode = "lib"
endif
end
# Check that the mode is ok
if ( "${mode}" == "all" ) goto modeok
if ( "${mode}" == "lib" ) goto modeok
if ( "${mode}" == "core" ) goto modeok
if ( "${mode}" == "goodies" ) goto modeok
if ( "${mode}" == "links" ) goto modeok
if ( "${mode}" == "clean" ) goto modeok
if ( "${mode}" == "docu" ) goto modeok
if ( "${mode}" == "sync" ) goto modeok
echo "Unsupported mode ${mode} ... Stop"
exit 1
modeok:
# -----------------------------------------------------------------------------
# Make clean
# -----------------------------------------------------------------------------
if ( "${mode}" == "clean" ) then
cd ${LAGRANTO}/
foreach prog ( $core )
\rm -f ${prog}/${prog} ${prog}/${prog}.o
end
\rm -f trace/calvar.o select/special.o
foreach tool ( $tools )
\rm -f goodies/${tool} goodies/${tool}.o
end
\rm -f goodies/*.mod goodies/*.o
\rm lib/*.a lib/*.o
foreach prog ( $core )
\rm -f bin/${prog} bin/${prog}.sh bin/${prog}.ecmwf
end
\rm -f bin/seltra bin/seltra.sh bin/seltra.ecmwf
foreach tool ( $tools )
\rm -f bin/${tool} bin/${tool}.sh bin/${tool}.ecmwf
end
\rm -f bin/lagrantohelp.sh bin/lagrantohelp.ecmwf
\rm -f bin/startf bin/startf.sh bin/startf.ecmwf
\rm -f bin/lagranto.sh bin/lagranto.ecmwf
\rm ${LAGRANTO}/startf
exit 0
endif
# -----------------------------------------------------------------------------
# Install reference
# -----------------------------------------------------------------------------
if ( ("${mode}" == "docu") | ("${mode}" == "all" ) ) then
echo "Installing documentation"
echo "-----------------------------------------------------------------"
echo
cd ${LAGRANTO}/docu/reference/
\rm -f reference.ps
\rm -f reference2.ps
groff -man ../man/*.0 > reference2.ps
ps2pdf reference2.ps
latex title
dvips title
ps2pdf title.ps
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=reference.pdf title.pdf reference2.pdf
\rm -f *.aux *.log *.dvi
\rm -f title.ps reference2.ps
\rm -f title.pdf reference2.pdf
endif
if ( "${mode}" == "docu" ) exit 0
# -----------------------------------------------------------------------------
# Install libraries
# -----------------------------------------------------------------------------
if ( ("${mode}" == "lib") | ("${mode}" == "all" ) ) then
echo "-----------------------------------------------------------------"
echo "Installing libraries"
echo "-----------------------------------------------------------------"
echo
# Change to library directory
cd ${LAGRANTO}/lib
# Set the correct netCDF interface
echo
if ( "${ncdf}" == "ive" ) then
echo " ioinp_ive.f -> ioinp.f"
\cp ioinp_ive.f ioinp.f
endif
if ( "${ncdf}" == "nc" ) then
echo " ioinp_cdf.f -> ioinp.f"
\cp ioinp_nc.f ioinp.f
endif
if ( "${ncdf}" == "cdo" ) then
echo " ioinp_cdo.f -> ioinp.f"
\cp ioinp_cdo.f ioinp.f
endif
if ( "${ncdf}" == "mch" ) then
echo " ioinp_mch.f -> ioinp.f"
\cp ioinp_mch.f ioinp.f
endif
echo
# Loop over all libraries - compile and make library
foreach lib ( $libs )
\rm -f ${lib}.a
\rm -f ${lib}.o
echo ${FORTRAN} -c -O ${lib}.f
${FORTRAN} -c -O ${NETCDF_INC} ${lib}.f
ar r ${lib}.a ${lib}.o
\rm -f ${lib}.l ${lib}.o
ranlib ${lib}.a
if ( ! -f ${lib}.a ) then
echo "Problem in compiling ${lib} ... Stop"
exit 1
endif
end
endif
if ( "${mode}" == "lib" ) exit 0
# -----------------------------------------------------------------------------
# Check that libraries are ok
# -----------------------------------------------------------------------------
echo
echo "-----------------------------------------------------------------"
echo "Check that all libraries are available"
echo "-----------------------------------------------------------------"
echo
# Change to library directory
cd ${LAGRANTO}/lib
# Check whether all libraries are available
foreach lib ( $libs )
if ( ! -f ${lib}.a ) then
echo "Library ${lib} missing... Stop"
exit 1
else
ls -l ${lib}.a
endif
end
# Exit if only libraries shoudl be installed
if ( "${mode}" == "lib" ) exit 0
# -----------------------------------------------------------------------------
# Compile Lagrango core programs
# -----------------------------------------------------------------------------
if ( ("${mode}" == "all" ) | ("${mode}" == "core" ) ) then
echo
echo "-----------------------------------------------------------------"
echo "Installing Lagranto core programs"
echo "-----------------------------------------------------------------"
foreach prog ( $core )
echo
echo "----- $prog"
echo
cd ${LAGRANTO}/${prog}
\rm -f ${prog}.o
\rm -f ${prog}
if ( "${prog}" == "trace" ) \rm calvar.o
if ( "${prog}" == "select" ) \rm special.o
\rm -f ${prog}
make -f ${prog}.make
if ( ! -f ${prog} ) then
echo "Problem in compiling ${prog} ... Stop"
exit 1
endif
end
endif
if ( "${mode}" == "core" ) exit 0
# -----------------------------------------------------------------------------
# Check that all Lagranto core programs are available
# -----------------------------------------------------------------------------
echo
echo "-----------------------------------------------------------------"
echo "Check that all Lagranto core programs are available"
echo "-----------------------------------------------------------------"
echo
foreach prog ( $core )
cd ${LAGRANTO}/${prog}
if ( ! -f ${prog} ) then
echo "${prog} is missing... Stop"
exit 1
else
ls -l ${prog}
endif
end
# Exit if only core programs shoudl be installed
if ( "${mode}" == "core" ) exit 0
# -----------------------------------------------------------------------------
# Compile Lagrango goodies
# -----------------------------------------------------------------------------
if ( ("${mode}" == "all" ) | ("${mode}" == "goodies" ) ) then
echo
echo "-----------------------------------------------------------------"
echo "Installing Lagranto goodies"
echo "-----------------------------------------------------------------"
cd ${LAGRANTO}/goodies
foreach tool ( $tools )
echo
echo "----- ${tool}"
echo
\rm -f ${tool}.o
\rm -f ${tool}
if ( -f ${tool}.make ) then
make -f ${tool}.make
else if ( -f ${tool}.install ) then
./${tool}.install
endif
if ( ! -f ${tool} ) then
echo "Problem in compiling ${tool} ... Stop"
exit 1
endif
end
endif
if ( "${mode}" == "goodies" ) exit 0
# -----------------------------------------------------------------------------
# Check that all Lagranto goodies are available
# -----------------------------------------------------------------------------
echo
echo "-----------------------------------------------------------------"
echo "Check that all Lagranto goodies are available"
echo "-----------------------------------------------------------------"
echo
cd ${LAGRANTO}/goodies
foreach tool ( $tools )
if ( ! -f ${tool} ) then
echo "${tool} is missing... Stop"
exit 1
else
ls -l ${tool}
endif
end
endif
# Exit if only goodies should be installed
if ( "${mode}" == "goodies" ) exit 0
# -----------------------------------------------------------------------------
# Create links to programs
# -----------------------------------------------------------------------------
if ( ("${mode}" == "all" ) | ("${mode}" == "links" ) ) then
echo
echo "-----------------------------------------------------------------"
echo "Create links in ${LAGRANTO}/bin/"
echo "-----------------------------------------------------------------"
echo
if ( ! -d ${LAGRANTO}/bin ) mkdir ${LAGRANTO}/bin
cd ${LAGRANTO}/bin
ln -svf ${LAGRANTO}/bin/lagranto lagranto.sh
ln -svf ${LAGRANTO}/bin/lagranto lagranto.ecmwf
ln -svf ${LAGRANTO}/bin/lagrantohelp lagrantohelp.sh
ln -svf ${LAGRANTO}/bin/lagrantohelp lagrantohelp.ecmwf
ln -svf ${LAGRANTO}/caltra/caltra.sh caltra.sh
ln -svf ${LAGRANTO}/startf/create_startf.sh create_startf.sh
ln -svf ${LAGRANTO}/select/select.sh select.sh
ln -svf ${LAGRANTO}/select/select.sh seltra.sh
ln -svf ${LAGRANTO}/trace/trace.sh trace.sh
ln -svf ${LAGRANTO}/density/density.sh density.sh
ln -svf ${LAGRANTO}/startf/create_startf.sh startf.sh
ln -svf ${LAGRANTO}/lidar/lidar.sh lidar.sh
ln -svf ${LAGRANTO}/caltra/caltra.sh caltra.ecmwf
ln -svf ${LAGRANTO}/startf/create_startf.sh create_startf.ecmwf
ln -svf ${LAGRANTO}/select/select.sh select.ecmwf
ln -svf ${LAGRANTO}/select/select.sh seltra.ecmwf
ln -svf ${LAGRANTO}/trace/trace.sh trace.ecmwf
ln -svf ${LAGRANTO}/density/density.sh density.ecmwf
ln -svf ${LAGRANTO}/startf/create_startf.sh startf.ecmwf
ln -svf ${LAGRANTO}/lidar/lidar.sh lidar.ecmwf
ln -svf ${LAGRANTO}/caltra/caltra.sh caltra
ln -svf ${LAGRANTO}/startf/create_startf.sh create_startf
ln -svf ${LAGRANTO}/select/select.sh select
ln -svf ${LAGRANTO}/select/select.sh seltra
ln -svf ${LAGRANTO}/trace/trace.sh trace
ln -svf ${LAGRANTO}/density/density.sh density
ln -svf ${LAGRANTO}/startf/create_startf.sh startf
ln -svf ${LAGRANTO}/lidar/lidar.sh lidar
foreach tool ( $tools )
ln -svf ${LAGRANTO}/goodies/${tool}.sh ${tool}.sh
ln -svf ${LAGRANTO}/goodies/${tool}.sh ${tool}.ecmwf
ln -svf ${LAGRANTO}/goodies/${tool}.sh ${tool}
end
# Set link for create_startf / startf
\rm -f ${LAGRANTO}/startf
ln -svf ${LAGRANTO}/create_startf ${LAGRANTO}/startf
# Set extra name for <select> to avoid conflict in BASH
ln -svf ${LAGRANTO}/select/select.sh seltra
ln -svf ${LAGRANTO}/select/select.sh seltra.sh
ln -svf ${LAGRANTO}/select/select.sh seltra.ecmwf
endif
# -----------------------------------------------------------------------------
# Synchronise ( development -> operational )
# -----------------------------------------------------------------------------
if ( ("${mode}" == "all" ) | ("${mode}" == "sync" ) ) then
echo
echo "-----------------------------------------------------------------"
echo "Sync ( lagranto.ecmwf -> lagranto )"
echo "-----------------------------------------------------------------"
echo
cd ${path_sync}/bin/
ln -svf ${path_devel}/bin/lagranto.sh lagranto.ecmwf
ln -svf ${path_devel}/bin/lagrantohelp.sh lagrantohelp.ecmwf
ln -svf ${path_devel}/caltra/caltra.sh caltra.ecmwf
ln -svf ${path_devel}/startf/create_startf.sh create_startf.ecmwf
ln -svf ${path_devel}/select/select.sh select.ecmwf
ln -svf ${path_devel}/trace/trace.sh trace.ecmwf
ln -svf ${path_devel}/density/density.sh density.ecmwf
ln -svf ${path_devel}/startf/create_startf.sh startf.ecmwf
ln -svf ${path_devel}/lidar/lidar.sh lidar.ecmwf
ln -svf ${path_devel}/lidar/seltra.sh seltra.ecmwf
foreach tool ( $tools )
ln -svf ${path_devel}/goodies/${tool}.sh ${tool}.ecmwf
end
# Set all permissions
chmod -R og+rx ${path_sync}/bin/
endif
# -----------------------------------------------------------------------------
# Final tasks
# -----------------------------------------------------------------------------
echo
echo "-----------------------------------------------------------------"
echo "Installation complete"
echo "-----------------------------------------------------------------"
echo
echo "Please set the environmental variable LAGRANTO"
echo
echo " setenv LAGRANTO ${LAGRANTO}"
echo