Subversion Repositories lagranto.wrf

Rev

Rev 15 | Details | Compare with Previous | Last modification | View Log | RSS feed

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