1 | #!/bin/ksh |
---|
2 | # $Id$ |
---|
3 | #--------------------------------------------------------------------- |
---|
4 | #- ins_m_prec - Installation of the precision module |
---|
5 | #--------------------------------------------------------------------- |
---|
6 | function ins_m_prec_Usage |
---|
7 | { |
---|
8 | echo " |
---|
9 | ins_m_prec install the precision module in IOIPSL/src |
---|
10 | |
---|
11 | Usage : |
---|
12 | ${b_n} [-h] | [-v] [-i i_prec] [-r r_prec] |
---|
13 | |
---|
14 | Options : |
---|
15 | -h : help |
---|
16 | -v : verbose mode |
---|
17 | -i i_prec : integer precision 4/8 |
---|
18 | -r r_prec : real precision 4/8 |
---|
19 | |
---|
20 | Defaults : |
---|
21 | -i 4 -r 8 |
---|
22 | |
---|
23 | Example for default precision : |
---|
24 | ins_m_prec |
---|
25 | |
---|
26 | Example for INTEGER 4 and REAL 4 precision : |
---|
27 | ins_m_prec -i 4 -r 4 |
---|
28 | " |
---|
29 | } |
---|
30 | #- dirname and basename |
---|
31 | d_n=$(dirname ${0}); b_n=$(basename ${0}); |
---|
32 | #- Retrieving and validation of the options |
---|
33 | x_v='silencious'; x_i=""; x_r=""; |
---|
34 | while getopts :hvi:r: V |
---|
35 | do |
---|
36 | case ${V} in |
---|
37 | (h) ins_m_prec_Usage; exit 0;; |
---|
38 | (v) x_v='verbose';; |
---|
39 | (i) x_i=${OPTARG};; |
---|
40 | (r) x_r=${OPTARG};; |
---|
41 | (:) echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2; |
---|
42 | exit 2;; |
---|
43 | (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2; |
---|
44 | exit 2;; |
---|
45 | esac |
---|
46 | done |
---|
47 | shift $(($OPTIND-1)); |
---|
48 | #- |
---|
49 | # INTEGER and REAL precision |
---|
50 | #- |
---|
51 | case ${x_i} in |
---|
52 | ( 4 | 8 ) ;; |
---|
53 | ("") x_i='4';; |
---|
54 | (*) |
---|
55 | echo 'Invalid INTEGER precision requested' 1>&2; |
---|
56 | echo ${x_i}' (must be 4 or 8)' 1>&2; |
---|
57 | exit 1;; |
---|
58 | esac |
---|
59 | case ${x_r} in |
---|
60 | ( 4 | 8 ) ;; |
---|
61 | ("") x_r='8';; |
---|
62 | (*) |
---|
63 | echo 'Invalid REAL precision requested' 1>&2; |
---|
64 | echo ${x_r}' (must be 4 or 8)' 1>&2; |
---|
65 | exit 1;; |
---|
66 | esac |
---|
67 | #- |
---|
68 | [[ ${x_v} = 'verbose' ]] && \ |
---|
69 | { echo "\nInstallation of the precision module"; |
---|
70 | echo '--- Integer precision : '${x_i}; |
---|
71 | echo '--- Real precision : '${x_r}; } |
---|
72 | #- |
---|
73 | dp_d=${d_n}'/../modeles/IOIPSL/src'; |
---|
74 | #- |
---|
75 | dp_b="${dp_d}"'/def.prec' |
---|
76 | [[ ! -f "${dp_b}" ]] && { echo "${dp_b} unreachable ..."; exit 3; } |
---|
77 | sed -e "s/i_std=i_?/i_std=i_${x_i}/" \ |
---|
78 | -e "s/r_std=r_?/r_std=r_${x_r}/" ${dp_b} > wmpf.$$; |
---|
79 | #- |
---|
80 | # Create the module "defprec.f90" or update it |
---|
81 | # if the default precision has been modified |
---|
82 | #- |
---|
83 | dp_p="${dp_d}"'/defprec.f90'; |
---|
84 | diff -q wmpf.$$ ${dp_p} > /dev/null 2>&1; r_c=${?}; |
---|
85 | [[ ${r_c} != 0 ]] && cp -p wmpf.$$ ${dp_p}; |
---|
86 | [[ ${x_v} = 'verbose' ]] && \ |
---|
87 | { echo " "; |
---|
88 | { [[ ${r_c} = 0 ]] && echo ${dp_p} 'already up to date'; } || \ |
---|
89 | { [[ ${r_c} = 1 ]] && echo 'Update '${dp_p}; } || \ |
---|
90 | { [[ ${r_c} = 2 ]] && echo 'Create '${dp_p}; } |
---|
91 | echo " "; } |
---|
92 | #- |
---|
93 | unset dp_d dp_b dp_p x_v x_i x_r; rm -f wmpf.$$; |
---|
94 | #- |
---|
95 | exit 0; |
---|