Subversion Repositories lagranto.ecmwf

Rev

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