source: modipsl/tags/v2_1_1/util/ins_script

Last change on this file was 49, checked in by bellier, 18 years ago

JB:

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