Subversion Repositories lagranto.ecmwf

Rev

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