Subversion Repositories lagranto.wrf

Rev

Rev 2 | 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
7 michaesp 9
  echo "install.sh [lib|core|goodies|links|all|clean] "
2 michaesp 10
  exit 0
11
endif
12
 
13
# Set the mode
14
set mode = $1
15
 
16
# Set paths for development 
17
set path_devel = "/home/michaesp/project/lagranto.wrf/"
18
 
19
# Init Fortran compiler and set netCDF acccordingly
20
setenv FORTRAN pgf90 
21
 
22
# Init netCDF library depending on the Fortran compiler
23
if ( "${FORTRAN}" == "pgf90" ) then
24
  module load pgi/9.0-1
25
  module load netcdf/4.1.1-pgf90
26
 
27
else if ( "${FORTRAN}" == "gfortran" ) then
28
  module load gfortran
29
  module load netcdf/4.1.1
30
 
31
else if ( "${FORTRAN}" == "ifort" ) then
32
  module load ifort/10.1.017
33
  module load netcdf/4.1.1-ifort
34
 
35
else
36
  echo "Fortran Compiler ${FORTRAN} not supported... Exit"
37
  exit 1
38
 
39
endif
40
 
41
# -----------------------------------------------------------------------------
42
# Set internal parameters and detailed installation mode
43
# -----------------------------------------------------------------------------
44
 
45
# Set LAGRANTO environment variable
46
setenv LAGRANTO ${path_devel}
47
 
48
# Set netCDF paths
49
setenv NETCDF_LIB ${NETCDF}/lib/ 
50
setenv NETCDF_INC ${NETCDF}/include/
51
 
52
# Set list of core programs
53
set core  = "caltra trace select"
54
 
55
# Set list of goodies
56
set tools = "extract gettidiff getvars list2lsl lsl2list mergetra newtime reformat timeres trainfo difference datelist tracal wrfmap" 
57
 
58
# Set list of libraries
59
set libs  = "iotra inter times libcdfio libcdfplus libwrf"
60
 
61
# Core programs
62
foreach prog ( $core )
63
   if ( "${prog}" == "${mode}" ) then
64
      set core  = ${prog}
65
      set mode  = "core"
66
   endif
67
end
68
 
69
# Goodies
70
foreach tool ( $tools )
71
   if ( "${tool}" == "${mode}" ) then
72
      set tools = ${tool}
73
      set mode  = "goodies"
74
   endif
75
end
76
 
77
# Libraries
78
foreach lib ( $libs )
79
   if ( "${lib}" == "${mode}" ) then
80
      set libs  = ${lib}
81
      set mode  = "lib"
82
   endif
83
end
84
 
7 michaesp 85
# -----------------------------------------------------------------------------
86
# Make clean 
87
# -----------------------------------------------------------------------------
2 michaesp 88
 
7 michaesp 89
if ( "${mode}" == "clean" ) then
90
 
91
\rm -f caltra/caltra caltra/caltra.o
92
\rm -f select/select select/select.o select/special.o
93
\rm -f trace/trace   trace/trace.o
94
 
95
foreach tool ( $tools )
96
  \rm -f goodies/${tool} goodies/${tool}.o 
