Subversion Repositories lagranto.wrf

Rev

Rev 11 | Rev 15 | Go to most recent revision | 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
24
setenv FORTRAN pgf90 
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
32
  module load netcdf/4.1.1
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
71
set core  = "caltra trace select"
72
 
73
# Set list of goodies
74
set tools = "extract gettidiff getvars list2lsl lsl2list mergetra newtime reformat timeres trainfo difference datelist tracal wrfmap" 
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
 
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
 
113
foreach tool ( $tools )
114
  \rm -f goodies/${tool} goodies/${tool}.o 
115
end
116
\rm -f goodies/*.mod
117
 
118
\rm lib/*.a lib/*.o
119
 
120
\rm -f bin/caltra bin/caltra.sh
121
\rm -f bin/select bin/select.sh bin/seltra bin/seltra.sh
122
\rm -f bin/trace  bin/trace.sh
123
foreach tool ( $tools )
124
  \rm -f bin/${tool} bin/${tool}.sh 
125
end
126
\rm -f bin/lagrantohelp.sh
127
 
128
exit 0
129
 
130
endif
131
 
2 michaesp 132
# -----------------------------------------------------------------------------
133
# Install libraries 
134
# -----------------------------------------------------------------------------
135
 
136
if ( ("${mode}" == "lib") | ("${mode}" == "all" ) ) then
137
 
138
echo "-----------------------------------------------------------------"
139
echo "Installing libraries"
140
echo "-----------------------------------------------------------------"
141
echo
142
 
143
# Change to library directory
144
cd ${LAGRANTO}/lib
145
 
146
# Loop over all libraries - compile and make library
147
foreach lib ( $libs )
148
 
149
\rm -f ${lib}.a
150
\rm -f ${lib}.o
151
echo ${FORTRAN} -c -O ${lib}.f
11 michaesp 152
${FORTRAN} -c -O ${NETCDF_INC} ${lib}.f
2 michaesp 153
ar r ${lib}.a ${lib}.o
154
\rm -f ${lib}.l ${lib}.o
155
ranlib ${lib}.a
156
if ( ! -f ${lib}.a ) then
157
  echo "Problem in compiling ${lib} ... Stop"
158
  exit 1
159
endif
160
 
161
end
162
 
163
endif
164
 
165
 
166
# -----------------------------------------------------------------------------
167
# Check that libraries are ok
168
# -----------------------------------------------------------------------------
169
 
170
echo
171
echo "-----------------------------------------------------------------"
172
echo "Check that all libraries are available"
173
echo "-----------------------------------------------------------------"
174
echo
175
 
176
# Change to library directory
177
cd ${LAGRANTO}/lib
178
 
179
# Check whether all libraries are available
180
foreach lib ( $libs )
181
 
182
if ( ! -f ${lib}.a ) then
183
  echo "Library ${lib} missing... Stop"
184
  exit 1
185
else
186
  ls -l ${lib}.a    
187
endif
188
 
189
end
190
 
191
# Exit if only libraries shoudl be installed
192
if ( "${mode}" == "lib" ) exit 0
193
 
194
# -----------------------------------------------------------------------------
195
# Compile Lagrango core programs
196
# -----------------------------------------------------------------------------
197
 
198
if ( ("${mode}" == "all" ) | ("${mode}" == "core" ) ) then
199
 
200
echo
201
echo "-----------------------------------------------------------------"
202
echo "Installing Lagranto core programs"
203
echo "-----------------------------------------------------------------"
204
 
205
foreach prog ( $core )
206
 
207
echo
208
echo "----- $prog"
209
echo
210
cd ${LAGRANTO}/${prog}
211
\rm -f ${prog}.o 
212
\rm -f ${prog}
213
if ( "${prog}" == "select" ) \rm special.o
214
\rm -f ${prog}
215
make -f ${prog}.make
216
if ( ! -f ${prog} ) then
217
  echo "Problem in compiling ${prog} ... Stop"
218
  exit 1
219
endif
220
 
221
end
222
 
223
endif
224
 
225
# -----------------------------------------------------------------------------
226
# Check that all Lagranto core programs are available
227
# -----------------------------------------------------------------------------
228
 
229
echo
230
echo "-----------------------------------------------------------------"
231
echo "Check that all Lagranto core programs are available"
232
echo "-----------------------------------------------------------------"
233
echo
234
 
235
foreach prog ( $core )
236
 
237
  cd ${LAGRANTO}/${prog}
238
  if ( ! -f ${prog} ) then
239
    echo "${prog} is missing... Stop"
240
    exit 1
241
  else
242
    ls -l ${prog}    
243
  endif
244
 
245
end
246
 
247
# Exit if only core programs shoudl be installed
248
if ( "${mode}" == "core" ) exit 0
249
 
250
# -----------------------------------------------------------------------------
251
# Compile Lagrango goodies
252
# -----------------------------------------------------------------------------
253
 
254
if ( ("${mode}" == "all" ) | ("${mode}" == "goodies" ) ) then
255
 
256
echo
257
echo "-----------------------------------------------------------------"
258
echo "Installing Lagranto goodies"
259
echo "-----------------------------------------------------------------"
260
 
261
cd ${LAGRANTO}/goodies
262
 
263
foreach tool ( $tools )
264
 
265
echo
266
echo "----- ${tool}"
267
echo
268
\rm -f ${tool}.o
269
\rm -f ${tool}
270
if ( -f ${tool}.make ) then
271
   make -f ${tool}.make
272
else if ( -f ${tool}.install ) then
273
   ./${tool}.install
274
endif
275
 
276
if ( ! -f ${tool} ) then
277
  echo "Problem in compiling ${tool} ... Stop"
278
  exit 1
279
endif
280
 
281
end
282
 
283
endif
284
 
285
# -----------------------------------------------------------------------------
286
# Check that all Lagranto goodies are available
287
# -----------------------------------------------------------------------------
288
 
289
echo
290
echo "-----------------------------------------------------------------"
291
echo "Check that all Lagranto goodies are available"
292
echo "-----------------------------------------------------------------"
293
echo
294
 
295
cd ${LAGRANTO}/goodies
296
 
297
foreach tool ( $tools )
298
 
299
if ( ! -f ${tool} ) then
300
  echo "${tool} is missing... Stop"
301
  exit 1
302
else
303
  ls -l ${tool} 
304
endif
305
 
306
end
307
 
308
endif
309
 
310
# Exit if only goodies should be installed
311
if ( "${mode}" == "goodies" ) exit 0
312
 
313
# -----------------------------------------------------------------------------
314
# Create links to programs
315
# -----------------------------------------------------------------------------
316
 
317
if ( ("${mode}" == "all" ) | ("${mode}" == "links" )  ) then
318
 
319
echo
320
echo "-----------------------------------------------------------------"
321
echo "Create links in ${LAGRANTO}/bin/"
322
echo "-----------------------------------------------------------------"
323
echo
324
 
325
if ( ! -d ${LAGRANTO}/bin ) mkdir ${LAGRANTO}/bin
326
cd ${LAGRANTO}/bin
327
 
328
ln -svf ${LAGRANTO}/bin/lagrantohelp        lagrantohelp.sh
11 michaesp 329
ln -svf ${LAGRANTO}/bin/lagrantohelp        lagrantohelp.wrf
2 michaesp 330
 
331
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra.sh
332
ln -svf ${LAGRANTO}/select/select.sh        select.sh
333
ln -svf ${LAGRANTO}/trace/trace.sh          trace.sh
334
 
335
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra
336
ln -svf ${LAGRANTO}/select/select.sh        select
337
ln -svf ${LAGRANTO}/trace/trace.sh          trace
338
 
11 michaesp 339
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra.wrf
340
ln -svf ${LAGRANTO}/select/select.sh        select.wrf
341
ln -svf ${LAGRANTO}/trace/trace.sh          trace.wrf
342
 
343
 
2 michaesp 344
foreach tool ( $tools )
345
 
346
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool}.sh 
347
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool} 
11 michaesp 348
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool}.wrf
2 michaesp 349
 
350
end
351
 
352
# Set extra name for <select> to avoid conflict in BASH
353
ln -svf ${LAGRANTO}/select/select.sh        seltra
354
ln -svf ${LAGRANTO}/select/select.sh        seltra.sh
11 michaesp 355
ln -svf ${LAGRANTO}/select/select.sh        seltra.wrf
2 michaesp 356
 
357
endif
358
 
359
# -----------------------------------------------------------------------------
11 michaesp 360
# Synchronise ( development -> operational ) 
361
# -----------------------------------------------------------------------------
362
 
363
if ( ("${mode}" == "all" ) | ("${mode}" == "sync" )  ) then
364
 
365
echo
366
echo "-----------------------------------------------------------------"
367
echo "Sync ( lagranto.wrf -> lagranto )"
368
echo "-----------------------------------------------------------------"
369
echo
370
 
371
cd ${path_sync}/bin/
372
 
373
ln -svf ${path_devel}/bin/lagrantohelp.sh        lagrantohelp.wrf
374
 
375
ln -svf ${path_devel}/caltra/caltra.sh           caltra.wrf
376
ln -svf ${path_devel}/select/select.sh           select.wrf
377
ln -svf ${path_devel}/trace/trace.sh             trace.wrf
378
ln -svf ${path_devel}/lidar/seltra.sh            seltra.wrf
379
 
380
foreach tool ( $tools )
381
 
382
ln -svf ${path_devel}/goodies/${tool}.sh      ${tool}.wrf
383
 
384
end
385
 
386
# Set all permissions
387
chmod -R og+rx ${path_sync}/bin/
388
 
389
endif
390
 
391
 
392
# -----------------------------------------------------------------------------
2 michaesp 393
# Final tasks
394
# -----------------------------------------------------------------------------
395
 
396
echo
397
echo "-----------------------------------------------------------------"
398
echo "Installation complete"
399
echo "-----------------------------------------------------------------"
400
echo
401
echo "Please set the environmental variable LAGRANTO"
402
echo
403
echo "    setenv LAGRANTO ${LAGRANTO}"
404
echo
405
 
406
 
407
 
408
 
409