source: modipsl/trunk/util/ins_script @ 400

Last change on this file since 400 was 400, checked in by mafoipsl, 16 years ago

First implementation for vargas : AIX6 and ax6_mono
Not fully tested.

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 6.5 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" -o "$x_t" = "aix6" ]; then
55   b_n_atlas=$LOGIN
56   d_n_atlas="/u/"$(dirname $HOME | awk -F\/ '{print $3"/"$4}')
57elif [ "$x_t" = "babel" ]; then
58   b_n_atlas=$LOGIN
59   d_n_atlas="/u/"$(dirname $HOME | awk -F\/ '{print $3"/"$4}')
60elif [ "$x_t" = "fjvpp" ]; then
61   b_n_atlas=$(basename $DMFDIR)
62   d_n_atlas=\/$(dirname $DMFDIR | awk -F\/ '{print $4}')
63elif [ "$x_t" = "sx6nec" ]; then
64   b_n_atlas=$(basename $DMFDIR)
65   d_n_atlas=$(dirname $DMFDIR)
66elif [ "$x_t" = "sx8mercure" ]; then
67   b_n_atlas=$(basename $DMFDIR)
68   d_n_atlas=$(dirname $DMFDIR)
69else
70echo "        !!! WARNING !!!"
71echo " The path for the output files on the storage server,"
72echo " needed for the descriptor files, is not automaticaly set."
73echo " Please specify manually this path by replacing the AAAAAAA"
74echo " string in the Output Job with the desired path."
75echo "        !!! WARNING !!!"
76fi
77
78case ${x_t} in
79  ( aix* | babel | cray | fjvpp | linux | lxiv7 | lxiv8 | osf1 | \
80    solaris | t3e | sx8brodie | sx6nec | sx8mercure | unix ) ;;
81  (*)
82    echo "Target_Host "${x_t}" not supported" 1>&2;
83    exit 1;;
84esac
85#-
86x_m=$( (cd $d_n ; pwd) | sed -e "s,/util,," )
87
88if [ ${x_v} = 'verbose' ]; then
89  echo '--- Mode              : '${x_v};
90  echo '--- Compilation       : '${x_d};
91  echo '--- Target            : '${x_t};
92  echo '--- Name              : '${x_n};
93  echo '--- MODIPSL directory : '${x_m};
94fi;
95#-
96#-
97l_rep=`find ${d_n}/.. -name AA_job -print`
98#-
99W_OS=${x_t};
100#
101if   [ ${W_OS}  = "sx8brodie" ]; then
102   format='\s'
103elif [ ${W_OS}  = "aix" -o ${W_OS}  = "aix6" ]; then
104   format='\s'
105elif [ ${W_OS}  = "babel" ]; then
106   format='\s'
107elif [ ${W_OS}  = "fjvpp" ]; then
108   format='\d'
109elif [ ${W_OS}  = "sx6nec" ]; then
110   format='\s'
111elif [ ${W_OS}  = "sx8mercure" ]; then
112   format='\s'
113else
114echo "        !!! WARNING !!!"
115echo " The display format of numbers,"
116echo " needed for the dates, is not automaticaly set."
117echo " Please specify manually this format by replacing the PPPPPPP"
118echo " string in the Output Job with the desired format."
119echo "        !!! WARNING !!!"
120fi
121echo " ";
122echo "Installation of simple execution jobs for $W_OS";
123echo " ";
124#-
125for i in $l_rep
126do
127  j=${i%/AA_job}
128  MKTR="$j"'/AA_job'
129  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}'`
130  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}'`
131  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}'`
132  r=$( (cd $j ; pwd) )
133  echo "Installation in directory : $(cd $j ; pwd) ";
134  sed -e "s,MMMMMMM,${x_m}," -e "s,RRRRRRR,${r}," -e "s,AAAAAAA,${d_n_atlas}\/${b_n_atlas},g" ${MKTR}  > jb1.$$
135  W_XX='#-Q- '$W_OS
136  FILE_NAME="";
137
138if [ '\?'${x_n} = '\?' ] && [ '\?'${Job_name} = '\?' ]; then
139    FILE_NAME="$j/Job"
140elif [ '\?'${x_n} = '\?' ] && [ -n "${Job_name}" ] && [ ${Job_name} = XXX ]; then
141    FILE_NAME="$j/Job_LO1"
142elif [ '\?'${x_n} != '\?' ] && [ ${Job_name} = XXX ]; then
143  FILE_NAME="$j/Job_${x_n}"
144elif [ '\?'${x_n} = '\?' ] && [ -n "${Job_name}" ] && [ ${Job_name} != XXX ]; then
145  FILE_NAME="$j/Job_${Job_name}"
146elif [ '\?'${x_n} != '\?' ] && [ ${Job_name} != XXX ]; then
147  FILE_NAME="$j/Job_${x_n}"
148fi
149
150 if [ ! -f "${FILE_NAME}" ]; then
151   case ${FILE_NAME} in
152      "$j/Job") sed -e "s,PPPPPPP,${format},g" -e "s,^$W_XX *,," -e "s,JJJJJJJ,Job," jb1.$$ | grep -v '^#-Q- ' > ${FILE_NAME};;
153      "$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};;
154      "$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};;
155      "$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};;
156   esac
157   chmod 755 ${FILE_NAME}
158 else
159        echo " "
160        echo "WARNING : The file ${FILE_NAME} already exists, "
161        echo "WARNING : installation was not completed correctly "
162        echo "WARNING :       !!! NO FILE REPLACED !!!"
163        echo "WARNING : use parameter -n new_name to obtain Job_new_name script file"
164        echo "WARNING :   for example : ins_script -n LP1  "
165        echo " "
166   rm -f jb1.$$ 
167   exit 0;   
168 fi
169echo "Installation in file : `echo ${FILE_NAME} | sed -e 's,/.*/,,' ` ";
170 
171#-$$ Introduire ici la selection de la technique de communication
172#-$$ pour OASIS (prefixe #-C- )
173done
174#-
175rm -f jb1.$$ 
176#-
177#-$$ launch ins_post if at least one post-processing utility exists
178#-$$
179OK_POST=`find ${d_n}/.. -name da2st`
180if [ -n "$OK_POST" ]; then
181${d_n}/ins_post -t ${x_t}
182fi
183exit 0;
Note: See TracBrowser for help on using the repository browser.