Subversion Repositories lagranto.ecmwf

Rev

Rev 5 | Go to most recent revision | Details | 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
25
  module load pgi/9.0-1
26
  module load netcdf/4.1.1-pgf90
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
50
setenv NETCDF_LIB ${NETCDF}/lib/ 
51
setenv NETCDF_INC ${NETCDF}/include/
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
190
${FORTRAN} -c -O -I ${NETCDF_INC} ${lib}.f
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
380
ln -svf ${LAGRANTO}/trace/trace.sh          trace.sh
381
ln -svf ${LAGRANTO}/density/density.sh      density.sh
382
ln -svf ${LAGRANTO}/startf/create_startf.sh startf.sh
383
ln -svf ${LAGRANTO}/lidar/lidar.sh          lidar.sh
384
 
385
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra.ecmwf
386
ln -svf ${LAGRANTO}/startf/create_startf.sh create_startf.ecmwf
387
ln -svf ${LAGRANTO}/select/select.sh        select.ecmwf
388
ln -svf ${LAGRANTO}/trace/trace.sh          trace.ecmwf
389
ln -svf ${LAGRANTO}/density/density.sh      density.ecmwf
390
ln -svf ${LAGRANTO}/startf/create_startf.sh startf.ecmwf
391
ln -svf ${LAGRANTO}/lidar/lidar.sh          lidar.ecmwf
392
 
393
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra
394
ln -svf ${LAGRANTO}/startf/create_startf.sh create_startf
395
ln -svf ${LAGRANTO}/select/select.sh        select
396
ln -svf ${LAGRANTO}/trace/trace.sh          trace
397
ln -svf ${LAGRANTO}/density/density.sh      density
398
ln -svf ${LAGRANTO}/startf/create_startf.sh startf
399
ln -svf ${LAGRANTO}/lidar/lidar.sh          lidar
400
 
401
foreach tool ( $tools )
402
 
403
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool}.sh 
404
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool}.ecmwf
405
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool} 
406
 
407
end
408
 
409
# Set link for create_startf / startf
410
\rm -f ${LAGRANTO}/startf
411
ln -svf ${LAGRANTO}/create_startf ${LAGRANTO}/startf
412
 
413
# Set extra name for <select> to avoid conflict in BASH
414
ln -svf ${LAGRANTO}/select/select.sh        seltra
415
ln -svf ${LAGRANTO}/select/select.sh        seltra.sh
416
ln -svf ${LAGRANTO}/select/select.sh        seltra.ecmwf
417
 
418
endif
419
 
420
 
421
# -----------------------------------------------------------------------------
422
# Synchronise ( development -> operational ) 
423
# -----------------------------------------------------------------------------
424
 
425
if ( "${mode}" == "sync"  ) then
426
 
427
echo
428
echo "-----------------------------------------------------------------"
429
echo "Sync ( development -> operational )"
430
echo "-----------------------------------------------------------------"
431
echo
432
 
433
# Synchronize directories
434
rsync --delete -avz ${path_devel} ${path_sync}
435
 
436
# Set the correct path 
437
setenv LAGRANTO ${path_sync}
438
 
439
# Set the correct links
440
if ( ! -d ${LAGRANTO}/bin ) mkdir ${LAGRANTO}/bin
441
cd ${LAGRANTO}/bin
442
 
443
ln -svf ${LAGRANTO}/bin/lagranto            lagranto.sh
444
ln -svf ${LAGRANTO}/bin/lagranto            lagranto.ecmwf
445
ln -svf ${LAGRANTO}/bin/lagrantohelp        lagrantohelp.sh
446
ln -svf ${LAGRANTO}/bin/lagrantohelp        lagrantohelp.ecmwf
447
 
448
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra.sh
449
ln -svf ${LAGRANTO}/startf/create_startf.sh create_startf.sh
450
ln -svf ${LAGRANTO}/select/select.sh        select.sh
451
ln -svf ${LAGRANTO}/trace/trace.sh          trace.sh
452
ln -svf ${LAGRANTO}/density/density.sh      density.sh
453
ln -svf ${LAGRANTO}/startf/create_startf.sh startf.sh
454
ln -svf ${LAGRANTO}/lidar/lidar.sh          lidar.sh
455
 
456
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra.ecmwf
457
ln -svf ${LAGRANTO}/startf/create_startf.sh create_startf.ecmwf
458
ln -svf ${LAGRANTO}/select/select.sh        select.ecmwf
459
ln -svf ${LAGRANTO}/trace/trace.sh          trace.ecmwf
460
ln -svf ${LAGRANTO}/density/density.sh      density.ecmwf
461
ln -svf ${LAGRANTO}/startf/create_startf.sh startf.ecmwf
462
ln -svf ${LAGRANTO}/lidar/lidar.sh          lidar.ecmwf
463
 
464
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra
465
ln -svf ${LAGRANTO}/startf/create_startf.sh create_startf
466
ln -svf ${LAGRANTO}/select/select.sh        select
467
ln -svf ${LAGRANTO}/trace/trace.sh          trace
468
ln -svf ${LAGRANTO}/density/density.sh      density
469
ln -svf ${LAGRANTO}/startf/create_startf.sh startf
470
ln -svf ${LAGRANTO}/lidar/lidar.sh          lidar
471
 
472
foreach tool ( $tools )
473
 
474
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool}.sh 
475
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool}.ecmwf
476
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool} 
477
 
478
end
479
 
480
# Set all permissions
481
chmod -R og+rx ${path_sync}
482
 
483
# Set link for create_startf / startf
484
ln -s ${LAGRANTO}/create_startf ${LAGRANTO}/startf
485
 
486
endif
487
 
488
# -----------------------------------------------------------------------------
489
# Final tasks
490
# -----------------------------------------------------------------------------
491
 
492
echo
493
echo "-----------------------------------------------------------------"
494
echo "Installation complete"
495
echo "-----------------------------------------------------------------"
496
echo
497
echo "Please set the environmental variable LAGRANTO"
498
echo
499
echo "    setenv LAGRANTO ${LAGRANTO}"
500
echo
501
 
502
 
503
 
504
 
505