source: modipsl/trunk/util/ins_m_prec @ 15

Last change on this file since 15 was 13, checked in by bellier, 18 years ago

JB: Id added

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1#!/bin/ksh
2# $Id$
3#---------------------------------------------------------------------
4#- ins_m_prec - Installation of the precision module
5#---------------------------------------------------------------------
6function ins_m_prec_Usage
7{
8echo "
9ins_m_prec install the precision module in IOIPSL/src
10
11Usage :
12  ${b_n} [-h] | [-v] [-i i_prec] [-r r_prec]
13
14Options :
15  -h        : help
16  -v        : verbose mode
17  -i i_prec : integer precision 4/8
18  -r r_prec : real    precision 4/8
19
20Defaults :
21  -i 4 -r 8
22
23Example for default precision :
24  ins_m_prec
25
26Example for INTEGER 4 and REAL 4 precision :
27  ins_m_prec -i 4 -r 4
28"
29}
30#-  dirname and  basename
31d_n=${0%/*}; b_n=${0##*/};
32#- Retrieving and validation of the options
33x_v='silencious'; x_i=""; x_r="";
34while 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
47shift $(($OPTIND-1));
48#-
49# INTEGER and REAL precision
50#-
51case ${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;;
58esac
59case ${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;;
66esac
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#-
73dp_d=${d_n}'/../modeles/IOIPSL/src';
74#-
75dp_b="${dp_d}"'/def.prec'
76[[ ! -f "${dp_b}" ]] && { echo "${dp_b} unreachable ..."; exit 3; }
77sed -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#-
83dp_p="${dp_d}"'/defprec.f90';
84diff -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#-
93unset dp_d dp_b dp_p x_v x_i x_r; rm -f wmpf.$$;
94#-
95exit 0;
Note: See TracBrowser for help on using the repository browser.