Subversion Repositories lagranto.wrf

Rev

Rev 7 | Go to most recent revision | Details | 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
9
  echo "install.sh [lib|core|goodies|links|all] "
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
 
85
 
86
# -----------------------------------------------------------------------------
87
# Install libraries 
88
# -----------------------------------------------------------------------------
89
 
90
if ( ("${mode}" == "lib") | ("${mode}" == "all" ) ) then
91
 
92
echo "-----------------------------------------------------------------"
93
echo "Installing libraries"
94
echo "-----------------------------------------------------------------"
95
echo
96
 
97
# Change to library directory
98
cd ${LAGRANTO}/lib
99
 
100
# Loop over all libraries - compile and make library
101
foreach lib ( $libs )
102
 
103
\rm -f ${lib}.a
104
\rm -f ${lib}.o
105
echo ${FORTRAN} -c -O ${lib}.f
106
${FORTRAN} -c -O -I ${NETCDF_INC} ${lib}.f
107
ar r ${lib}.a ${lib}.o
108
\rm -f ${lib}.l ${lib}.o
109
ranlib ${lib}.a
110
if ( ! -f ${lib}.a ) then
111
  echo "Problem in compiling ${lib} ... Stop"
112
  exit 1
113
endif
114
 
115
end
116
 
117
endif
118
 
119
 
120
# -----------------------------------------------------------------------------
121
# Check that libraries are ok
122
# -----------------------------------------------------------------------------
123
 
124
echo
125
echo "-----------------------------------------------------------------"
126
echo "Check that all libraries are available"
127
echo "-----------------------------------------------------------------"
128
echo
129
 
130
# Change to library directory
131
cd ${LAGRANTO}/lib
132
 
133
# Check whether all libraries are available
134
foreach lib ( $libs )
135
 
136
if ( ! -f ${lib}.a ) then
137
  echo "Library ${lib} missing... Stop"
138
  exit 1
139
else
140
  ls -l ${lib}.a    
141
endif
142
 
143
end
144
 
145
# Exit if only libraries shoudl be installed
146
if ( "${mode}" == "lib" ) exit 0
147
 
148
# -----------------------------------------------------------------------------
149
# Compile Lagrango core programs
150
# -----------------------------------------------------------------------------
151
 
152
if ( ("${mode}" == "all" ) | ("${mode}" == "core" ) ) then
153
 
154
echo
155
echo "-----------------------------------------------------------------"
156
echo "Installing Lagranto core programs"
157
echo "-----------------------------------------------------------------"
158
 
159
foreach prog ( $core )
160
 
161
echo
162
echo "----- $prog"
163
echo
164
cd ${LAGRANTO}/${prog}
165
\rm -f ${prog}.o 
166
\rm -f ${prog}
167
if ( "${prog}" == "select" ) \rm special.o
168
\rm -f ${prog}
169
make -f ${prog}.make
170
if ( ! -f ${prog} ) then
171
  echo "Problem in compiling ${prog} ... Stop"
172
  exit 1
173
endif
174
 
175
end
176
 
177
endif
178
 
179
# -----------------------------------------------------------------------------
180
# Check that all Lagranto core programs are available
181
# -----------------------------------------------------------------------------
182
 
183
echo
184
echo "-----------------------------------------------------------------"
185
echo "Check that all Lagranto core programs are available"
186
echo "-----------------------------------------------------------------"
187
echo
188
 
189
foreach prog ( $core )
190
 
191
  cd ${LAGRANTO}/${prog}
192
  if ( ! -f ${prog} ) then
193
    echo "${prog} is missing... Stop"
194
    exit 1
195
  else
196
    ls -l ${prog}    
197
  endif
198
 
199
end
200
 
201
# Exit if only core programs shoudl be installed
202
if ( "${mode}" == "core" ) exit 0
203
 
204
# -----------------------------------------------------------------------------
205
# Compile Lagrango goodies
206
# -----------------------------------------------------------------------------
207
 
208
if ( ("${mode}" == "all" ) | ("${mode}" == "goodies" ) ) then
209
 
210
echo
211
echo "-----------------------------------------------------------------"
212
echo "Installing Lagranto goodies"
213
echo "-----------------------------------------------------------------"
214
 
215
cd ${LAGRANTO}/goodies
216
 
217
foreach tool ( $tools )
218
 
219
echo
220
echo "----- ${tool}"
221
echo
222
\rm -f ${tool}.o
223
\rm -f ${tool}
224
if ( -f ${tool}.make ) then
225
   make -f ${tool}.make
226
else if ( -f ${tool}.install ) then
227
   ./${tool}.install
228
endif
229
 
230
if ( ! -f ${tool} ) then
231
  echo "Problem in compiling ${tool} ... Stop"
232
  exit 1
233
endif
234
 
235
end
236
 
237
endif
238
 
239
# -----------------------------------------------------------------------------
240
# Check that all Lagranto goodies are available
241
# -----------------------------------------------------------------------------
242
 
243
echo
244
echo "-----------------------------------------------------------------"
245
echo "Check that all Lagranto goodies are available"
246
echo "-----------------------------------------------------------------"
247
echo
248
 
249
cd ${LAGRANTO}/goodies
250
 
251
foreach tool ( $tools )
252
 
253
if ( ! -f ${tool} ) then
254
  echo "${tool} is missing... Stop"
255
  exit 1
256
else
257
  ls -l ${tool} 
258
endif
259
 
260
end
261
 
262
endif
263
 
264
# Exit if only goodies should be installed
265
if ( "${mode}" == "goodies" ) exit 0
266
 
267
# -----------------------------------------------------------------------------
268
# Create links to programs
269
# -----------------------------------------------------------------------------
270
 
271
if ( ("${mode}" == "all" ) | ("${mode}" == "links" )  ) then
272
 
273
echo
274
echo "-----------------------------------------------------------------"
275
echo "Create links in ${LAGRANTO}/bin/"
276
echo "-----------------------------------------------------------------"
277
echo
278
 
279
if ( ! -d ${LAGRANTO}/bin ) mkdir ${LAGRANTO}/bin
280
cd ${LAGRANTO}/bin
281
 
282
ln -svf ${LAGRANTO}/bin/lagrantohelp        lagrantohelp.sh
283
 
284
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra.sh
285
ln -svf ${LAGRANTO}/select/select.sh        select.sh
286
ln -svf ${LAGRANTO}/trace/trace.sh          trace.sh
287
 
288
ln -svf ${LAGRANTO}/caltra/caltra.sh        caltra
289
ln -svf ${LAGRANTO}/select/select.sh        select
290
ln -svf ${LAGRANTO}/trace/trace.sh          trace
291
 
292
foreach tool ( $tools )
293
 
294
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool}.sh 
295
ln -svf ${LAGRANTO}/goodies/${tool}.sh     ${tool} 
296
 
297
end
298
 
299
# Set extra name for <select> to avoid conflict in BASH
300
ln -svf ${LAGRANTO}/select/select.sh        seltra
301
ln -svf ${LAGRANTO}/select/select.sh        seltra.sh
302
 
303
endif
304
 
305
# -----------------------------------------------------------------------------
306
# Final tasks
307
# -----------------------------------------------------------------------------
308
 
309
echo
310
echo "-----------------------------------------------------------------"
311
echo "Installation complete"
312
echo "-----------------------------------------------------------------"
313
echo
314
echo "Please set the environmental variable LAGRANTO"
315
echo
316
echo "    setenv LAGRANTO ${LAGRANTO}"
317
echo
318
 
319
 
320
 
321
 
322