source: modipsl/trunk/util/ins_script @ 293

Last change on this file since 293 was 293, checked in by bellier, 16 years ago

JB: modified a ksh command, not equivalent in ksh93

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 6.3 KB
Line 
1#!/bin/ksh
2# $Id$
3#---------------------------------------------------------------------
4#- Installation de scripts de lancement d experiences propres a un environnement
5#---------------------------------------------------------------------
6d_n=$(dirname ${0}); b_n=$(basename ${0});
7
8#- Saisie et validation des options
9x_v='silencious';
10x_d='normal';
11x_t="";
12x_n="";
13
14while getopts :hvd:t:n: V
15  do
16    case $V in
17      (h)  echo "Usage    : "${b_n} \
18                " [-h] [-v] [-d] [-t h]  [-n f]";
19           echo " -h       : help";
20           echo " -v       : verbose mode";
21           echo " -d       : debug mode";
22           echo " -t h     : target host_name";
23           echo " -n f     : Name";
24           echo "Defaults  : -t local_host";
25           exit 0;;
26      (v)  x_v='verbose';;
27      (d)  x_d='debug';;
28      (t)  x_t=${OPTARG};;
29      (n)  x_n=${OPTARG};;
30      (:)  echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
31           exit 2;;
32      (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
33           exit 2;;
34    esac
35  done
36shift $(($OPTIND-1));
37#- Traitement des options
38#- REAL precision
39#- Target_Host Name
40if [ '\?'${x_t} = '\?' ]; then
41  x_t=`${d_n}/w_i_h`;
42  if [ $? -ne 0 ]; then
43    echo "Bad installation : w_i_h/uname unreachable" 1>&2;
44    exit 1;
45  elif [ "$x_t" = "Unknown" ]; then
46    echo "Local_Host not supported" 1>&2;
47    exit 1;
48  fi;
49fi;
50
51if   [ "$x_t" = "sx8brodie" ]; then
52   b_n_atlas=$(basename $HOME)
53   d_n_atlas=$(dirname $HOME | sed 's/home/u/')
54elif [ "$x_t" = "aix" ]; then
55   b_n_atlas=$LOGIN
56   d_n_atlas="/u/"$(dirname $HOME | awk -F\/ '{print $3"/"$4}')
57elif [ "$x_t" = "fjvpp" ]; then
58   b_n_atlas=$(basename $DMFDIR)
59   d_n_atlas=\/$(dirname $DMFDIR | awk -F\/ '{print $4}')
60elif [ "$x_t" = "sx6nec" ]; then
61   b_n_atlas=$(basename $DMFDIR)
62   d_n_atlas=$(dirname $DMFDIR)
63elif [ "$x_t" = "sx8mercure" ]; then
64   b_n_atlas=$(basename $DMFDIR)
65   d_n_atlas=$(dirname $DMFDIR)
66else
67echo "        !!! WARNING !!!"
68echo " The path for the output files on the storage server,"
69echo " needed for the descriptor files, is not automaticaly set."
70echo " Please specify manually this path by replacing the AAAAAAA"
71echo " string in the Output Job with the desired path."
72echo "        !!! WARNING !!!"
73fi
74
75case ${x_t} in
76  ( aix | cray | fjvpp | linux | lxiv7 | lxiv8 | osf1 | \
77    solaris | t3e | sx8brodie | sx6nec | sx8mercure | unix ) ;;
78  (*)
79    echo "Target_Host "${x_t}" not supported" 1>&2;
80    exit 1;;
81esac
82#-
83x_m=$( (cd $d_n ; pwd) | sed -e "s,/util,," )
84
85if [ ${x_v} = 'verbose' ]; then
86  echo '--- Mode              : '${x_v};
87  echo '--- Compilation       : '${x_d};
88  echo '--- Target            : '${x_t};
89  echo '--- Name              : '${x_n};
90  echo '--- MODIPSL directory : '${x_m};
91fi;
92#-
93#-
94l_rep=`find ${d_n}/.. -name AA_job -print`
95#-
96W_OS=${x_t};
97#
98if   [ ${W_OS}  = "sx8brodie" ]; then
99   format='\s'
100elif [ ${W_OS}  = "aix" ]; then
101   format='\s'
102elif [ ${W_OS}  = "fjvpp" ]; then
103   format='\d'
104elif [ ${W_OS}  = "sx6nec" ]; then
105   format='\s'
106elif [ ${W_OS}  = "sx8mercure" ]; then
107   format='\s'
108else
109echo "        !!! WARNING !!!"
110echo " The display format of numbers,"
111echo " needed for the dates, is not automaticaly set."
112echo " Please specify manually this format by replacing the PPPPPPP"
113echo " string in the Output Job with the desired format."
114echo "        !!! WARNING !!!"
115fi
116echo " ";
117echo "Installation of simple execution jobs for $W_OS";
118echo " ";
119#-
120for i in $l_rep
121do
122  j=${i%/AA_job}
123  MKTR="$j"'/AA_job'
124  Job_name=`( grep '#-Q- '${W_OS}' #@$-r' ${MKTR} || grep '#-Q- '${W_OS}' #PBS -N' ${MKTR} || grep '#-Q- '${W_OS}' #@job_name' ${MKTR} ) | awk -F: '{print $3}'`
125  JN2=`( grep '#-Q- '${W_OS}' #@$-r' ${MKTR} || grep '#-Q- '${W_OS}' #PBS -N' ${MKTR} || grep '#-Q- '${W_OS}' #@job_name' ${MKTR} ) | awk -F: '{print $2}'`
126  JN4=`( grep '#-Q- '${W_OS}' #@$-r' ${MKTR} || grep '#-Q- '${W_OS}' #PBS -N' ${MKTR} || grep '#-Q- '${W_OS}' #@job_name' ${MKTR} ) | awk -F: '{print $4}'`
127  r=$( (cd $j ; pwd) )
128  echo "Installation in directory : $(cd $j ; pwd) ";
129  sed -e "s,MMMMMMM,${x_m}," -e "s,RRRRRRR,${r}," -e "s,AAAAAAA,${d_n_atlas}\/${b_n_atlas},g" ${MKTR}  > jb1.$$
130  W_XX='#-Q- '$W_OS
131  FILE_NAME="";
132
133if [ '\?'${x_n} = '\?' ] && [ '\?'${Job_name} = '\?' ]; then
134    FILE_NAME="$j/Job"
135elif [ '\?'${x_n} = '\?' ] && [ -n "${Job_name}" ] && [ ${Job_name} = XXX ]; then
136    FILE_NAME="$j/Job_LO1"
137elif [ '\?'${x_n} != '\?' ] && [ ${Job_name} = XXX ]; then
138  FILE_NAME="$j/Job_${x_n}"
139elif [ '\?'${x_n} = '\?' ] && [ -n "${Job_name}" ] && [ ${Job_name} != XXX ]; then
140  FILE_NAME="$j/Job_${Job_name}"
141elif [ '\?'${x_n} != '\?' ] && [ ${Job_name} != XXX ]; then
142  FILE_NAME="$j/Job_${x_n}"
143fi
144
145 if [ ! -f "${FILE_NAME}" ]; then
146   case ${FILE_NAME} in
147      "$j/Job") sed -e "s,PPPPPPP,${format},g" -e "s,^$W_XX *,," -e "s,JJJJJJJ,Job," jb1.$$ | grep -v '^#-Q- ' > ${FILE_NAME};;
148      "$j/Job_LO1") sed -e "s,PPPPPPP,${format},g" -e "s,^$W_XX *,," -e "s,XXXXXXX,LO1," -e "s,JJJJJJJ,Job_LO1," -e "s,:${JN2}:,," -e "s,${Job_name},LO1.1,"  -e "s,:${JN4}:,," jb1.$$ | grep -v '^#-Q- ' > ${FILE_NAME};;
149      "$j/Job_${x_n}") sed -e "s,PPPPPPP,${format},g" -e "s,^$W_XX *,," -e "s,XXXXXXX,${x_n}," -e "s,JJJJJJJ,Job_${x_n},"  -e "s,:${JN2}:,," -e "s,${Job_name},${x_n}.1,"  -e "s,:${JN4}:,,"  jb1.$$ | grep -v '^#-Q- ' > ${FILE_NAME};;
150      "$j/Job_${Job_name}") sed -e "s,PPPPPPP,${format},g" -e "s,^$W_XX *,," -e "s,XXXXXXX,${Job_name}," -e "s,JJJJJJJ,Job_${Job_name},"  -e "s,:${JN2}:,," -e "s,${Job_name},${Job_name}.1,"  -e "s,:${JN4}:,," jb1.$$ | grep -v '^#-Q- ' > ${FILE_NAME};;
151   esac
152   chmod 755 ${FILE_NAME}
153 else
154        echo " "
155        echo "WARNING : The file ${FILE_NAME} already exists, "
156        echo "WARNING : installation was not completed correctly "
157        echo "WARNING :       !!! NO FILE REPLACED !!!"
158        echo "WARNING : use parameter -n new_name to obtain Job_new_name script file"
159        echo "WARNING :   for example : ins_script -n LP1  "
160        echo " "
161   rm -f jb1.$$ 
162   exit 0;   
163 fi
164echo "Installation in file : `echo ${FILE_NAME} | sed -e 's,/.*/,,' ` ";
165 
166#-$$ Introduire ici la selection de la technique de communication
167#-$$ pour OASIS (prefixe #-C- )
168done
169#-
170rm -f jb1.$$ 
171#-
172#-$$ launch ins_post if at least one post-processing utility exists
173#-$$
174OK_POST=`find ${d_n}/.. -name da2st`
175if [ -n "$OK_POST" ]; then
176${d_n}/ins_post -t ${x_t}
177fi
178exit 0;
Note: See TracBrowser for help on using the repository browser.