New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
ins_make in tags/nemo_v3_2/nemo_v3_2/NVTK/INSTALL/MODIPSL_FILES – NEMO

source: tags/nemo_v3_2/nemo_v3_2/NVTK/INSTALL/MODIPSL_FILES/ins_make @ 1878

Last change on this file since 1878 was 1878, checked in by flavoni, 14 years ago

initial test for nemogcm

File size: 5.5 KB
Line 
1#!/bin/bash
2# $Id: ins_make 1754 2009-11-25 13:28:24Z rblod $
3#---------------------------------------------------------------------
4#- Installation of Makefiles according to an environment
5#---------------------------------------------------------------------
6shopt -s extglob
7#-
8function ins_make_Usage
9{
10typeset v0 v1 v2 v3 v4 v5 v6 v7 h_n;
11echo -e "
12ins_make install the Makefile in the directories
13
14Usage :
15  ${b_n} [-h] [-v] [-d] [-p r] [-t h] [-w w] [-m m]
16
17Options :
18  -h   : help
19  -v   : verbose mode
20  -d   : debug mode
21  -p p : int and real precision I4R4/I4R8/I8R8/4/8
22  -t h : target host_name
23  -w w : directory Where to install the Makefile (recursive)
24  -m m : mpi context choosen for the coupling MPI1/MPI2
25
26Defaults :
27   -t local_host -p I4R8
28
29Example for remote host compilation :
30  ins_make -t sx8brodie
31"
32echo -e "Supported targets :\n"
33[[ ! -f "${MKTG}" ]] && { echo -e "? (${MKTG} unreachable)\n"; exit 3; }
34while read v1 v2 v3 v4 v5 v6 v7
35  do
36    [[ -n "${v1}" && "${v1}${v3}" = '#-Q-#-'                       && \
37       -n "${v4}" && "${v4}${v5}${v6}" = 'Globaldefinitionsfor' ]] && \
38     { h_n=${v2}'           '; echo -e "${h_n:0:13} : ${v7}"; }
39  done <${MKTG}
40echo -e "
41For other targets, look in ${MKTG}.
42"
43}
44#-    dirname     and      basename
45d_n=$(dirname ${0}); b_n=$(basename ${0});
46#- File containing global definitions
47MKTG=${d_n}'/AA_make.gdef'
48
49#- Retrieving and validation of the options
50x_v='silencious'; x_d='normal'; x_p="??"; x_t="??"; x_w="??"; x_m='??';
51while getopts :hvdp:m:t:w: V
52  do
53   case ${V} in
54    (h)  ins_make_Usage; exit 0;;
55    (v)  x_v='verbose';;
56    (d)  x_d='debug';;
57    (p)  x_p=${OPTARG};;
58    (t)  x_t=${OPTARG};;
59    (w)  x_w=${OPTARG};;
60    (m)  x_m=${OPTARG};;
61    (:)  echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
62         exit 2;;
63    (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
64         exit 2;;
65   esac
66  done
67shift $(($OPTIND-1));
68#-
69# Treatment of the options
70#-
71# Default INTEGER and REAL precision
72case ${x_p} in
73 ( I4R4 | 4 )  x_p='I4R4'; w_ip='4'; w_rp='4';;
74 ( I4R8 | ?? ) x_p='I4R8'; w_ip='4'; w_rp='8';;
75 ( I8R8 | 8 )  x_p='I8R8'; w_ip='8'; w_rp='8';;
76 (*)
77   echo 'Invalid precision ' 1>&2;
78   echo ${x_p}' (must be I4R4, I4R8, I8R8, 4 or 8)' 1>&2;
79   exit 1;;
80esac
81#-
82# Target_Host Name
83[[ ${x_t} = '??' ]] && \
84 { x_t=$(${d_n}/w_i_h);
85   { [[ ${?} != 0 ]] && \
86      { echo "Bad installation : w_i_h/uname unreachable" 1>&2;
87        exit 1; }; } || \
88     [[ ${x_t} = "Unknown" ]] && \
89      { echo "Local_Host not supported" 1>&2; exit 1; }; }
90#-
91# Get editing header
92#x_h=$(${d_n}/w_i_p ${x_t});
93x_h=${x_t};
94#-
95[[ ! -f "${MKTG}" ]] && { echo "${MKTG} unreachable ..."; exit 3; }
96#-
97W_X1=$(sed -n -e "s/^#-Q-  *\(${x_h}\)[\t ].*$/\1/p" ${MKTG} | sort -u);
98[[ '\?'"${W_X1}" != '\?'"${x_h}" ]] && \
99  { echo "Target_Host  "${x_t}"  not supported" 1>&2; exit 1; }
100#-
101case ${x_m} in
102 ( mpi1 | mpi2 | MPI1 | MPI2 | ?? );;
103 (*) echo "MPI context "${x_m}" not supported" 1>&2; exit 1;;
104esac
105#-
106[[ ${x_v} = 'verbose' ]] && \
107 { echo "";
108   echo '--- Mode         : '${x_v};
109   echo '--- Compilation  : '${x_d};
110   echo '--- Precision    : '${x_p};
111   echo '--- Target       : '${x_t};
112   echo '--- MPI context  : '${x_m}; }
113#-
114echo "";
115echo "Installation of makefiles, scripts and data for ${x_t}";
116echo "";
117#-
118w_t='AA_make';
119#-
120if [ ${x_w} = '??' ]; then
121l_rep=$(cd ${d_n};find .. -name ${w_t} -print)
122else
123l_rep=$(cd ${d_n};find ../*/${x_w} -name ${w_t} -print)
124fi
125#-
126for i in ${l_rep}
127do
128  k=${i%/${w_t}}; k=${k#./}; j=${d_n}'/'${k}; j=${j#./};
129  echo "Installation in ${j}";
130  MKTL="${j}"'/AA_make.ldef';
131  [[ ! -f "${MKTL}" ]] && { echo "${MKTL} unreachable ..."; exit 3; }
132  MKTR="${j}"'/AA_make';
133  cat ${MKTL} ${MKTG} ${MKTR} > mk1.$$;
134  W_PR='#-Q-  *'; W_X1=${W_PR}${x_h};
135  sed -e "/^${W_X1}[\t ]/ s/^${W_X1} *//" -e "/^${W_PR}/d" mk1.$$ > mk2.$$;
136#-
137# Default INTEGER and REAL precision
138  W_PR='#-P- '; W_X1=${W_PR}${x_p};
139  sed -e "/^${W_X1} */ s///" -e "/^${W_PR}/d" mk2.$$ > mk1.$$;
140#-
141# Handle the precision module "defprec.f90" in "IOIPSL/src"
142  [[ '!!'${j##*/modeles} = '!!/IOIPSL/src' ]] && \
143   { [[ ${x_v} = 'verbose' ]] && W_X1='-v' || W_X1="";
144     ${d_n}/ins_m_prec ${W_X1} -i ${w_ip} -r ${w_rp}; r_c=${?};
145     unset w_ip w_rp;
146     [[ ${r_c} != 0 ]] && exit ${r_c}; }
147#-
148# Debug
149  W_PR='#-D- ';
150  [[ ${x_d} = 'debug' ]] && W_X1=${W_PR}'MD' || W_X1=${W_PR}'MN';
151  sed -e "/^${W_X1} */ s///" -e "/^${W_PR}/d" mk1.$$ > mk2.$$;
152#-
153# Retrieve the path of the Makefile directory
154# and the path from the directory to modipsl/util
155  mk_dir=$(cd ${j};/bin/pwd;);
156  ut_dir=''; for ww in ${k//\//' '}; do ut_dir=${ut_dir}'../'; done
157  ut_dir=${ut_dir%'../'}'util';
158  echo "Path from Makefile to modipsl/util : ${ut_dir}";
159# Update the values
160  W_X1='UTIL_DIR ='; W_X2='MAKE_DIR =';
161  sed -e "s!^${W_X1}.*!${W_X1} ${ut_dir}!" \
162      -e "s!^${W_X2}.*!${W_X2} ${mk_dir}!" \
163      mk2.$$ > mk1.$$
164  unset mk_dir ut_dir;
165#-
166# Choice of mpi library for the coupling
167  W_X1='LIB_MPI ='; W_X2='LIB_MPI_BIS =';
168  case ${x_m} in
169   ( mpi1 | MPI1 )
170    lib_mpi='MPI1'; lib_mpi_bis='MPI1';
171    sed -e "s!^${W_X1}.*!${W_X1} ${lib_mpi}!" \
172        -e "s!^${W_X2}.*!${W_X2} ${lib_mpi_bis}!" \
173      mk1.$$ > ${j}/Makefile;;
174   ( mpi2 | MPI2 )
175    lib_mpi='MPI2'; lib_mpi_bis='';
176    sed -e "s!^${W_X1}.*!${W_X1} ${lib_mpi}!" \
177        -e "s!^${W_X2}.*!${W_X2} ${lib_mpi_bis}!" \
178      mk1.$$ > ${j}/Makefile;;
179   (??) 
180    cp mk1.$$ ${j}/Makefile;;
181   (*) ;;
182  esac
183  unset lib_mpi lib_mpi_bis;
184#-
185done
186#-
187# Creating environment file
188echo ${x_t} > ${d_n}/.host_target
189#-
190echo "";
191unset W_X1 W_X2 w_t; rm -f mk1.$$ mk2.$$;
192#-
193exit 0;
Note: See TracBrowser for help on using the repository browser.