Subversion Repositories lagranto.ecmwf

Rev

Rev 5 | Rev 11 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 michaesp 1
#!/bin/csh
2
 
3
# -----------------------------------------------------------------------------
4
# Set some general parameters
5
# -----------------------------------------------------------------------------
6
 
7
# Usage
8
if ( $#argv == 0 ) then
9 michaesp 9
  echo "install.sh [lib|core|goodies|links|all|docu|clean|tag] "
3 michaesp 10
  exit 0
11
endif
12
 
13
# Set the mode
14
set mode = $1
15
 
9 michaesp 16
# Set path to SVN repository
17
set svnpath=https://svn.iac.ethz.ch/pub/lagranto.ecmwf/
18
 
3 michaesp 19
# Set paths for development and for synchronisation (operational)
20
set path_devel = "${DYN_TOOLS}//lagranto.ecmwf/"
9 michaesp 21
set path_sync  = "${DYN_TOOLS}/lagranto/"
3 michaesp 22
 
23
# Init Fortran compiler and set netCDF acccordingly
24
setenv FORTRAN pgf90 
25
 
26
# Init netCDF library depending on the Fortran compiler
27
if ( "${FORTRAN}" == "pgf90" ) then
5 michaesp 28
  module load netcdf/4.2.1-pgf90
29
  module list
3 michaesp 30
 
31
else if ( "${FORTRAN}" == "gfortran" ) then
32
  module load gfortran
33
  module load netcdf/4.1.1
34
 
35
else if ( "${FORTRAN}" == "ifort" ) then
36
  module load ifort/10.1.017
37
  module load netcdf/4.1.1-ifort
38
 
39
else
40
  echo "Fortran Compiler ${FORTRAN} not supported... Exit"
41
  exit 1
42
 
43
endif
44
 
45
# -----------------------------------------------------------------------------
9 michaesp 46
# Create a new tag in SVN repository
47
# -----------------------------------------------------------------------------
48
 
49
if ( "${mode}" == "tag" ) then
50
   svn info
51
   if ( "${#argv}" != 2 ) then
52
     echo "Usage: install.csh tag id <id=tag number>"
53
   else
54
     set tagnr = $2
55
   endif
56
   svn copy ${svnpath}/trunk ${svnpath}/tags/${tagnr} -m "Release ${tagnr}"
57
   exit 0
58
endif
59
 
60
# -----------------------------------------------------------------------------
3 michaesp 61
# Set internal parameters and detailed installation mode
62
# -----------------------------------------------------------------------------
63
 
64
# Set LAGRANTO environment variable
65
setenv LAGRANTO ${path_devel}
66
 
67
# Set netCDF paths
5 michaesp 68
setenv NETCDF_LIB `nc-config --flibs`
69
setenv NETCDF_INC `nc-config --fflags`
3 michaesp 70
 
71
# Set list of core programs
72
set core  = "create_startf caltra trace select density lidar"
73
 
74
# Set list of goodies
75
set tools = "changecst changet extract getmima gettidiff getvars list2lsl lsl2list mergetra newtime reformat timeres trainfo difference datelist tracal" 
76
 
77
# Set list of libraries
78
set libs  = "iotra ioinp inter times libcdfio libcdfplus"
79
 
80
# Core programs
81
foreach prog ( $core )
82
   if ( "${prog}" == "${mode}" ) then
83
      set core  = ${prog}
84
      set mode  = "core"
85
   endif
86
end
87
 
88
# Goodies
89
foreach tool ( $tools )
90
   if ( "${tool}" == "${mode}" ) then
91
      set tools = ${tool}
92
      set mode  = "goodies"
93
   endif
94
end
95
 
96
# Libraries
97
foreach lib ( $libs )
98
   if ( "${lib}" == "${mode}" ) then
99
      set libs  = ${lib}
100
      set mode  = "lib"
101
   endif
102
end
103
 
104
# Check that the mode is ok 
105
if ( "${mode}" == "all"     ) goto modeok
106
if ( "${mode}" == "lib"     ) goto modeok
107
if ( "${mode}" == "core"    ) goto modeok
108
if ( "${mode}" == "goodies" ) goto modeok
109
if ( "${mode}" == "links"   ) goto modeok
110
if ( "${mode}" == "clean"   ) goto modeok
111
if ( "${mode}" == "docu"    ) goto modeok
9 michaesp 112
if ( "${mode}" == "sync"    ) goto modeok
3 michaesp 113
echo "Unsupported mode ${mode} ... Stop"
114
exit 1
115
 
116
modeok:
117
 
118
# -----------------------------------------------------------------------------
119
# Make clean 
120
# -----------------------------------------------------------------------------
121
 
122
if ( "${mode}" == "clean" ) then
123
 
124
cd ${LAGRANTO}/
125
 
126
foreach prog ( $core )
127
   \rm -f ${prog}/${prog} ${prog}/${prog}.o
128
end
129
\rm -f trace/calvar.o select/special.o
130
 
131
foreach tool ( $tools )
132
  \rm -f goodies/${tool} goodies/${tool}.o 
133
end
134
\rm -f goodies/*.mod goodies/*.o
135
 
136
\rm lib/*.a lib/*.o
137
 
138
foreach prog ( $core )
139
   \rm -f bin/${prog} bin/${prog}.sh  bin/${prog}.ecmwf
140
end
141
\rm -f bin/seltra bin/seltra.sh bin/seltra.ecmwf
142
foreach tool ( $tools )
143
  \rm -f bin/${tool} bin/${tool}.sh bin/${tool}.ecmwf
144
end
145
\rm -f bin/lagrantohelp.sh bin/lagrantohelp.ecmwf
146
\rm -f bin/startf bin/startf.sh bin/startf.ecmwf
147
\rm -f bin/lagranto.sh bin/lagranto.ecmwf
148
 
149
\rm ${LAGRANTO}/startf
150
 
151
exit 0
152
 
153
endif
154
 
155
# -----------------------------------------------------------------------------
156
# Install reference 
157
# -----------------------------------------------------------------------------
158
 
159
if ( ("${mode}" == "docu") | ("${mode}" == "all" ) ) then
160
 
161
echo "-----------------------------------------------------------------"
162
echo "Installing documentation"
163
echo "-----------------------------------------------------------------"
164
echo
165
 
166
cd ${LAGRANTO}/docu/reference/
167
 
168
\rm -f reference.ps
169
\rm -f reference2.ps
170
groff -man ../man/*.0 > reference2.ps
171
ps2pdf reference2.ps
172
 
173
latex title
174
dvips title
175
ps2pdf title.ps
176
 
177
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=reference.pdf title.pdf reference2.pdf
178
 
179
\rm -f *.aux *.log *.dvi
180
\rm -f title.ps  reference2.ps
181
\rm -f title.pdf reference2.pdf
182
 
183
endif
184
 
185
if ( "${mode}" == "docu" ) exit 0
186
 
187
 
188
 
189
# -----------------------------------------------------------------------------
190
# Install libraries 
191
# -----------------------------------------------------------------------------
192
 
193
if ( ("${mode}" == "lib") | ("${mode}" == "all" ) ) then
194
 
195
echo "-----------------------------------------------------------------"
196
echo "Installing libraries"
197
echo "-----------------------------------------------------------------"
198
echo
199
 
200
# Change to library directory
201
cd ${LAGRANTO}/lib
202
 
203
# Loop over all libraries - compile and make library
204
foreach lib ( $libs )
205
 
206
\rm -f ${lib}.a
207
\rm -f ${lib}.o
208
echo ${FORTRAN} -c -O ${lib}.f
5 michaesp 209
${FORTRAN} -c -O ${NETCDF_INC} ${lib}.f
3 michaesp 210
ar r ${lib}.a ${lib}.o
211
\rm -f ${lib}.l ${lib}.o
212
ranlib ${lib}.a
213
if ( ! -f ${lib}.a ) then
214
  echo "Problem in compiling ${lib} ... Stop"
215
  exit 1
216
endif
217
 
218
end
219
 
220
endif
221
 
222
if ( "${mode}" == "lib" ) exit 0
223
 
224
# -----------------------------------------------------------------------------
225
# Check that libraries are ok
226
# -----------------------------------------------------------------------------
227
 
228
echo
229
echo "-----------------------------------------------------------------"
230
echo "Check that all libraries are available"
231
echo "-----------------------------------------------------------------"
232
echo
233
 
234
# Change to library directory
235
cd ${LAGRANTO}/lib
236
 
237
# Check whether all libraries are available
238
foreach lib ( $libs )
239
 
240
if ( ! -f ${lib}.a ) then
241
  echo "Library ${lib} missing... Stop"
242
  exit 1
243
else
244
  ls -l ${lib}.a    
245
endif
246
 
247
end
248
 
249
# Exit if only libraries shoudl be installed
250
if ( "${mode}" == "lib" ) exit 0
251
 
252
# -----------------------------------------------------------------------------
253
# Compile Lagrango core programs
254
# -----------------------------------------------------------------------------
255
 
256
if ( ("${mode}" == "all" ) | ("${mode}" == "core" ) ) then
257
 
258
echo
259
echo "-----------------------------------------------------------------"
260
echo "Installing Lagranto core programs"
261
echo "-----------------------------------------------------------------"
262
 
263
foreach prog ( $core )
264
 
265
echo
266
echo "----- $prog"
267
echo
268
cd ${LAGRANTO}/${prog}
269
\rm -f ${prog}.o 
270
\rm -f ${prog}
271
if ( "${prog}" == "trace"  ) \rm calvar.o
272
if ( "${prog}" == "select" ) \rm special.o
273
\rm -f ${prog}
274
make -f ${prog}.make
275
if ( ! -f ${prog} ) then
276
  echo "Problem in compiling ${prog} ... Stop"
277
  exit 1
278
endif
279
 
280
end
281
 
282
endif
283
 
284
if ( "${mode}" == "core" ) exit 0
285
 
286
# -----------------------------------------------------------------------------
287
# Check that all Lagranto core programs are available
288
# -----------------------------------------------------------------------------
289
 
290
echo
291
echo "-----------------------------------------------------------------"
292
echo "Check that all Lagranto core programs are available"
293
echo "-----------------------------------------------------------------"
294
echo
295
 
296
foreach prog ( $core )
297
 
298
  cd ${LAGRANTO}/${prog}
299
  if ( ! -f ${prog} ) then
300
    echo "${prog} is missing... Stop"
301
    exit 1
302
  else
303
    ls -l ${prog}    
304
  endif
305
 
306
end
307
 
308
# Exit if only core programs shoudl be installed
309
if ( "${mode}" == "core" ) exit 0
310
 
311
# -----------------------------------------------------------------------------
312
# Compile Lagrango goodies
313
# -----------------------------------------------------------------------------
314
 
315
if ( ("${mode}" == "all" ) | ("${mode}" == "goodies" ) ) then
316
 
317
echo
318
echo "-----------------------------------------------------------------"
319
echo "Installing Lagranto goodies"
320
echo "-----------------------------------------------------------------"
321
 
322
cd ${LAGRANTO}/goodies
323
 
324
foreach tool ( $tools )
325
 
326
echo
327
echo "----- ${tool}"
328
echo
329
\rm -f ${tool}.o
330
\rm -f ${tool}
331
if ( -f ${tool}.make ) then
332
   make -f ${tool}.make
333
else if ( -f ${tool}.install ) then
334
   ./${tool}.install
335
endif
336
 
337
if ( ! -f ${tool} ) then
338
  echo "Problem in compiling ${tool} ... Stop"
339
  exit 1
340
endif
341
 
342
end
343
 
344
endif
345
 
346
if ( "${mode}" == "goodies" ) exit 0
347
 
348
# -----------------------------------------------------------------------------
349
# Check that all Lagranto goodies are available
350
# -----------------------------------------------------------------------------
351
 
352
echo
353
echo "-----------------------------------------------------------------"
354
echo "Check that all Lagranto goodies are available"
355
echo "-----------------------------------------------------------------"
356
echo
357
 
358
cd ${LAGRANTO}/goodies
359
 
360
foreach tool ( $tools )
361
 
362
if ( ! -f ${tool} ) then
363
  echo "${tool} is missing... Stop"
364
  exit 1
365
else
366
  ls -l ${tool} 
367
endif
368
 
369
end
370
 
371
endif
372
 
373
# Exit if only goodies should be installed
374
if ( "${mode}" == "goodies" ) exit 0
375
 
376
# -----------------------------------------------------------------------------
377
# Create links to programs
378
# -----------------------------------------------------------------------------
379
 
380
if ( ("${mode}" == "all" ) | ("${mode}" == "links" )  ) then
381
 
382
echo
383
echo "-----------------------------------------------------------------"
384
echo "Create links in ${LAGRANTO}/bin/"
385
echo "-----------------------------------------------------------------"
386
echo
387
 
388
if ( ! -d ${LAGRANTO}/bin ) mkdir ${LAGRANTO}/bin
389
cd ${LAGRANTO}/bin
390
 
391
ln -svf ${LAGRANTO}/bin/lagranto            lagranto.sh
392
ln -svf ${LAGRANTO}/bin/lagranto            lagranto.ecmwf  
393
ln -svf ${LAGRANTO}/bin/lagrantohelp        lagrantohelp.sh
394
ln -svf ${LAGRANTO}/bin/lagrantohelp        lagrantohelp.ecmwf
395
 
396
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra.sh
397
ln -svf ${LAGRANTO}/startf/create_startf.sh create_startf.sh
398
ln -svf ${LAGRANTO}/select/select.sh        select.sh
5 michaesp 399
ln -svf ${LAGRANTO}/select/select.sh        seltra.sh
3 michaesp 400
ln -svf ${LAGRANTO}/trace/trace.sh          trace.sh
401
ln -svf ${LAGRANTO}/density/density.sh      density.sh
402
ln -svf ${LAGRANTO}/startf/create_startf.sh startf.sh
403
ln -svf ${LAGRANTO}/lidar/lidar.sh          lidar.sh
404
 
405
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra.ecmwf
406
ln -svf ${LAGRANTO}/startf/create_startf.sh create_startf.ecmwf
407
ln -svf ${LAGRANTO}/select/select.sh        select.ecmwf
5 michaesp 408
ln -svf ${LAGRANTO}/select/select.sh        seltra.ecmwf
3 michaesp 409
ln -svf ${LAGRANTO}/trace/trace.sh          trace.ecmwf
410
ln -svf ${LAGRANTO}/density/density.sh      density.ecmwf
411
ln -svf ${LAGRANTO}/startf/create_startf.sh startf.ecmwf
412
ln -svf ${LAGRANTO}/lidar/lidar.sh          lidar.ecmwf
413
 
414
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra
415
ln -svf ${LAGRANTO}/startf/create_startf.sh create_startf
416
ln -svf ${LAGRANTO}/select/select.sh        select
5 michaesp 417
ln -svf ${LAGRANTO}/select/select.sh        seltra
3 michaesp 418
ln -svf ${LAGRANTO}/trace/trace.sh          trace
419
ln -svf ${LAGRANTO}/density/density.sh      density
420
ln -svf ${LAGRANTO}/startf/create_startf.sh startf
421
ln -svf ${LAGRANTO}/lidar/lidar.sh          lidar
422
 
423
foreach tool ( $tools )
424
 
425
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool}.sh 
426
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool}.ecmwf
427
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool} 
428
 
429
end
430
 
431
# Set link for create_startf / startf
432
\rm -f ${LAGRANTO}/startf
433
ln -svf ${LAGRANTO}/create_startf ${LAGRANTO}/startf
434
 
435
# Set extra name for <select> to avoid conflict in BASH
436
ln -svf ${LAGRANTO}/select/select.sh        seltra
437
ln -svf ${LAGRANTO}/select/select.sh        seltra.sh
438
ln -svf ${LAGRANTO}/select/select.sh        seltra.ecmwf
439
 
440
endif
441
 
442
 
443
# -----------------------------------------------------------------------------
444
# Synchronise ( development -> operational ) 
445
# -----------------------------------------------------------------------------
446
 
9 michaesp 447
if ( ("${mode}" == "all" ) | ("${mode}" == "sync" )  ) then
3 michaesp 448
 
449
echo
450
echo "-----------------------------------------------------------------"
9 michaesp 451
echo "Sync ( lagranto.ecmwf -> lagranto )"
3 michaesp 452
echo "-----------------------------------------------------------------"
453
echo
454
 
9 michaesp 455
cd ${path_sync}/bin/
3 michaesp 456
 
9 michaesp 457
ln -svf ${path_devel}/bin/lagranto.sh            lagranto.ecmwf
458
ln -svf ${path_devel}/bin/lagrantohelp.sh        lagrantohelp.ecmwf
3 michaesp 459
 
9 michaesp 460
ln -svf ${path_devel}/caltra/caltra.sh           caltra.ecmwf
461
ln -svf ${path_devel}/startf/create_startf.sh    create_startf.ecmwf
462
ln -svf ${path_devel}/select/select.sh           select.ecmwf
463
ln -svf ${path_devel}/trace/trace.sh             trace.ecmwf
464
ln -svf ${path_devel}/density/density.sh         density.ecmwf
465
ln -svf ${path_devel}/startf/create_startf.sh    startf.ecmwf
466
ln -svf ${path_devel}/lidar/lidar.sh             lidar.ecmwf
467
ln -svf ${path_devel}/lidar/seltra.sh            seltra.ecmwf
3 michaesp 468
 
469
foreach tool ( $tools )
470
 
9 michaesp 471
ln -svf ${path_devel}/goodies/${tool}.sh         ${tool}.ecmwf
3 michaesp 472
 
473
end
474
 
475
# Set all permissions
9 michaesp 476
chmod -R og+rx ${path_sync}/bin/
3 michaesp 477
 
478
endif
479
 
480
# -----------------------------------------------------------------------------
481
# Final tasks
482
# -----------------------------------------------------------------------------
483
 
484
echo
485
echo "-----------------------------------------------------------------"
486
echo "Installation complete"
487
echo "-----------------------------------------------------------------"
488
echo
489
echo "Please set the environmental variable LAGRANTO"
490
echo
491
echo "    setenv LAGRANTO ${LAGRANTO}"
492
echo
493
 
494
 
495
 
496
 
497