source: modipsl/branches/v_dev_module/util/ins_script @ 657

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