1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # $Id: buildbufr $
|
---|
4 | #
|
---|
5 | #****k* BUFR/buildbufr *
|
---|
6 | #-----------------------------------------------------------------------
|
---|
7 | #
|
---|
8 | # NAME
|
---|
9 | # buildbufr
|
---|
10 | #
|
---|
11 | # SYNOPSIS
|
---|
12 | # Example script to build BUFR library and support programs.
|
---|
13 | #
|
---|
14 | # > buildbufr [-b bufrdir] [-c] [-f compiler] [-h]
|
---|
15 | # [-p prefix] [-n] [-t] [-z]
|
---|
16 | #
|
---|
17 | # OPTIONS
|
---|
18 | # -b set BUFR_LIBRARY temporarily to <bufrdir>
|
---|
19 | # BUFR tables will be copied here as working versions.
|
---|
20 | # Default: existing environment variable definition,
|
---|
21 | # or if this is not defined, then <prefix>/data/bufr/
|
---|
22 | # Tip: use "-b ." to install locally within the BUFR package tree.
|
---|
23 | #
|
---|
24 | # -c clean build before make (make from scratch)
|
---|
25 | # Recommended if trying a different compiler or building
|
---|
26 | # an updated package from an existing build in the same
|
---|
27 | # location. Default: build only things which have changed.
|
---|
28 | #
|
---|
29 | # -f F90 compiler
|
---|
30 | # HP: one of DEF, NAG or HP (Default: HP)
|
---|
31 | # Linux: one of DEF, IFC, IFORT, IFORT8, IFORT9, IFORT10,
|
---|
32 | # PGF, PGF6, PGF7,
|
---|
33 | # NAG, LF95, G95 or GFC (Default: IFORT)
|
---|
34 | # Cygwin: one of DEF, IFORT, G95 or GFC (Default: G95)
|
---|
35 | # Sun OS: one of DEF, FUJITSU (Default: FUJITSU)
|
---|
36 | # See file f90_compilers.dat for definitive list - other
|
---|
37 | # compilers may be supported by adding entries to this file.
|
---|
38 | #
|
---|
39 | # -h print basic usage info and exit.
|
---|
40 | #
|
---|
41 | # -n without -z: don't install executables (Default: install to <prefix>/bin)
|
---|
42 | # with -z: disables default distribution of tarball.
|
---|
43 | #
|
---|
44 | # -p set a prefix (root directory) for build. Default: HOME
|
---|
45 | # <prefix>/bin - location for binary (executable) files
|
---|
46 | # <prefix>/lib - location for BUFR object library (libbufr.a)
|
---|
47 | # <prefix>/include - location for f90 include & module files
|
---|
48 | # <prefix>/man/man1 - location for 'man page' files
|
---|
49 | # Tip: use "-p ." to install locally within the BUFR package tree.
|
---|
50 | #
|
---|
51 | # -t also build & run MetDB simple test programs. Executable files
|
---|
52 | # are built in bufr/metdb/. Default: skip test programs.
|
---|
53 | # (testtables and decbufr are always built & run)
|
---|
54 | #
|
---|
55 | # -z builds a distribution as a zip archive. Except for -n all other
|
---|
56 | # options are ignored. This option is for local administrator use,
|
---|
57 | # and depends on files not in the distribution package. By default,
|
---|
58 | # the newly-created package is uploaded to the E-GVAP project hub
|
---|
59 | # server and copied to the ROPP archive/build directory; this can
|
---|
60 | # be disabled by also using -n.
|
---|
61 | #
|
---|
62 | # INPUTS
|
---|
63 | # BUFR source code
|
---|
64 | #
|
---|
65 | # OUTPUTS
|
---|
66 | # Without -z: BUFR object library libbufr.a (bufr.lib for native Windows
|
---|
67 | # compilers) & application executables, etc.
|
---|
68 | # With -z: ../bufrpack-<ver>.zip where <ver> is the current BUFR package
|
---|
69 | # release version ID taken from the README file.
|
---|
70 | #
|
---|
71 | # ENVIRONMENT VARIABLES
|
---|
72 | # BUFR_LIBRARY - path to BUFR run-time files
|
---|
73 | # PACKAGES - path to package root directory (used with -z only)
|
---|
74 | #
|
---|
75 | # USES
|
---|
76 | # f90_select
|
---|
77 | # cygpath (on Cygwin builds only)
|
---|
78 | # bufrpack.sh (with -z only)
|
---|
79 | #
|
---|
80 | # DESCRIPTION
|
---|
81 | # Assumes a directory structure:
|
---|
82 | #
|
---|
83 | # bufr[-<ver>]/
|
---|
84 | # |
|
---|
85 | # +--------+---------+
|
---|
86 | # | |
|
---|
87 | # metdb/ extra/
|
---|
88 | #
|
---|
89 | # and that:
|
---|
90 | # - we are curently in bufr/ or bufr-<ver>/ (where <ver> is the BUFR
|
---|
91 | # package release version ID)
|
---|
92 | # - the MetDB BUFR package, including operational tables, is installed
|
---|
93 | # in metdb/
|
---|
94 | # - non-MetDB files are in extra/
|
---|
95 | # - run-time tables will be placed in BUFR_LIBRARY (normally
|
---|
96 | # <prefix>/data/bufr/)
|
---|
97 | #
|
---|
98 | # Configured to support a (limited) number of compilers running under
|
---|
99 | # HP-UX, SunOS, Linux and Cygwin (Microsoft Windows). See README,
|
---|
100 | # README.cygwin & f90_compilers.dat files for details.
|
---|
101 | #
|
---|
102 | # Tip: to save a log of the build,
|
---|
103 | # > buildbufr [options] | tee buildbufr.log
|
---|
104 | #
|
---|
105 | # The build script will:
|
---|
106 | # - check that the BUFR_LIBRARY environment variable is set
|
---|
107 | # if not, set the default to directory <prefix>/data/bufr)
|
---|
108 | # - attempt to create the prefix tree if directories do not pre-exist
|
---|
109 | # - check that the selected (if using the -f option) or default F90
|
---|
110 | # compiler is present & working
|
---|
111 | # - install the 'operational' set of BUFR tables from metdb/ to
|
---|
112 | # BUFR_LIBRARY
|
---|
113 | # - if provided, install any modified BUFR tables in extra/
|
---|
114 | # to BUFR_LIBRARY (replacing the operational ones)
|
---|
115 | # - clean any previous build (only if using the -c option)
|
---|
116 | # - make the kernel MetDB BUFR object library in <prefix>/lib/libbufr.a
|
---|
117 | # - build & run the MetDB test programs (if using the -t option)
|
---|
118 | # - add some extra support routines to the BUFR object library
|
---|
119 | # - make the BUFR application executable programs in <prefix>/bin
|
---|
120 | # and run them on test inputs
|
---|
121 | # - install man pages from extra/ to <prefix>/man/man1
|
---|
122 | #
|
---|
123 | # NB if the -c option is not used, and a previous build has been done,
|
---|
124 | # only changed components will be updated.
|
---|
125 | #
|
---|
126 | # If the -z option is used, a distribution package (zipfile) will be built.
|
---|
127 | # Since this uses files not included in the distribution zipfile, this option
|
---|
128 | # should only be used on the package development tree. A file called
|
---|
129 | # bufrpack-<ver>.zip (where <ver> is the current package release version ID,
|
---|
130 | # extracted from te README file) will be created (or replaced_ in the PACKAGES
|
---|
131 | # directory (parent of bufr/).
|
---|
132 | #
|
---|
133 | # AUTHOR
|
---|
134 | # Dave Offiler
|
---|
135 | #
|
---|
136 | # MODIFICATION HISTORY
|
---|
137 | # 1.0 05-Aug-2005 First documented suitable for RoboDoc D. Offiler
|
---|
138 | # 1.1 12-Sep-2005 Add support for SunOS D. Offiler
|
---|
139 | # 1.2 21-Sep-2005 BUFR library name bufr.lib for ifort on
|
---|
140 | # Cygwin only (was thus named for any
|
---|
141 | # Cygwin compiler) D. Offiler
|
---|
142 | # 1.3 11-Apr-2006 First change directory to the one
|
---|
143 | # containing this script, so it can be
|
---|
144 | # called from elsewhere D. Offiler
|
---|
145 | # 1.4 26-Jul-2006 (a) Skip running test_tables & decbufr if the
|
---|
146 | # executables weren't built
|
---|
147 | # (b) Install table CT001033 from extra/ to
|
---|
148 | # BUFR_LIBRARY D. Offiler
|
---|
149 | # 1.5 06-Dec-2006 (a) Increase sleep time between main library
|
---|
150 | # build and extra build - make not detecting that
|
---|
151 | # the extra .o files are newer than the .a.
|
---|
152 | # (b) Add -n option to command line. D. Offiler
|
---|
153 | # 1.6 14-Jun-2007 Extract release version from README and print
|
---|
154 | # to stdout. D. Offiler
|
---|
155 | # 1.7 28-Mar-2008 Convert Cygwin paths to full Unix-style before
|
---|
156 | # invoking make D. Offiler
|
---|
157 | # 1.8 02-Sep-2008 (a) Run under 'bash' (was 'sh')
|
---|
158 | # Use [[test]] built-in syntax instead of [test] external;
|
---|
159 | # Use $(command) syntax instead of `command` form;
|
---|
160 | # Use bash substringing instead of external editing commands
|
---|
161 | # (b) Delete BUFR sample file if clean & test options present
|
---|
162 | # before building & running MetBD sample test programs
|
---|
163 | # (c) Append $EXE (OS-dependant blank or '.exe.') when invoking
|
---|
164 | # test programs to match correct build program extension
|
---|
165 | # when both could be present (e.g. shared Linux &
|
---|
166 | # Windows/Cygwin partition)
|
---|
167 | # (d) Distro package builder appends version ID to zip file
|
---|
168 | # name & file paths
|
---|
169 | # (e) Updated comment headers. D. Offiler
|
---|
170 | # 1.9 13-Aug-2009 (a) Removed use of portability.fi include file -
|
---|
171 | # replaced by nag_interfaces.f90 for transparency
|
---|
172 | # with NAG compiler.
|
---|
173 | # (b) Distro builder creates gzipped tar archive
|
---|
174 | # bufr-<ver>.tar.gz instead of ZIP archive
|
---|
175 | # bufrpack-<ver>.zip.
|
---|
176 | # (c) MetDB BUFR library renamed libmetdbbufr.a to avoid
|
---|
177 | # clash with ECMWF BUFR library also called libbufr.a
|
---|
178 | # (c) Improved usage info (-h) D. Offiler
|
---|
179 | # 1.10 01-Nov-2009 (a) Rename test_tables to testtables.
|
---|
180 | # (b) Install new tables MASTERTABLE, DATACATEGORY
|
---|
181 | # (replaces TABLEA) and ORIGCENTRE (replaces
|
---|
182 | # CT001033 & CT001034).
|
---|
183 | # (c) Check library for new sec1tables instead of
|
---|
184 | # old codetables when adding extra/ code. D. Offiler
|
---|
185 | #
|
---|
186 | #-------------------------------------------------------------------
|
---|
187 | #****
|
---|
188 | #
|
---|
189 | usage(){
|
---|
190 | echo
|
---|
191 | echo "Usage: > buildbufr [-c] [-b bufrdir] [-f compiler]"
|
---|
192 | echo " [-p prefix] [-t] [-z] [-n] [-h]"
|
---|
193 | echo
|
---|
194 | echo "where:"
|
---|
195 | echo " -c : clean build before make (make from scratch)"
|
---|
196 | echo " [Default: build only things which have changed]"
|
---|
197 | echo " -b : tempory override of path to install BUFR tables"
|
---|
198 | echo " [Default: BUFR_LIBRARY or if not set, <prefix>/data/bufr]"
|
---|
199 | echo " -f : F90 compiler ID"
|
---|
200 | echo " [Default: OS-dependant - see f90_compilers.dat]"
|
---|
201 | echo " -p : set a prefix (root directory) for installation. [Default: HOME]"
|
---|
202 | echo " -t : run simple MetDB tests to check correct build. [Default: skip tests]"
|
---|
203 | echo " -z : build distribution tarball. For local admin use only."
|
---|
204 | echo " -n : without -z - disable installation of executables to <prefix>/bin"
|
---|
205 | echo " with -z - disable default upload of package to E-GVAP server"
|
---|
206 | echo " -h : print this usage info "
|
---|
207 | echo
|
---|
208 | exit
|
---|
209 | exit
|
---|
210 | }
|
---|
211 | #-------------------------------------------------------------------
|
---|
212 | #
|
---|
213 | echo
|
---|
214 | echo " ============ Build script for BUFR package ============"
|
---|
215 | #
|
---|
216 | # --- Start from directory containing this script ---
|
---|
217 | #
|
---|
218 | TOP=$(dirname $0)
|
---|
219 | cd $TOP
|
---|
220 | TOP=$PWD
|
---|
221 | #
|
---|
222 | # --- Parse options after setting defaults ---
|
---|
223 | #
|
---|
224 | clean="n"
|
---|
225 | f90opt="DEF"
|
---|
226 | PREFIX=$HOME
|
---|
227 | install_extra="install_mod install_exe"
|
---|
228 | test="n"
|
---|
229 | upload="PUBLISH"
|
---|
230 | zipdist="n"
|
---|
231 | #
|
---|
232 | while getopts b:cf:hinp:tz option
|
---|
233 | do
|
---|
234 | case $option in
|
---|
235 | b) BUFR_LIBRARY=$OPTARG
|
---|
236 | if [[ $BUFR_LIBRARY = "." ]] || [[ $BUFR_LIBRARY = "./" ]]; then
|
---|
237 | BUFR_LIBRARY=$PWD/data/bufr/
|
---|
238 | fi
|
---|
239 | ;;
|
---|
240 | c) clean="y"
|
---|
241 | ;;
|
---|
242 | f) f90opt=$OPTARG
|
---|
243 | ;;
|
---|
244 | h) usage
|
---|
245 | ;;
|
---|
246 | n) install_extra="install_mod"
|
---|
247 | upload=""
|
---|
248 | ;;
|
---|
249 | p) PREFIX=$OPTARG
|
---|
250 | if [[ $PREFIX = "." ]] || [[ $PREFIX = "./" ]]; then
|
---|
251 | PREFIX=$PWD
|
---|
252 | fi
|
---|
253 | if [[ ! ${PREFIX:0:1} = "/" ]]; then
|
---|
254 | PREFIX=$PWD/$PREFIX
|
---|
255 | fi
|
---|
256 | ;;
|
---|
257 | t) test="y"
|
---|
258 | ;;
|
---|
259 | z) zipdist="y"
|
---|
260 | ;;
|
---|
261 | esac
|
---|
262 | done
|
---|
263 | #
|
---|
264 | # ---- Build zip archive distribution package ----
|
---|
265 | #
|
---|
266 | if [[ $zipdist = "y" ]]; then
|
---|
267 | if [[ -f scripts/bufrpack.sh ]]; then
|
---|
268 | scripts/bufrpack.sh $upload
|
---|
269 | else
|
---|
270 | echo
|
---|
271 | echo "*** Package builder script not available in this distribution"
|
---|
272 | fi
|
---|
273 | exit
|
---|
274 | fi
|
---|
275 | #
|
---|
276 | # --- Setup for OS-specific stuff ---
|
---|
277 | #
|
---|
278 | OS=$(uname | cut -c 1-6 | tr "[:lower:]" "[:upper:]")
|
---|
279 | case $OS in
|
---|
280 | AIX)
|
---|
281 | echo " (AIX Unix)"
|
---|
282 | INSTALL="cp -f -p"
|
---|
283 | DELETE="rm -f"
|
---|
284 | ;;
|
---|
285 | HP-UX)
|
---|
286 | echo " (HP Unix)"
|
---|
287 | INSTALL="cp -f -p"
|
---|
288 | DELETE="rm -f"
|
---|
289 | ;;
|
---|
290 | SUNOS)
|
---|
291 | echo " (Sun-OS)"
|
---|
292 | INSTALL="cp -f -p"
|
---|
293 | DELETE="rm -f"
|
---|
294 | ;;
|
---|
295 | CYGWIN)
|
---|
296 | echo " (Windows/Cygwin)"
|
---|
297 | INSTALL="cp --update --verbose --preserve"
|
---|
298 | DELETE="rm --force --verbose"
|
---|
299 | ;;
|
---|
300 | *)
|
---|
301 | uname -a | grep nec > /dev/null
|
---|
302 | if [[ $? -eq 0 ]]; then
|
---|
303 | echo " (NEC Linux)"
|
---|
304 | INSTALL="cp --update --verbose --preserve"
|
---|
305 | DELETE="rm --force --verbose"
|
---|
306 | else
|
---|
307 | echo " (Linux)"
|
---|
308 | INSTALL="cp --update --verbose --preserve=timestamps"
|
---|
309 | DELETE="rm --force --verbose"
|
---|
310 | fi
|
---|
311 | ;;
|
---|
312 | esac
|
---|
313 | #
|
---|
314 | # --- Data files & directories ---
|
---|
315 | #
|
---|
316 | if [[ -z "$BUFR_LIBRARY" ]]; then
|
---|
317 | BUFR_LIBRARY=$PREFIX/data/bufr/
|
---|
318 | fi
|
---|
319 | #
|
---|
320 | # --- Show release info
|
---|
321 | #
|
---|
322 | release="on $(hostname)"
|
---|
323 | if [[ -f RELEASE ]]; then
|
---|
324 | echo
|
---|
325 | cat RELEASE
|
---|
326 | elif [[ -f README ]]; then
|
---|
327 | release=$(grep "(Release" README | awk '{print $1 " " $2}')
|
---|
328 | fi
|
---|
329 | runtime=$(date "+%H:%M %z on %A, %d-%b-%Y")
|
---|
330 | echo
|
---|
331 | echo ">> Building BUFR $release at $runtime"
|
---|
332 | #
|
---|
333 | # ---- Under Cywin (Windows) convert paths to semi-Windows style ----
|
---|
334 | # E.g. if C: is 'mounted' to mount point /c, then c:\include is
|
---|
335 | # mapped to /c/include, which the Intel compiler confuses with
|
---|
336 | # the /c (compile only) switch. We use the cygpath utility to
|
---|
337 | # convert such paths to c:/include which the compiler is happy
|
---|
338 | # with and doesn't cause bash any problems with backslashes
|
---|
339 | # either, which could be interpreted as escape characters.
|
---|
340 | # A further issue is to remove any trailing '/' from some paths.
|
---|
341 | #
|
---|
342 | if [[ $OS = "CYGWIN" ]]; then
|
---|
343 | HOME=$(cygpath -m $HOME | sed s#"\/$"##)
|
---|
344 | TOP=$(cygpath -m $TOP)
|
---|
345 | PREFIX=$(cygpath -m $PREFIX)
|
---|
346 | BUFR_LIBRARY=$(cygpath -m $BUFR_LIBRARY)
|
---|
347 | fi
|
---|
348 | #
|
---|
349 | PREFIX=$(echo $PREFIX | sed s#"\/$"##)
|
---|
350 | BINDIR=$PREFIX/bin
|
---|
351 | LIBDIR=$PREFIX/lib
|
---|
352 | INCDIR=$PREFIX/include
|
---|
353 | MANDIR=$PREFIX/man
|
---|
354 | DATDIR=$PREFIX/data
|
---|
355 | #
|
---|
356 | # --- Ensure the last character of BUFR_LIBRARY is a '/'
|
---|
357 | # and is a full path
|
---|
358 | #
|
---|
359 | BUFR_LIBRARY=${BUFR_LIBRARY%%/}/
|
---|
360 | if [[ $BUFR_LIBRARY = "./" ]]; then
|
---|
361 | BUFR_LIBRARY=$TOP/
|
---|
362 | fi
|
---|
363 | export BUFR_LIBRARY
|
---|
364 | #
|
---|
365 | # --- Create any missing directories ---
|
---|
366 | #
|
---|
367 | echo
|
---|
368 | echo ">> Checking target directories..."
|
---|
369 | if [[ $OS = "AIX" ]]; then
|
---|
370 | mkdir -p $BINDIR
|
---|
371 | mkdir -p $LIBDIR
|
---|
372 | mkdir -p $INCDIR
|
---|
373 | mkdir -p $MANDIR/man1
|
---|
374 | mkdir -p $DATDIR/bufr
|
---|
375 | mkdir -p ${BUFR_LIBRARY%%/}
|
---|
376 | else
|
---|
377 | mkdir -p -v $BINDIR
|
---|
378 | mkdir -p -v $LIBDIR
|
---|
379 | mkdir -p -v $INCDIR
|
---|
380 | mkdir -p -v $MANDIR/man1
|
---|
381 | mkdir -p -v $DATDIR/bufr
|
---|
382 | mkdir -p -v ${BUFR_LIBRARY%%/}
|
---|
383 | fi
|
---|
384 | #
|
---|
385 | # --- Set up favourite compiler ---
|
---|
386 | #
|
---|
387 | echo
|
---|
388 | if [[ $OS = "CYGWIN" ]]; then
|
---|
389 | INCDIR=$(cygpath -u $INCDIR)
|
---|
390 | fi
|
---|
391 | export INCDIR
|
---|
392 | . ./f90_select f90opt=$f90opt
|
---|
393 | echo ">> Using $f90name compiler ($FF)"
|
---|
394 | echo
|
---|
395 | echo ">> Setting up file syntax for $OS..."
|
---|
396 | OBJ=".o"
|
---|
397 | EXE=""
|
---|
398 | TARGET=libmetdbbufr
|
---|
399 | BUFRLIB=${TARGET}.a
|
---|
400 | MAKEFILE1="Makefile_BUFRrelease"
|
---|
401 | MAKEFILE2="Makefile_BUFRtest"
|
---|
402 | MAKEFILE3="Makefile"
|
---|
403 | if [[ $OS = "CYGWIN" ]]; then
|
---|
404 | if [[ $FF = "ifort" ]]; then
|
---|
405 | OBJ=".obj"
|
---|
406 | sed s/"\\.o"/"\\.obj"/g metdb/$MAKEFILE1 > metdb/${MAKEFILE1}_CYGWIN
|
---|
407 | MAKEFILE1="${MAKEFILE1}_CYGWIN"
|
---|
408 | fi
|
---|
409 | #
|
---|
410 | # ---- Under Cywin (Windows) convert paths to Unix style ----
|
---|
411 | # The 'make' utility doesn't like having ':' appear in file names -
|
---|
412 | # which it uses as a syntax separator. So we use the cygpath utility
|
---|
413 | # here to convert semi-Windows style cygdrive/c:/include (/c:/include
|
---|
414 | # if mounted) to /cygdrive/c/include (or /c/include). Oh the joys of
|
---|
415 | # working with Windows!
|
---|
416 | #
|
---|
417 | PREFIX=$(cygpath -u $PREFIX)
|
---|
418 | BINDIR=$PREFIX/bin
|
---|
419 | LIBDIR=$PREFIX/lib
|
---|
420 | INCDIR=$PREFIX/include
|
---|
421 | MANDIR=$PREFIX/man
|
---|
422 | DATDIR=$PREFIX/data
|
---|
423 | EXE=".exe"
|
---|
424 | fi
|
---|
425 | #
|
---|
426 | # --- Install operational & local BUFR tables ---
|
---|
427 | #
|
---|
428 | echo
|
---|
429 | echo ">> Copying operational BUFR tables to $BUFR_LIBRARY..."
|
---|
430 | $INSTALL $TOP/metdb/TABLEB $BUFR_LIBRARY
|
---|
431 | $INSTALL $TOP/metdb/TABLED $BUFR_LIBRARY
|
---|
432 | $INSTALL $TOP/metdb/CODEFIG $BUFR_LIBRARY
|
---|
433 | #
|
---|
434 | echo
|
---|
435 | echo ">> Copying local BUFR tables to $BUFR_LIBRARY..."
|
---|
436 | $INSTALL $TOP/extra/MASTERTABLE $BUFR_LIBRARY
|
---|
437 | $INSTALL $TOP/extra/DATACATEGORY $BUFR_LIBRARY
|
---|
438 | $INSTALL $TOP/extra/ORIGCENTRE $BUFR_LIBRARY
|
---|
439 | if [[ -s $TOP/extra/CODEFIG ]]; then
|
---|
440 | $INSTALL $TOP/extra/CODEFIG $BUFR_LIBRARY
|
---|
441 | fi
|
---|
442 | if [[ -s $TOP/extra/TABLEB ]]; then
|
---|
443 | $INSTALL $TOP/extra/TABLEB $BUFR_LIBRARY
|
---|
444 | fi
|
---|
445 | if [[ -s $TOP/extra/TABLED ]]; then
|
---|
446 | $INSTALL $TOP/extra/TABLED $BUFR_LIBRARY
|
---|
447 | fi
|
---|
448 | #
|
---|
449 | # --- Build MetDB kernel BUFR object library ---
|
---|
450 | #
|
---|
451 | echo
|
---|
452 | cd $TOP/metdb
|
---|
453 | if [[ "$clean" = "y" ]]; then
|
---|
454 | echo ">> Cleaning BUFR kernel object library..."
|
---|
455 | echo
|
---|
456 | make -f $MAKEFILE1 clean
|
---|
457 | if [[ -f $BUFRLIB ]]; then
|
---|
458 | $DELETE $BUFRLIB
|
---|
459 | fi
|
---|
460 | if [[ -f $LIBDIR/$BUFRLIB ]]; then
|
---|
461 | $DELETE $LIBDIR/$BUFRLIB
|
---|
462 | fi
|
---|
463 | echo
|
---|
464 | fi
|
---|
465 | echo ">> Building BUFR kernel object library $BUFRLIB..."
|
---|
466 | echo
|
---|
467 | make -f $MAKEFILE1 FF=$FF FFLAGS="$FFLAGS" \
|
---|
468 | CC=$CC CFLAGS="$CFLAGS" TARGET=$TARGET
|
---|
469 | echo
|
---|
470 | if [[ -f $BUFRLIB ]]; then
|
---|
471 | cp $BUFRLIB $TOP/extra
|
---|
472 | #
|
---|
473 | # --- Optionally build & run MetDB simple encode/decode test programs ---
|
---|
474 | #
|
---|
475 | BUFRDEC_FILE="$TOP/metdb/TestMessage.bufr"
|
---|
476 | export BUFRDEC_FILE
|
---|
477 | if [[ "$test" = "y" ]]; then
|
---|
478 | echo
|
---|
479 | $INSTALL $TOP/extra/$MAKEFILE2 $TOP/metdb/
|
---|
480 | if [[ $clean = "y" ]]; then
|
---|
481 | echo
|
---|
482 | echo ">> Cleaning test programs & data..."
|
---|
483 | make -f $MAKEFILE2 OBJ=$OBJ EXE=$EXE \
|
---|
484 | BUFRLIB=$BUFRLIB clean
|
---|
485 | if [[ -f $BUFRDEC_FILE ]]; then
|
---|
486 | $DELETE $BUFRDEC_FILE
|
---|
487 | fi
|
---|
488 | fi
|
---|
489 | echo
|
---|
490 | echo ">> Testing basic encode/decode..."
|
---|
491 | echo
|
---|
492 | make -f $MAKEFILE2 FF=$FF FFLAGS="$FFLAGS" \
|
---|
493 | OBJ=$OBJ EXE=$EXE BUFRLIB=$BUFRLIB
|
---|
494 | echo
|
---|
495 | echo " - Encoding..."
|
---|
496 | echo
|
---|
497 | ./BUFRencode${EXE}
|
---|
498 | if [[ -f $BUFRDEC_FILE ]]; then
|
---|
499 | echo
|
---|
500 | echo " - Decoding..."
|
---|
501 | ./BUFRdecode${EXE}
|
---|
502 | else
|
---|
503 | echo
|
---|
504 | echo "*** Encode failed! ***"
|
---|
505 | fi
|
---|
506 | fi
|
---|
507 | #
|
---|
508 | # ---- Build & run extra utility routines & programs ---
|
---|
509 | #
|
---|
510 | echo
|
---|
511 | cd $TOP/extra
|
---|
512 | if [[ "$clean" = "y" ]]; then
|
---|
513 | echo ">> Cleaning BUFR extra utilities..."
|
---|
514 | echo
|
---|
515 | make -f $MAKEFILE3 PREFIX=$PREFIX OBJ=$OBJ EXE=$EXE clean
|
---|
516 | $DELETE $MANDIR/man1/decbufr.1
|
---|
517 | echo
|
---|
518 | fi
|
---|
519 | #
|
---|
520 | echo ">> Adding BUFR extra routines to $BUFRLIB"
|
---|
521 | echo " and making BUFR utility programs in $BINDIR..."
|
---|
522 | echo
|
---|
523 |
|
---|
524 | ar -t $BUFRLIB | grep sec1tables > /dev/null
|
---|
525 | if [[ $? -eq 0 ]]; then
|
---|
526 | echo
|
---|
527 | echo "$BUFRLIB is up to date"
|
---|
528 | else
|
---|
529 | touch -t $(date "+%Y%m%d")0000 $BUFRLIB # force make to add 'new' bits
|
---|
530 | fi
|
---|
531 | #
|
---|
532 | # --- NAG compiler needs system interfaces adding to the library
|
---|
533 | #
|
---|
534 | if [[ ${f90name:0:3} = "NAG" ]]; then
|
---|
535 | NAGIF=nag_interfaces.f90
|
---|
536 | else
|
---|
537 | NAGIF=""
|
---|
538 | fi
|
---|
539 |
|
---|
540 | echo
|
---|
541 | make -f $MAKEFILE3 FF=$FF FFLAGS="$FFLAGS" PREFIX=$PREFIX \
|
---|
542 | OBJ=$OBJ EXE=$EXE BUFRLIB=$BUFRLIB NAGIF=$NAGIF
|
---|
543 | if [[ $? -eq 0 ]]; then
|
---|
544 | make -f $MAKEFILE3 PREFIX=$PREFIX EXE=$EXE $install_extra
|
---|
545 | fi
|
---|
546 | echo
|
---|
547 | if [[ -f testtables ]]; then
|
---|
548 | echo ">> Testing BUFR run-time Tables A,B,D and Code Tables..."
|
---|
549 | ./testtables${EXE} < testtables.dat
|
---|
550 | else
|
---|
551 | echo "*** Failed to build testtables - correct error(s) and re-run"
|
---|
552 | fi
|
---|
553 | echo
|
---|
554 | if [[ -f decbufr ]]; then
|
---|
555 | echo ">> Testing decbufr..."
|
---|
556 | ./decbufr${EXE} $BUFRDEC_FILE -d
|
---|
557 | else
|
---|
558 | echo "*** Failed to build decbufr - correct error(s) and re-run"
|
---|
559 | fi
|
---|
560 | #
|
---|
561 | echo
|
---|
562 | echo ">> Installing $BUFRLIB to $LIBDIR..."
|
---|
563 | $INSTALL $BUFRLIB $LIBDIR
|
---|
564 | #
|
---|
565 | else
|
---|
566 | echo "*** Failed to build BUFR library - correct error(s) and re-run"
|
---|
567 | fi
|
---|
568 | #
|
---|
569 | # --- Install man pages ---
|
---|
570 | #
|
---|
571 | echo
|
---|
572 | echo ">> Copying MAN files to $MANDIR/man1..."
|
---|
573 | $INSTALL $TOP/extra/*.1 $MANDIR/man1
|
---|
574 | #
|
---|
575 | echo
|
---|
576 | cd $TOP
|
---|
577 | #
|
---|
578 | exit
|
---|