Subversion Repositories lagranto.ecmwf

Rev

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