source: IOIPSL/trunk/ins_m_prec

Last change on this file was 4931, checked in by jgipsl, 20 months ago

Copied ins_m_prec from modipsl/util into IOIPSL/trunk folder. Adapt the script for the path to def.prec file. Launch this script from makeioipsl_fcm.

This has been done to make the compilation script makeioipsl_fcm independent of script in util folder. In the standard method using a main Makefile created by ins_make: ins_m_prec is launched by ins_make which is launched my model script in util. Now when using a main compilation script, ins_make is not needed anymore.

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 2.3 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=$(dirname ${0}); b_n=$(basename ${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_b='src/def.prec'
74[[ ! -f "${dp_b}" ]] && { echo "${dp_b} unreachable ..."; exit 3; }
75sed -e "s/i_std=i_?/i_std=i_${x_i}/" \
76    -e "s/r_std=r_?/r_std=r_${x_r}/" ${dp_b} > wmpf.$$;
77#-
78# Create the module "defprec.f90" or update it
79# if the default precision has been modified
80#-
81dp_p='src/defprec.f90';
82diff -q wmpf.$$ ${dp_p} > /dev/null 2>&1; r_c=${?};
83[[ ${r_c} != 0 ]] && cp -p wmpf.$$ ${dp_p};
84[[ ${x_v} = 'verbose' ]] && \
85 { echo " ";
86  { [[ ${r_c} = 0 ]] && echo ${dp_p} 'already up to date'; } || \
87  { [[ ${r_c} = 1 ]] && echo 'Update '${dp_p}; } || \
88  { [[ ${r_c} = 2 ]] && echo 'Create '${dp_p}; }
89  echo " "; }
90#-
91unset dp_b dp_p x_v x_i x_r; rm -f wmpf.$$;
92#-
93exit 0;
Note: See TracBrowser for help on using the repository browser.