source: modipsl/trunk/util/ins_script @ 15

Last change on this file since 15 was 13, checked in by bellier, 18 years ago

JB: Id added

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