Subversion Repositories lagranto.ecmwf

Rev

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