Ignore:
Timestamp:
09/04/09 13:27:47 (15 years ago)
Author:
bellier
Message:

New version with environmental management

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modipsl/trunk/util/ins_make

    r294 r728  
    1 #!/bin/ksh 
     1#!/bin/bash 
    22# $Id$ 
    33#--------------------------------------------------------------------- 
    44#- Installation of Makefiles according to an environment 
    55#--------------------------------------------------------------------- 
     6shopt -s extglob 
     7#- 
    68function ins_make_Usage 
    79{ 
    8 typeset -L13 h_n; typeset v0 v1 v2 v3 v4 v5 v6 v7; 
    9 print - " 
     10typeset v0 v1 v2 v3 v4 v5 v6 v7 h_n; 
     11echo -e " 
    1012ins_make install the Makefile in the directories 
    1113 
     
    2729  ins_make -t sx8brodie 
    2830" 
    29 print - "Supported targets :\n" 
    30 [[ ! -f "${MKTG}" ]] && { print - "? (${MKTG} unreachable)\n"; exit 3; } 
     31echo -e "Supported targets :\n" 
     32[[ ! -f "${MKTG}" ]] && { echo -e "? (${MKTG} unreachable)\n"; exit 3; } 
    3133while read v1 v2 v3 v4 v5 v6 v7 
    3234  do 
    3335    [[ -n "${v1}" && "${v1}${v3}" = '#-Q-#-'                       && \ 
    3436       -n "${v4}" && "${v4}${v5}${v6}" = 'Globaldefinitionsfor' ]] && \ 
    35      { h_n=${v2}; print - "${h_n} : ${v7}"; } 
     37     { h_n=${v2}'           '; echo -e "${h_n:0:13} : ${v7}"; } 
    3638  done <${MKTG} 
    37 print - " 
    38 Fot other targets, look in ${MKTG}. 
     39echo -e " 
     40For other targets, look in ${MKTG}. 
    3941" 
    4042} 
     
    4345#- File containing global definitions 
    4446MKTG=${d_n}'/AA_make.gdef' 
     47 
    4548#- Retrieving and validation of the options 
    4649x_v='silencious'; x_d='normal'; x_p="??"; x_t="??"; x_m='??'; 
     
    8487      { echo "Local_Host not supported" 1>&2; exit 1; }; } 
    8588#- 
     89# Get editing header 
     90x_h=$(${d_n}/w_i_p ${x_t}); 
     91#- 
    8692[[ ! -f "${MKTG}" ]] && { echo "${MKTG} unreachable ..."; exit 3; } 
    8793#- 
    88 W_XX=$(sed -n -e "s/^#-Q-  *\(${x_t}\)[\t ].*$/\1/p" ${MKTG} | sort -u); 
    89 [[ '\?'"${W_XX}" != '\?'"${x_t}" ]] && \ 
     94W_X1=$(sed -n -e "s/^#-Q-  *\(${x_h}\)[\t ].*$/\1/p" ${MKTG} | sort -u); 
     95[[ '\?'"${W_X1}" != '\?'"${x_h}" ]] && \ 
    9096  { echo "Target_Host  "${x_t}"  not supported" 1>&2; exit 1; } 
    9197#- 
     
    103109   echo '--- MPI context  : '${x_m}; } 
    104110#- 
    105 echo ""; echo "Installation of makefiles for ${x_t}"; echo ""; 
     111echo ""; 
     112echo "Installation of makefiles, scripts and data for ${x_t}"; 
     113echo ""; 
    106114#- 
    107 l_rep=$(find ${d_n}/.. -name AA_make -print) 
     115w_t='AA_make'; 
     116l_rep=$(cd ${d_n};find .. -name ${w_t} -print) 
    108117for i in ${l_rep} 
    109118do 
    110   j=${i%/AA_make}; 
     119  k=${i%/${w_t}}; k=${k#./}; j=${d_n}'/'${k}; j=${j#./}; 
    111120  echo "Installation in ${j}"; 
    112121  MKTL="${j}"'/AA_make.ldef'; 
     
    114123  MKTR="${j}"'/AA_make'; 
    115124  cat ${MKTL} ${MKTG} ${MKTR} > mk1.$$; 
    116   W_PR='#-Q-  *'; W_XX=${W_PR}${x_t}; 
    117   sed -e "/^${W_XX}[\t ]/ s/^${W_XX} *//" -e "/^${W_PR}/d" mk1.$$ > mk2.$$; 
     125  W_PR='#-Q-  *'; W_X1=${W_PR}${x_h}; 
     126  sed -e "/^${W_X1}[\t ]/ s/^${W_X1} *//" -e "/^${W_PR}/d" mk1.$$ > mk2.$$; 
    118127#- 
    119128# Default INTEGER and REAL precision 
    120   W_PR='#-P- '; W_XX=${W_PR}${x_p}; 
    121   sed -e "/^${W_XX} */ s///" -e "/^${W_PR}/d" mk2.$$ > mk1.$$; 
     129  W_PR='#-P- '; W_X1=${W_PR}${x_p}; 
     130  sed -e "/^${W_X1} */ s///" -e "/^${W_PR}/d" mk2.$$ > mk1.$$; 
    122131#- 
    123132# Handle the precision module "defprec.f90" in "IOIPSL/src" 
    124133  [[ '!!'${j##*/modeles} = '!!/IOIPSL/src' ]] && \ 
    125    { [[ ${x_v} = 'verbose' ]] && W_XX='-v' || W_XX=""; 
    126      ${d_n}/ins_m_prec ${W_XX} -i ${w_ip} -r ${w_rp}; r_c=${?}; 
     134   { [[ ${x_v} = 'verbose' ]] && W_X1='-v' || W_X1=""; 
     135     ${d_n}/ins_m_prec ${W_X1} -i ${w_ip} -r ${w_rp}; r_c=${?}; 
    127136     unset w_ip w_rp; 
    128137     [[ ${r_c} != 0 ]] && exit ${r_c}; } 
     
    130139# Debug 
    131140  W_PR='#-D- '; 
    132   [[ ${x_d} = 'debug' ]] && W_XX=${W_PR}'MD' || W_XX=${W_PR}'MN'; 
    133   sed -e "/^${W_XX} */ s///" -e "/^${W_PR}/d" mk1.$$ > mk2.$$; 
     141  [[ ${x_d} = 'debug' ]] && W_X1=${W_PR}'MD' || W_X1=${W_PR}'MN'; 
     142  sed -e "/^${W_X1} */ s///" -e "/^${W_PR}/d" mk1.$$ > mk2.$$; 
    134143#- 
    135 # Retrieve the path of the directory 
    136   mk_dir=$(cd ${j};/bin/pwd;) 
    137   W_XX='MAKE_DIR =' 
    138 # Update the value 
    139   sed -e "s!^${W_XX}.*!${W_XX} ${mk_dir}!" mk2.$$ > mk1.$$ 
    140   unset mk_dir; 
     144# Retrieve the path of the Makefile directory 
     145# and the path from the directory to modipsl/util 
     146  mk_dir=$(cd ${j};/bin/pwd;); 
     147  ut_dir=''; for ww in ${k//\//' '}; do ut_dir=${ut_dir}'../'; done 
     148  ut_dir=${ut_dir%'../'}'util'; 
     149  echo "Path from Makefile to modipsl/util : ${ut_dir}"; 
     150# Update the values 
     151  W_X1='UTIL_DIR ='; W_X2='MAKE_DIR ='; 
     152  sed -e "s!^${W_X1}.*!${W_X1} ${ut_dir}!" \ 
     153      -e "s!^${W_X2}.*!${W_X2} ${mk_dir}!" \ 
     154      mk2.$$ > mk1.$$ 
     155  unset mk_dir ut_dir; 
    141156#- 
    142157# Choice of mpi library for the coupling 
    143   W_XX='LIB_MPI ='; W_XX_BIS='LIB_MPI_BIS ='; 
     158  W_X1='LIB_MPI ='; W_X2='LIB_MPI_BIS ='; 
    144159  case ${x_m} in 
    145160   ( mpi1 | MPI1 ) 
    146161    lib_mpi='MPI1'; lib_mpi_bis='MPI1'; 
    147     sed -e "s!^${W_XX}.*!${W_XX} ${lib_mpi}!" \ 
    148         -e "s!^${W_XX_BIS}.*!${W_XX_BIS} ${lib_mpi_bis}!" \ 
     162    sed -e "s!^${W_X1}.*!${W_X1} ${lib_mpi}!" \ 
     163        -e "s!^${W_X2}.*!${W_X2} ${lib_mpi_bis}!" \ 
    149164      mk1.$$ > ${j}/Makefile;; 
    150165   ( mpi2 | MPI2 ) 
    151166    lib_mpi='MPI2'; lib_mpi_bis=''; 
    152     sed -e "s!^${W_XX}.*!${W_XX} ${lib_mpi}!" \ 
    153         -e "s!^${W_XX_BIS}.*!${W_XX_BIS} ${lib_mpi_bis}!" \ 
     167    sed -e "s!^${W_X1}.*!${W_X1} ${lib_mpi}!" \ 
     168        -e "s!^${W_X2}.*!${W_X2} ${lib_mpi_bis}!" \ 
    154169      mk1.$$ > ${j}/Makefile;; 
    155170   (??)  
     
    158173  esac 
    159174  unset lib_mpi lib_mpi_bis; 
     175#- 
    160176done 
    161177#- 
     178# Creating environment file  
     179echo ${x_t} > ${d_n}/.host_target 
     180#- 
    162181echo ""; 
    163 unset W_XX W_XX_BIS; rm -f mk1.$$ mk2.$$; 
     182unset W_X1 W_X2 w_t; rm -f mk1.$$ mk2.$$; 
    164183#- 
    165184exit 0; 
Note: See TracChangeset for help on using the changeset viewer.