Subversion Repositories lagranto.20cr

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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