Subversion Repositories lagranto.arpege

Rev

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