Changeset 12 for modipsl/trunk/util/ins_make
- Timestamp:
- 03/12/07 17:13:47 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modipsl/trunk/util/ins_make
r2 r12 1 1 #!/bin/ksh 2 # $Id : ins_make,v 2.19 2006/01/18 05:59:17 adm Exp$2 # $Id$ 3 3 #--------------------------------------------------------------------- 4 4 #- Installation of Makefiles according to an environment 5 5 #--------------------------------------------------------------------- 6 b_n=$(basename $0) 7 d_n=$(dirname $0) 6 function ins_make_Usage 7 { 8 echo " 9 ins_make install the Makefile in the directories 10 11 Usage : 12 ${b_n} [-h] [-v] [-d] [-p r] [-t h] [-m m] 13 14 Options : 15 -h : help 16 -v : verbose mode 17 -d : debug mode 18 -p p : int and real precision I4R4/I4R8/I8R8/4/8 19 -t h : target host_name 20 -m m : mpi context choosen for the coupling MPI1/MPI2 21 22 Defaults : 23 -t local_host -p I4R8 24 25 Example for remote host compilation : 26 ins_make -t sx8brodie 27 " 28 } 29 #- dirname and basename 30 d_n=${0%/*}; b_n=${0##*/}; 8 31 #- Retrieving and validation of the options 9 x_v='silencious'; 10 x_d='normal'; 11 x_p=""; 12 x_t=""; 13 x_m='??'; 32 x_v='silencious'; x_d='normal'; x_p="??"; x_t="??"; x_m='??'; 14 33 while getopts :hvdp:m:t: V 15 34 do 16 case $V in 17 (h) echo "Usage : "${b_n} \ 18 " [-h] [-v] [-d] [-p r] [-t h] "; 19 echo " -h : help"; 20 echo " -v : verbose mode"; 21 echo " -t h : target host_name"; 22 echo " -d : debug mode"; 23 echo " -p p : int and real precision I4R4/I4R8/I8R8/4/8"; 24 echo " -m m : mpi context choosen for the coupling MPI1/MPI2"; 25 echo ""; 26 echo "Example for remote host compilation "; 27 echo "ins_make -t sxnec"; 28 echo ""; 29 echo "Defaults : -t local_host"; 30 echo ""; 31 exit 0;; 32 (v) x_v='verbose';; 33 (d) x_d='debug';; 34 (p) x_p=${OPTARG};; 35 (t) x_t=${OPTARG};; 36 (m) x_m=${OPTARG};; 37 (:) echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2; 38 exit 2;; 39 (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2; 40 exit 2;; 41 esac 35 case ${V} in 36 (h) ins_make_Usage; exit 0;; 37 (v) x_v='verbose';; 38 (d) x_d='debug';; 39 (p) x_p=${OPTARG};; 40 (t) x_t=${OPTARG};; 41 (m) x_m=${OPTARG};; 42 (:) echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2; 43 exit 2;; 44 (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2; 45 exit 2;; 46 esac 42 47 done 43 48 shift $(($OPTIND-1)); … … 47 52 # Default INTEGER and REAL precision 48 53 case ${x_p} in 49 ( I4R4 | I4R8 | I8R8 ) ;; 50 ( 4 ) x_p='I4R4';; 51 ( 8 ) x_p='I8R8';; 52 ("") x_p='??';; 53 (*) 54 echo 'Invalid precision ' 1>&2; 55 echo ${x_p}' (must be I4R4, I4R8, I8R8, 4 or 8)' 1>&2; 56 exit 1;; 54 ( I4R4 | 4 ) x_p='I4R4'; w_ip='4'; w_rp='4';; 55 ( I4R8 | ?? ) x_p='I4R8'; w_ip='4'; w_rp='8';; 56 ( I8R8 | 8 ) x_p='I8R8'; w_ip='8'; w_rp='8';; 57 (*) 58 echo 'Invalid precision ' 1>&2; 59 echo ${x_p}' (must be I4R4, I4R8, I8R8, 4 or 8)' 1>&2; 60 exit 1;; 57 61 esac 58 62 #- 59 63 # Target_Host Name 60 if [ '\?'${x_t} = '\?' ]; then 61 x_t=`${d_n}/w_i_h`; 62 if [ $? -ne 0 ]; then 63 echo "Bad installation : w_i_h/uname unreachable" 1>&2; 64 exit 1; 65 elif [ "$x_t" = "Unknown" ]; then 66 echo "Local_Host not supported" 1>&2; 67 exit 1; 68 fi; 69 fi; 70 case ${x_t} in 71 (aix | ax_mono | cray | Darwin | fjvpp | g95 | eshpux | \ 72 linux | lxiv7 | lxiv8 | osf1 | osxxlf | sgi6 | \ 73 solaris | sxdkrz | sxnec | sx6nec | t3e | tx7 | unix) ;; 74 (*) 75 echo "Target_Host "${x_t}" not supported" 1>&2; 76 exit 1;; 64 [[ ${x_t} = '??' ]] && \ 65 { x_t=$(${d_n}/w_i_h); 66 { [[ ${?} != 0 ]] && \ 67 { echo "Bad installation : w_i_h/uname unreachable" 1>&2; 68 exit 1; }; } || \ 69 [[ ${x_t} = "Unknown" ]] && \ 70 { echo "Local_Host not supported" 1>&2; exit 1; }; } 71 #- 72 MKTG=${d_n}'/AA_make.gdef' 73 [[ ! -f "${MKTG}" ]] && { echo "${MKTG} unreachable ..."; exit 3; } 74 #- 75 W_XX=$(sed -n -e "s/^#-Q- *\([^ ]*\).*$/\1/p" ${MKTG} | \ 76 sort -u | sed -e "/${x_t}/!d"); 77 [[ '\?'"${W_XX}" != '\?'${x_t} ]] && \ 78 { echo "Target_Host "${x_t}" not supported" 1>&2; exit 1; } 79 #- 80 case ${x_m} in 81 ( mpi1 | mpi2 | MPI1 | MPI2 | ?? );; 82 (*) echo "MPI context "${x_m}" not supported" 1>&2; exit 1;; 77 83 esac 78 84 #- 79 case ${x_m} in 80 ( mpi1 | mpi2 | MPI1 | MPI2 | ??) ;; 81 (*) 82 echo "MPI context "${x_m}" not supported" 1>&2; 83 exit 1;; 84 esac 85 [[ ${x_v} = 'verbose' ]] && \ 86 { echo ""; 87 echo '--- Mode : '${x_v}; 88 echo '--- Compilation : '${x_d}; 89 echo '--- Precision : '${x_p}; 90 echo '--- Target : '${x_t}; 91 echo '--- MPI context : '${x_m}; } 85 92 #- 86 if [ ${x_v} = 'verbose' ]; then 87 echo '--- Mode : '${x_v}; 88 echo '--- Compilation : '${x_d}; 89 echo '--- Precision : '${x_p}; 90 echo '--- Target : '${x_t}; 91 echo '--- MPI context : '${x_m}; 92 fi; 93 echo ""; echo "Installation of makefiles for ${x_t}"; echo ""; 93 94 #- 94 95 l_rep=$(find ${d_n}/.. -name AA_make -print) 95 #- 96 W_OS=${x_t}; 97 echo " "; 98 echo "Installation of makefiles for $W_OS"; 99 echo " "; 100 #- 101 MKTG=${d_n}'/AA_make.gdef' 102 if [ ! -f "$MKTG" ]; then 103 echo "$MKTG unreachable ..." 104 exit 3; 105 fi; 106 #- 107 for i in $l_rep 96 for i in ${l_rep} 108 97 do 109 j=${i%/AA_make} 110 echo "Installation in ${j} ..."; 111 MKTL="${j}"'/AA_make.ldef' 112 if [ ! -f "$MKTL" ]; then 113 echo "$MKTL unreachable ..." 114 exit 3; 115 fi; 116 MKTR="${j}"'/AA_make' 117 cat ${MKTL} ${MKTG} ${MKTR} > mk1.$$ 118 W_XX='#-Q- '$W_OS 119 sed -e "s/^$W_XX *//" mk1.$$ | grep -v '^#-Q- ' > mk2.$$ 98 j=${i%/AA_make}; 99 echo "Installation in ${j}"; 100 MKTL="${j}"'/AA_make.ldef'; 101 [[ ! -f "${MKTL}" ]] && { echo "${MKTL} unreachable ..."; exit 3; } 102 MKTR="${j}"'/AA_make'; 103 cat ${MKTL} ${MKTG} ${MKTR} > mk1.$$; 104 W_PR='#-Q- '; W_XX=${W_PR}${x_t}; 105 sed -e "/^${W_XX} */ s///" -e "/^${W_PR}/d" mk1.$$ > mk2.$$; 120 106 #- 121 107 # Default INTEGER and REAL precision 122 if [ ${x_p} = 'I4R4' ]; then 123 W_XX='#-P- I4R4' 124 elif [ ${x_p} = 'I4R8' ]; then 125 W_XX='#-P- I4R8' 126 elif [ ${x_p} = 'I8R8' ]; then 127 W_XX='#-P- I8R8' 128 else 129 W_XX='#-P- ??' 130 fi 131 sed -e "s/^$W_XX *//" mk2.$$ | grep -v '^#-P- ' > mk1.$$ 108 W_PR='#-P- '; W_XX=${W_PR}${x_p}; 109 sed -e "/^${W_XX} */ s///" -e "/^${W_PR}/d" mk2.$$ > mk1.$$; 132 110 #- 133 # Remove the module "defprec.f90" 134 # if the default precision has (eventually) been modified 135 if [ '!!'${j##*/modeles} = '!!/IOIPSL/src' ]; then 136 dp_n=${d_n}'/../modeles/IOIPSL/src/defprec.f90'; 137 if [ -f ${dp_n} ]; then 138 W_NEW=$(grep 'D_P =' mk1.$$ | tail -1 | sed "s/D_P = //") 139 if [ -f ${j}/Makefile ]; then 140 W_OLD=$(grep 'D_P =' ${j}/Makefile | tail -1 | sed "s/D_P = //") 141 else 142 W_OLD='!??!' 143 fi 144 if [ ${W_OLD} != ${W_NEW} ]; then 145 echo 'Remove '${dp_n}; 146 rm -f ${dp_n}; 147 fi 148 unset W_NEW W_OLD; 149 fi 150 unset dp_n; 151 fi 111 # Handle the precision module "defprec.f90" in "IOIPSL/src" 112 [[ '!!'${j##*/modeles} = '!!/IOIPSL/src' ]] && \ 113 { [[ ${x_v} = 'verbose' ]] && W_XX='-v' || W_XX=""; 114 ${d_n}/ins_m_prec ${W_XX} -i ${w_ip} -r ${w_rp}; r_c=${?}; 115 unset w_ip w_rp; 116 [[ ${r_c} != 0 ]] && exit ${r_c}; } 152 117 #- 153 118 # Debug 154 if [ ${x_d} = 'debug' ]; then 155 W_XX='#-D- MD' 156 else 157 W_XX='#-D- MN' 158 fi 159 sed -e "s/^$W_XX *//" mk1.$$ | grep -v '^#-D- ' > mk2.$$ 119 W_PR='#-D- '; 120 [[ ${x_d} = 'debug' ]] && W_XX=${W_PR}'MD' || W_XX=${W_PR}'MN'; 121 sed -e "/^${W_XX} */ s///" -e "/^${W_PR}/d" mk1.$$ > mk2.$$; 160 122 #- 161 123 # Retrieve the path of the directory … … 167 129 #- 168 130 # Choice of mpi library for the coupling 169 W_XX='LIB_MPI =' 170 W_XX_BIS='LIB_MPI_BIS =' 171 #- 172 case ${x_m} in 173 ( mpi1 | MPI1 ) 174 lib_mpi='MPI1' 175 lib_mpi_bis='MPI1' 131 W_XX='LIB_MPI ='; W_XX_BIS='LIB_MPI_BIS ='; 132 case ${x_m} in 133 ( mpi1 | MPI1 ) 134 lib_mpi='MPI1'; lib_mpi_bis='MPI1'; 176 135 sed -e "s!^${W_XX}.*!${W_XX} ${lib_mpi}!" \ 177 -e "s!^${W_XX_BIS}.*!${W_XX_BIS} ${lib_mpi_bis}!" mk1.$$ > ${j}/Makefile ;;178 ( mpi2 | MPI2 )179 lib_mpi='MPI2'180 lib_mpi _bis=''136 -e "s!^${W_XX_BIS}.*!${W_XX_BIS} ${lib_mpi_bis}!" \ 137 mk1.$$ > ${j}/Makefile;; 138 ( mpi2 | MPI2 ) 139 lib_mpi='MPI2'; lib_mpi_bis=''; 181 140 sed -e "s!^${W_XX}.*!${W_XX} ${lib_mpi}!" \ 182 -e "s!^${W_XX_BIS}.*!${W_XX_BIS} ${lib_mpi_bis}!" mk1.$$ > ${j}/Makefile ;; 183 (??) 184 cp mk1.$$ ${j}/Makefile ;; 185 (*) ;; 186 esac 187 unset lib_mpi; 188 unset lib_mpi_bis; 189 #- 141 -e "s!^${W_XX_BIS}.*!${W_XX_BIS} ${lib_mpi_bis}!" \ 142 mk1.$$ > ${j}/Makefile;; 143 (??) 144 cp mk1.$$ ${j}/Makefile;; 145 (*) ;; 146 esac 147 unset lib_mpi lib_mpi_bis; 190 148 done 191 149 #- 192 rm -f mk1.$$ mk2.$$ 150 echo ""; 151 unset W_XX W_XX_BIS; rm -f mk1.$$ mk2.$$; 193 152 #- 194 153 exit 0; 195 196 197 198 199 200 201
Note: See TracChangeset
for help on using the changeset viewer.