Subversion Repositories lagranto.um

Rev

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