97
end
98
\rm -f goodies/*.mod
99
 
100
\rm lib/*.a lib/*.o
101
 
102
\rm -f bin/caltra bin/caltra.sh
103
\rm -f bin/select bin/select.sh bin/seltra bin/seltra.sh
104
\rm -f bin/trace  bin/trace.sh
105
foreach tool ( $tools )
106
  \rm -f bin/${tool} bin/${tool}.sh 
107
end
108
\rm -f bin/lagrantohelp.sh
109
 
110
exit 0
111
 
112
endif
113
 
2 michaesp 114
# -----------------------------------------------------------------------------
115
# Install libraries 
116
# -----------------------------------------------------------------------------
117
 
118
if ( ("${mode}" == "lib") | ("${mode}" == "all" ) ) then
119
 
120
echo "-----------------------------------------------------------------"
121
echo "Installing libraries"
122
echo "-----------------------------------------------------------------"
123
echo
124
 
125
# Change to library directory
126
cd ${LAGRANTO}/lib
127
 
128
# Loop over all libraries - compile and make library
129
foreach lib ( $libs )
130
 
131
\rm -f ${lib}.a
132
\rm -f ${lib}.o
133
echo ${FORTRAN} -c -O ${lib}.f
134
${FORTRAN} -c -O -I ${NETCDF_INC} ${lib}.f
135
ar r ${lib}.a ${lib}.o
136
\rm -f ${lib}.l ${lib}.o
137
ranlib ${lib}.a
138
if ( ! -f ${lib}.a ) then
139
  echo "Problem in compiling ${lib} ... Stop"
140
  exit 1
141
endif
142
 
143
end
144
 
145
endif
146
 
147
 
148
# -----------------------------------------------------------------------------
149
# Check that libraries are ok
150
# -----------------------------------------------------------------------------
151
 
152
echo
153
echo "-----------------------------------------------------------------"
154
echo "Check that all libraries are available"
155
echo "-----------------------------------------------------------------"
156
echo
157
 
158
# Change to library directory
159
cd ${LAGRANTO}/lib
160
 
161
# Check whether all libraries are available
162
foreach lib ( $libs )
163
 
164
if ( ! -f ${lib}.a ) then
165
  echo "Library ${lib} missing... Stop"
166
  exit 1
167
else
168
  ls -l ${lib}.a    
169
endif
170
 
171
end
172
 
173
# Exit if only libraries shoudl be installed
174
if ( "${mode}" == "lib" ) exit 0
175
 
176
# -----------------------------------------------------------------------------
177
# Compile Lagrango core programs
178
# -----------------------------------------------------------------------------
179
 
180
if ( ("${mode}" == "all" ) | ("${mode}" == "core" ) ) then
181
 
182
echo
183
echo "-----------------------------------------------------------------"
184
echo "Installing Lagranto core programs"
185
echo "-----------------------------------------------------------------"
186
 
187
foreach prog ( $core )
188
 
189
echo
190
echo "----- $prog"
191
echo
192
cd ${LAGRANTO}/${prog}
193
\rm -f ${prog}.o 
194
\rm -f ${prog}
195
if ( "${prog}" == "select" ) \rm special.o
196
\rm -f ${prog}
197
make -f ${prog}.make
198
if ( ! -f ${prog} ) then
199
  echo "Problem in compiling ${prog} ... Stop"
200
  exit 1
201
endif
202
 
203
end
204
 
205
endif
206
 
207
# -----------------------------------------------------------------------------
208
# Check that all Lagranto core programs are available
209
# -----------------------------------------------------------------------------
210
 
211
echo
212
echo "-----------------------------------------------------------------"
213
echo "Check that all Lagranto core programs are available"
214
echo "-----------------------------------------------------------------"
215
echo
216
 
217
foreach prog ( $core )
218
 
219
  cd ${LAGRANTO}/${prog}
220
  if ( ! -f ${prog} ) then
221
    echo "${prog} is missing... Stop"
222
    exit 1
223
  else
224
    ls -l ${prog}    
225
  endif
226
 
227
end
228
 
229
# Exit if only core programs shoudl be installed
230
if ( "${mode}" == "core" ) exit 0
231
 
232
# -----------------------------------------------------------------------------
233
# Compile Lagrango goodies
234
# -----------------------------------------------------------------------------
235
 
236
if ( ("${mode}" == "all" ) | ("${mode}" == "goodies" ) ) then
237
 
238
echo
239
echo "-----------------------------------------------------------------"
240
echo "Installing Lagranto goodies"
241
echo "-----------------------------------------------------------------"
242
 
243
cd ${LAGRANTO}/goodies
244
 
245
foreach tool ( $tools )
246
 
247
echo
248
echo "----- ${tool}"
249
echo
250
\rm -f ${tool}.o
251
\rm -f ${tool}
252
if ( -f ${tool}.make ) then
253
   make -f ${tool}.make
254
else if ( -f ${tool}.install ) then
255
   ./${tool}.install
256
endif
257
 
258
if ( ! -f ${tool} ) then
259
  echo "Problem in compiling ${tool} ... Stop"
260
  exit 1
261
endif
262
 
263
end
264
 
265
endif
266
 
267
# -----------------------------------------------------------------------------
268
# Check that all Lagranto goodies are available
269
# -----------------------------------------------------------------------------
270
 
271
echo
272
echo "-----------------------------------------------------------------"
273
echo "Check that all Lagranto goodies are available"
274
echo "-----------------------------------------------------------------"
275
echo
276
 
277
cd ${LAGRANTO}/goodies
278
 
279
foreach tool ( $tools )
280
 
281
if ( ! -f ${tool} ) then
282
  echo "${tool} is missing... Stop"
283
  exit 1
284
else
285
  ls -l ${tool} 
286
endif
287
 
288
end
289
 
290
endif
291
 
292
# Exit if only goodies should be installed
293
if ( "${mode}" == "goodies" ) exit 0
294
 
295
# -----------------------------------------------------------------------------
296
# Create links to programs
297
# -----------------------------------------------------------------------------
298
 
299
if ( ("${mode}" == "all" ) | ("${mode}" == "links" )  ) then
300
 
301
echo
302
echo "-----------------------------------------------------------------"
303
echo "Create links in ${LAGRANTO}/bin/"
304
echo "-----------------------------------------------------------------"
305
echo
306
 
307
if ( ! -d ${LAGRANTO}/bin ) mkdir ${LAGRANTO}/bin
308
cd ${LAGRANTO}/bin
309
 
310
ln -svf ${LAGRANTO}/bin/lagrantohelp        lagrantohelp.sh
311
 
312
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra.sh
313
ln -svf ${LAGRANTO}/select/select.sh        select.sh
314
ln -svf ${LAGRANTO}/trace/trace.sh          trace.sh
315
 
316
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra
317
ln -svf ${LAGRANTO}/select/select.sh        select
318
ln -svf ${LAGRANTO}/trace/trace.sh          trace
319
 
320
foreach tool ( $tools )
321
 
322
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool}.sh 
323
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool} 
324
 
325
end
326
 
327
# Set extra name for <select> to avoid conflict in BASH
328
ln -svf ${LAGRANTO}/select/select.sh        seltra
329
ln -svf ${LAGRANTO}/select/select.sh        seltra.sh
330
 
331
endif
332
 
333
# -----------------------------------------------------------------------------
334
# Final tasks
335
# -----------------------------------------------------------------------------
336
 
337
echo
338
echo "-----------------------------------------------------------------"
339
echo "Installation complete"
340
echo "-----------------------------------------------------------------"
341
echo
342
echo "Please set the environmental variable LAGRANTO"
343
echo
344
echo "    setenv LAGRANTO ${LAGRANTO}"
345
echo
346
 
347
 
348
 
349
 
350