source: palm/trunk/SCRIPTS/subjob @ 1

Last change on this file since 1 was 1, checked in by raasch, 17 years ago

Initial repository layout and content

File size: 36.4 KB
Line 
1#!/bin/ksh
2# subjob - Plot-Shellskript         Version:  @(#)SUBJOB 1.0    28/11/06
3
4     # Prozedur zum automatischen Generieren von Batch-Jobs, die unter NQS
5     # laufen sollen und deren Ergebnis (Dayfile) zum Job-generierenden
6     # Host zurueckgeschickt werden sollen
7
8
9     # letzte Aenderung:
10     # 29/06/94 - Siggi - Beginn mit Erstellung der Originalversion
11     # 08/07/94 - Siggi - Originalversion abgeschlossen (Version 1.0)
12     # 06/02/98 - Siggi - berte validiert
13     # 27/01/01 - Siggi - ground.yonsei.ac.kr validiert, Jobs zur T3E in Korea
14     #                    moeglich
15     # 08/02/01 - Siggi - alle subjob-Meldungen ins englische uebersetzt
16     # 25/05/02 - Siggi - Unterstuetzung des LoadLeveler
17     # 30/05/02 - Siggi - Validierung fuer ibm-Rechner in Seoul (nobel) sowie
18     #                    allgemeine Anpassungen fuer ibm-Rechner
19     # 15/10/02 - Siggi - Neue Default-Jobklasse (p_normal) fuer IBM in Seoul
20     #                    Ruecktransfer des Jobprotokolls fuer diese
21     #                    Maschine abgeschaltet
22     # 31/10/02 - Siggi - berni validiert
23     # 06/11/02 - Siggi - Neue Jobklassen auf ibmb und ibmh
24     # 08/11/02 - Siggi - quanero validiert
25     # 11/12/02 - Siggi - Notification fuer Transfer-Jobs abgeschaltet
26     # 23/01/03 - Siggi - hostname nobel changed to nobela
27     # 06/02/03 - Siggi - gregale validated
28     # 12/02/03 - Siggi - orkan and maestro validated
29     # 21/02/03 - Siggi - all nobel nodes in Seoul validated
30     # 12/03/03 - Siggi - nec at DKRZ validated
31     # 13/03/03 - Siggi - new nqs resource variable Memory
32     # 07/04/03 - Siggi - processor request option -c on nech needs tasks per
33     #                    node
34     # 11/04/03 - Siggi - network on ibms has attribute "shared"
35     # 31/07/03 - Siggi - nqs2 on nech implemented (provisional: -h nech2)
36     #                    cxxl added to ibmh
37     # 29/08/03 - Siggi - changes in job queues and communication system on
38     #                    ibms
39     # 24/10/03 - Siggi - using alternate hanni address 130.75.4.2
40     # 30/10/03 - Siggi - nech is not supported any more
41     # 10/11/03 - Siggi - nech2 renamed to nech
42     # 20/11/03 - Siggi - submit command on nech changed from qsub.test to qsub
43     # 29/03/04 - Siggi - ground not supported any more, gfdl3 validated
44     # 31/03/04 - Siggi - new option -N for node usage
45     # 12/04/04 - Siggi - scp2 instead of scp used for transfer from decalpha
46     #                    due to error in ssh installation (otherwise a prompt
47     #                    for the password appears)
48     # 23/07/04 - Siggi - changes due to the new berni configuration
49     #                    (federation switch)
50     # 01/09/04 - Gerald  new job-classes on hanni
51     # 08/09/04 - Siggi - hanni IP address changed to 130.75.4.10
52     # 23/11/04 - Siggi - new job class cdata on hanni and berni
53     # 03/12/04 - Siggi - notification on ibm switched of in case of
54     #                    delete_dayfile = true, node usage in cdev set to
55     #                    shared
56     # 16/02/05 - Gerald  hababai validated
57     # 29/03/05 - Micha - new job class channi on hanni
58     # 11/05/05 - Siggi - ConsumableMemory is now required as resource keyword
59     #                    on ibms
60     # 24/05/05 - Siggi - Default queue on ibms changed from p_normal_1.3 to
61     #                    p_normal
62     # 30/06/05 - Siggi - network changed for queue cdev from "us" to "ip"
63     # 12/07/05 - Siggi - in network.mpi on ibmh/ibmb "csss" changed to
64     #                    "sn_all", new job class cexp
65     # 08/09/05 - Siggi - IP-address of gfdl3 changed
66     # 31/10/05 - Siggi - new job class pp on hurricane, serial jobs on
67     #                    hurricane (with -X0)
68     # 01/11/05 - Siggi - missing queue for jobs submitted on nech (for nech)
69     #                    added
70     # 30/12/05 - Siggi - change of IP adresses in subnet 130.75.105
71     # 09/02/06 - Siggi - ibmy admitted
72     # 10/02/06 - Siggi - scp2 changed to /bin/scp on decalpha
73     # 13/04/06 - Siggi - ostria admitted
74     # 18/04/06 - Siggi - new option -O for OpenMP usage
75     # 24/05/06 - Siggi - lctit admitted, ftpjob renamed scpjob
76     # 25/07/06 - Siggi - gfdl5 (ibmy) admitted for submitting jobs
77     # 27/09/06 - Siggi - breg/hreg extended with berni/hanni
78     # 25/10/06 - Siggi - data_limit set to 1.76 GByte on hanni and berni
79     # 28/11/06 - Siggi - levanto admitted
80
81
82    # VARIABLENVEREINBARUNGEN + DEFAULTWERTE
83 delete_dayfile=false
84 filetransfer_protocol=scp
85 locat=normal
86 no_default_queue=none
87 no_submit=false
88 job_catalog="~/job_queue"
89 job_name=none
90 local_user=$LOGNAME
91 node_usage=shared
92 numprocs=1
93 punkte="..........................................................."
94 submcom=qsub
95 queue=default
96 remote_host=none
97 remote_user=""
98 verify=true
99
100 typeset  -i   cputime=memory=Memory=0  minuten  resttime  sekunden  stunden
101 typeset  -i   inumprocs  nodes=tasks_per_node=threads_per_task=1
102 typeset  -L20 spalte1
103 typeset  -R40 spalte2
104 typeset  -L60 spalte3
105
106
107
108    # FEHLERBEHANDLUNG
109    # BEI EXIT:
110 trap 'if [[ $locat != normal ]]
111       then
112          case  $locat  in
113             (option)  printf "\n  --> available optios can be displayed"
114                       printf " by typing:"
115                       printf "\n      \"subjob ?\" \n";;
116             (ftpcopy|parameter|scp|verify)  printf "\n";;
117             (*)       printf "\n  +++ unknown error"
118                       printf "\n      please inform S. Raasch!\n"
119          esac
120          [[ -f $job_to_send ]]  &&  rm  $job_to_send
121          printf "\n\n+++ SUBJOB killed \n\n"
122       fi' exit
123
124
125    # BEI TERMINAL-BREAK:
126 trap '[[ -f $job_to_send ]]  &&  rm  $job_to_send
127       printf "\n\n+++ SUBJOB killed \n\n"
128       exit
129      ' 2
130
131
132
133
134    # LOKALEN HOSTNAMEN FESTSTELLEN
135 local_host=$(hostname)
136
137
138
139    # HOSTSPEZIFISCHE VARIABLEN VEREINBAREN BZW. PRUEFEN, OB LOKALER HOST
140    # UEBERHAUPT ZULAESSIG IST
141 case  $local_host  in
142     (atmos)                 local_addres=172.20.25.35;   local_host=lcide;;
143     (bora)                  local_addres=130.75.105.103; local_host=hpmuk;;
144     (breg*-en0|berni*-en0)  local_addres=130.73.230.10;  local_host=ibmb;;
145     (breva)                 local_addres=130.75.105.98;  local_host=hpmuk;;     
146     (caurus)                local_addres=130.75.105.19;  local_host=hpmuk;;
147     (chinook)               local_addres=130.75.105.100; local_host=hpmuk;;
148     (cs*)                   local_addres=136.172.44.131; local_host=nech;;
149     (elephanta)             local_addres=130.75.105.6;   local_host=hpmuk;;
150     (gfdl5)                 local_addres=165.132.26.58;  local_host=ibmy;;
151     (gfdl3.yonsei.ac.kr)    local_addres=165.132.26.56;  local_host=decalpha;;
152     (gregale)               local_addres=130.75.105.109; local_host=hpmuk;;
153     (hababai)               local_addres=130.75.105.108; local_host=hpmuk;;
154     (hreg*-en0|hanni*-en0)  local_addres=130.75.4.10;    local_host=ibmh;;
155     (irifi)                 local_addres=130.75.105.104; local_host=hpmuk;;
156     (levanto)               local_addres=130.75.105.45;  local_host=hpmuk;;
157     (maestro)               local_addres=130.75.105.2;   local_host=hpmuk;;
158     (nobel*)                local_addres=150.183.5.101;  local_host=ibms;;
159     (orkan)                 local_addres=130.75.105.3;   local_host=hpmuk;;
160     (ostria)                local_addres=130.75.105.106; local_host=hpmuk;;
161     (quanero)               local_addres=130.75.105.107; local_host=hpmuk;;
162     (scirocco)              local_addres=172.20.25.41;   local_host=lcmuk;;
163     (sun1|sun2)             local_addres=130.75.6.1;     local_host=unics;;
164     (tgg*)                  local_addres=172.17.75.161;  local_host=lctit;;
165     (vorias)                local_addres=172.20.25.43;   local_host=lcmuk;;
166     (*)                     printf "\n  +++ \"$local_host\" unknown";
167                             printf "\n      please inform S. Raasch!";
168                             locat=parameter; exit;;
169 esac
170
171
172
173    # REMOTE HOST DEFAULTMAESSIG = LOCAL HOST SETZEN
174 remote_host=$local_host
175
176
177
178
179    # PROZEDUROPTIONEN EINLESEN
180 while  getopts  :c:dDf:h:m:n:N:O:q:t:T:u:vX:  option
181 do
182   case  $option  in
183       (c)   job_catalog=$OPTARG;;
184       (d)   delete_dayfile=true;;
185       (D)   no_submit=true;;
186       (f)   filetransfer_protocol=$OPTARG;;
187       (h)   remote_host=$OPTARG;;
188       (m)   memory=$OPTARG;;
189       (n)   job_name=$OPTARG;;
190       (N)   node_usage=$OPTARG;;
191       (O)   threads_per_task=$OPTARG;;
192       (q)   no_default_queue=$OPTARG;;
193       (t)   cputime=$OPTARG;;
194       (T)   tasks_per_node=$OPTARG;;
195       (u)   remote_user=$OPTARG;;
196       (v)   verify=false;;
197       (X)   numprocs=$OPTARG;;
198       (\?)  printf "\n  +++ Option $OPTARG unknown \n";
199             locat=option; exit;;
200   esac
201 done
202
203
204    # JOBDATEINAMEN ALS NAECHSTES ARGUMENT HOLEN
205 shift OPTIND-1; file_to_send=$1
206
207
208    # KURZE AUFRUFBESCHREIBUNG WIRD HIER AUSGEGEBEN
209 if [ "$1" = "?" ]
210 then
211   (printf "\n  *** subjob can be called as follows:\n"
212    printf "\n      subjob -c.. -d -D -h.. -m.. -q.. -t.. -u.. -v  <jobfile>\n"
213    printf "\n      Description of available options:\n"
214    printf "\n      Option  Description                         Default-Value"
215    printf "\n        -c    job-input- and output-catalog       ~/job_queue"
216    printf "\n        -d    no job-protocol will be created     ---"
217    printf "\n        -D    only the job-file will be created   ---"
218    printf "\n        -f    filetransfer protocol               scp"
219    printf "\n        -h    execution host, available hosts:    $remote_host"
220    printf "\n              hpmuk, ibm, ibmb, ibmh, ibms, ibmy,"
221    printf "\n              unics"
222    printf "\n        -m    memory demand per process in MByte  ---"
223    printf "\n        -n    jobname                             <jobdatei>"
224    printf "\n        -O    threads per task (for OpenMP usage) 1"
225    printf "\n        -q    job-queue to be used                default"
226    printf "\n        -t    allowed cpu-time in seconds         ---"
227    printf "\n        -T    tasks per node (on parallel hosts)  ---"
228    printf "\n        -u    username on execution host          from .netrc"
229    printf "\n        -v    no prompt for confirmation          ---"
230    printf "\n        -X    # of processors (on parallel hosts) 1"
231    printf "\n "
232    printf "\n      The only possible positional parameter is <jobfile>:"
233    printf "\n      The complete NQS-job must be provided here."
234    printf "\n      <jobfile>=? creates this outline\n\n") | more
235    exit
236 fi
237
238
239
240    # PRUEFEN, OB JOBDATEI ANGEGEBEN WURDE UND OB SIE AUCH EXISTIERT
241 if [[ "$file_to_send" = "" ]]
242 then
243    printf "\n  +++ job-file missing"
244    locat=parameter; exit
245 else
246    if [[ -f $file_to_send ]]
247    then
248       true
249    else
250       printf "\n  +++ job-file: "
251       printf "\n           $file_to_send"
252       printf "\n      does not exist"
253       locat=parameter; exit
254    fi
255 fi
256
257
258
259    # FALLS KEIN JOBNAME ANGEGEBEN WURDE, WIRD JOBNAME = JOBDATEINAME
260    # GESETZT. VORAUSSETZUNG: JOBDATEINAME BEINHALTET KEINE PFADE
261 if [[ $job_name = none ]]
262 then
263    job_name=$file_to_send
264 fi
265 if [[ $(echo $job_name | grep -c "/") != 0 ]]
266 then
267    printf "\n  +++ job-file name: "
268    printf "\n           $job_name"
269    printf "\n      must not contain \"/\"-characters"
270    locat=parameter; exit
271 fi
272
273
274
275
276    # HOSTSPEZIFISCHE GROESSEN VEREINBAREN BZW. ABBRUCH BEI UNZULAESSIGEM HOST
277    # ODER WENN HOST NICHT ANGEGEBEN WURDE
278 if [[ $remote_host = none ]]
279 then
280    printf "\n  +++ host missing"
281    locat=option; exit
282 else
283    case  $remote_host  in
284        (hpmuk)  qsubmem=d; qsubtime=t; queue=hpmuk; remote_addres=130.75.105.19; submcom=/opt/nqs/bin/qsub;;
285        (ibm)    queue=p690_standard; remote_addres=134.76.99.81; submcom=/usr/lpp/LoadL/full/bin/llsubmit;;
286        (ibmb)   queue=cpar; remote_addres=130.73.230.10; submcom=/usr/lpp/LoadL/full/bin/llsubmit;;
287        (ibmh)   queue=cpar; remote_addres=130.75.4.10; submcom=/usr/lpp/LoadL/full/bin/llsubmit;;
288        (ibms)   queue=p_normal; remote_addres=150.183.5.101; submcom=/usr/lpp/LoadL/full/bin/llsubmit;;
289        (ibmy)   queue=parallel; remote_addres=165.132.26.58; submcom=/usr/lpp/LoadL/full/bin/llsubmit;;
290        (lctit)  queue=test; remote_addres=172.17.75.161; submcom=/n1ge/TITECH_GRID/tools/bin/n1ge;;
291        (nech)   qsubmem=memsz_job; qsubtime=cputim_job; remote_addres=136.172.44.147; submcom="/usr/local/bin/qsub";;
292        (vpp)    qsubmem=m; qsubtime=t; queue=vpp; remote_addres=130.75.4.130;;
293        (unics)  qsubmem=d; qsubtime=t; queue=unics; remote_addres=130.75.6.1;;
294        (*)      printf "\n  +++ hostname \"$remote_host\" not allowed";
295                 locat=parameter; exit;;
296    esac
297 fi
298
299
300    # EVTL. PRUEFEN, OB ANGEGEBENE QUEUE ZULAESSIG IST
301 if [[ $no_default_queue != none ]]
302 then
303    error=false
304    ndq=$no_default_queue
305    case  $remote_host  in
306        (hpmuk)  case  $ndq  in
307                     (hpmuk)  error=false;;
308                     (*)      error=true;;
309                 esac;;
310        (ibm)    case  $ndq  in
311                     (p690_express|p690_standard|p690_long)  error=false;;
312                     (*)                                     error=true;;
313                 esac;;
314        (ibmb)   case  $ndq  in
315                     (cdata|cdev|cexp|c1|cshare|csolo|cspec) error=false;;
316                     (*)                                     error=true;;
317                 esac;;
318        (ibmh)   case  $ndq  in
319                     (cdata|cdev|cexp|channi|cxxl|c1|cshare|csolo|cspec)  error=false;;
320                     (*)                                     error=true;;
321                 esac;;
322        (ibms)   case  $ndq  in
323                     (express|normal|p_express|p_normal|p_normal_1.3|p_normal_1.7|grand)     error=false;;
324                     (*)                                     error=true;;
325                 esac;;
326        (ibmy)   case  $ndq  in
327                     (parallel)                              error=false;;
328                     (*)                                     error=true;;
329                 esac;;
330        (lctit)  case  $ndq  in
331                     (cs|default|high|test)                  error=false;;
332                     (*)                                     error=true;;
333                 esac;;
334        (t3eb)   case  $ndq  in
335                     (berte|p50|p100|p392|forfree|p25himem)  error=false;;
336                     (*)    error=true;;
337                 esac;;
338        (t3eh)   case  $ndq  in
339                     (para_t3e|em|k|l|lm|comp_t3e|c|p|ht)  error=false;;
340                     (*)    error=true;;
341                 esac;;
342        (t3ej2|t3ej5)  case  $ndq  in
343                     (low|normal|high)  error=false;;
344                     (*)    error=true;;
345                 esac;;
346        (t3es)  case  $ndq  in
347                     (batch|serial-4|pe4|p48|pe16|pe32|pe64|pe128)  error=false;;
348                     (*)    error=true;;
349                 esac;;
350        (unics)  case  $ndq  in
351                     (unics|ht)  error=false;;
352                     (*)         error=true;;
353                 esac;;
354    esac
355    if [[ $error = true ]]
356    then
357       printf "\n  +++ queue \"$no_default_queue\" on host \"$remote_host\" not allowed"
358       locat=parameter; exit
359    else
360       queue=$no_default_queue
361    fi
362 fi
363
364
365
366    # KNOTENNUTZUNG IN ENTWICKLERQUEUE MUSS SHARED SEIN
367 if [[ $node_usage != shared  &&  $queue = cdev ]]
368 then
369    node_usage=shared
370 fi
371
372
373
374    # PRUEFEN DER CPU-ZEIT, ZEIT NACH STUNDEN, MINUTEN UND SEKUNDEN
375    # AUFTEILEN
376 done=false
377 while [[ $done = false ]]
378 do
379    if (( $cputime <= 0 ))
380    then
381       printf "\n  +++ wrong cpu-time or cpu-time missing"
382       printf "\n  >>> Please type cpu-time in seconds as INTEGER:"
383       printf "\n  >>> "
384       read  cputime  1>/dev/null  2>&1
385    else
386       done=true
387    fi
388 done
389 if [[ $remote_host = nech ]]
390 then
391    if (( tasks_per_node != 0 ))
392    then
393       (( cputime = cputime * tasks_per_node ))
394    elif [[ $numprocs != 0 ]]
395    then
396       (( cputime = cputime * numprocs ))
397    fi
398 fi
399 (( stunden  = cputime / 3600 ))
400 (( resttime = cputime - stunden * 3600 ))
401 (( minuten  = resttime / 60 ))
402 (( sekunden = resttime - minuten * 60 ))
403 timestring=${stunden}:${minuten}:${sekunden}
404
405
406
407    # PRUEFEN DER KERNSPEICHERANFORDERUNG
408 done=false
409 while [[ $done = false ]]
410 do
411    if (( memory <= 0 ))
412    then
413       printf "\n  +++ wrong memory demand or memory demand missing"
414       printf "\n  >>> Please type memory in  MByte per process  as INTEGER:"
415       printf "\n  >>> "
416       read  memory  1>/dev/null  2>&1
417    else
418       done=true
419    fi
420 done
421
422 if [[ $remote_host = nech ]]
423 then
424    if (( tasks_per_node != 0 ))
425    then
426       (( Memory = memory * tasks_per_node / 1000 ))
427    elif [[ $numprocs != 0 ]]
428    then
429       (( Memory = memory * numprocs / 1000 ))
430    else
431       (( Memory = memory / 1000 ))
432    fi
433 fi
434
435
436    # SPEICHERBERECHNUNG BEI OPENMP-NUTZUNG
437 if [[ $(echo $remote_host | cut -c1-3) = ibm ]]
438 then
439    (( memory = memory * threads_per_task ))
440 fi
441
442
443    # BERECHNUNG DER ANZAHL DER ZU VERWENDENDEN KNOTEN
444 if (( tasks_per_node != 0 ))
445 then
446    (( nodes = numprocs / ( tasks_per_node * threads_per_task ) ))
447 fi
448
449
450
451    # HEADER-AUSGABE
452 if [[ $verify = true ]]
453 then
454    printf "\n\n"
455    printf "#--------------------------------------------------------------# \n"
456    spalte1=SUBJOB;spalte2=$(date)
457    printf "| $spalte1$spalte2 | \n"
458    printf "|                                                              | \n"
459    printf "| values of parameters/options:                                | \n"
460    spalte1=local_host$punkte; spalte2=$punkte$local_host
461    printf "| $spalte1$spalte2 | \n"
462    spalte1=remote_host$punkte; spalte2=$punkte$remote_host
463    printf "| $spalte1$spalte2 | \n"
464    spalte1=queue$punkte; spalte2=$punkte$queue
465    printf "| $spalte1$spalte2 | \n"
466    spalte1=memory$punkte; spalte2="$punkte$memory mb"
467    printf "| $spalte1$spalte2 | \n"
468    spalte1=cputime$punkte; spalte2="$punkte$cputime sec"
469    printf "| $spalte1$spalte2 | \n"
470    spalte1=job_name$punkte; spalte2="$punkte$job_name"
471    printf "| $spalte1$spalte2 | \n"
472    printf "#--------------------------------------------------------------# \n\n"
473
474
475       # KONTROLLABFRAGE, OB ALLES O.K.
476    antwort="dummy"
477    while [[ $antwort != y  &&  $antwort != Y  &&  $antwort != n  &&  $antwort != N ]]
478    do
479       read antwort?" >>> continue (y/n) ? "
480    done
481    if [[ $antwort = n  ||  $antwort = N ]]
482    then
483       locat=verify; exit
484    fi
485    printf "\n"
486 fi
487
488
489
490    # ZUFALLSKENNUNG GENERIEREN UND JOBNAMEN AUF ZIELRECHNER BESTIMMEN
491 kennung=$RANDOM
492 job_on_remhost=${job_name}_${kennung}_$local_host
493 job_to_send=job_to_send_$kennung
494 if [[ $delete_dayfile = false ]]
495 then
496    remote_dayfile=${local_host}_${job_name}_result_$kennung
497    local_dayfile=${remote_host}_${job_name}
498 else
499    remote_dayfile=/dev/null
500    if [[ $(echo $remote_host | cut -c1-3) = ibm ]]
501    then
502       notification='# @ notification = never'
503    fi
504 fi
505
506
507
508    # QSUB- ODER LL-KOMMANDOS BZW. SKRIPTE  GENERIEREN
509 if [[ $(echo $remote_host | cut -c1-3) = ibm  &&  $numprocs != 0 ]]
510 then
511
512    if [[ $remote_host = ibmy ]]
513    then
514       consumable_memory=""
515    else
516       consumable_memory="ConsumableMemory($memory mb)"
517    fi
518    if [[ $queue = cdev ]]
519    then
520       data_limit="# @ data_limit = 1.76gb"
521       network_to_use="# @ network.mpi = sn_all,shared,ip"
522    else
523       if [[ $remote_host = ibms ]]
524       then
525          network_to_use="# @ network.mpi = csss,shared,us"
526       elif [[ $remote_host = ibmy ]]
527       then
528          network_to_use=""
529       else
530          network_to_use="# @ network.mpi = sn_all,shared,us"
531          data_limit="# @ data_limit = 1.76gb"
532       fi
533    fi
534
535    cat > $job_to_send << %%END%%
536#!/bin/ksh
537
538# @ job_type = parallel
539# @ job_name = palm
540# @ wall_clock_limit = ${timestring},$timestring
541# @ resources = ConsumableCpus($threads_per_task) $consumable_memory
542# @ output = $remote_dayfile
543# @ error = $remote_dayfile
544# @ image_size = 50
545# @ class = $queue
546# @ environment = OMP_NUM_THREADS=$threads_per_task; MP_SHARED_MEMORY=yes
547$network_to_use
548$data_limit
549$notification
550
551%%END%%
552
553    if (( nodes > 0 ))
554    then
555
556       cat >> $job_to_send << %%END%%
557# @ node = $nodes
558# @ tasks_per_node = $tasks_per_node
559# @ node_usage = $node_usage
560# @ queue
561
562%%END%%
563
564    else
565
566       if [[ $remote_host != ibmy ]]
567       then
568
569          cat >> $job_to_send << %%END%%
570# @ blocking = unlimited
571# @ total_tasks = $numprocs
572# @ node_usage = $node_usage
573# @ queue
574
575%%END%%
576
577       else
578
579          cat >> $job_to_send << %%END%%
580# @ node = 1
581# @ total_tasks = $numprocs
582# @ queue
583
584%%END%%
585
586       fi
587
588    fi
589
590 elif [[ $(echo $remote_host | cut -c1-3) = ibm  &&  $numprocs = 0 ]]
591 then
592
593    cat > $job_to_send << %%END%%
594#!/bin/ksh
595
596# @ job_type = serial
597# @ node_usage = $node_usage
598# @ job_name = palm
599# @ wall_clock_limit = ${timestring},$timestring
600# @ resources = ConsumableCpus(1) ConsumableMemory(1 gb)
601# @ output = $remote_dayfile
602# @ error = $remote_dayfile
603# @ class = $queue
604$notification
605
606# @ queue
607
608%%END%%
609
610 elif [[ $remote_host = nech ]]
611 then
612
613    if (( nodes > 1 ))
614    then
615       cat > $job_to_send << %%END%%
616#!/bin/ksh
617#PBS -l cpunum_prc=$tasks_per_node,cputim_job=$cputime
618#PBS -l ${qsubmem}=${Memory}gb
619#PBS -b $nodes
620#PBS -o $remote_dayfile
621#PBS -N palm
622#PBS -j o
623#PBS -T mpisx
624
625%%END%%
626
627    elif [[ $numprocs != 0 ]]
628    then
629       cat > $job_to_send << %%END%%
630#!/bin/ksh
631#PBS -l cpunum_prc=$tasks_per_node,cputim_job=$cputime
632#PBS -l ${qsubmem}=${Memory}gb
633#PBS -o $remote_dayfile
634#PBS -N palm
635#PBS -j o
636
637%%END%%
638
639    else
640       cat > $job_to_send << %%END%%
641#!/bin/ksh
642#PBS -l ${qsubmem}=${Memory}gb,${qsubtime}=$cputime
643#PBS -o $remote_dayfile
644#PBS -j o
645
646%%END%%
647
648    fi
649
650 elif [[ $remote_host = lctit ]]
651 then
652    cat > $job_to_send << %%END%%
653#!/bin/bash
654#$ -S /bin/bash
655cd $job_catalog
656PATH=$job_catalog:${job_catalog}/../pub:\$PATH
657export PATH
658
659%%END%%
660
661       # OPTIONEN FUER SUBMIT-KOMMANDO ZUSAMMENSTELLEN
662    submcom="$submcom  -N $job_name  -sgeout $remote_dayfile  -q default"
663
664 else
665
666    cat > $job_to_send << %%END%%
667# @\$-q ${queue}
668# @\$-l${qsubtime} $timestring
669# @\$-l${qsubmem} ${memory}mb
670# @\$-o $remote_dayfile
671# @\$-eo
672
673%%END%%
674
675 fi
676
677
678    # BEI RECHNUNG AUF REMOTE-MASCHINEN RUECKTRANSFER DES DAYFILES PER TRAP
679    # BEI EXIT VERANLASSEN
680    # VEKTORRECHNER MUSS EIGENEN JOB STARTEN, DA DORT NOHUP NICHT FUNKTIONIERT
681    # AUF IBM IN SEOUL IST RUECKTRANSFER ZUR ZEIT GENERELL NICHT MOEGLICH
682 if [[ $delete_dayfile = false  &&  $remote_host != $local_host ]]
683 then
684    echo "set +vx"                              >>  $job_to_send
685    echo "trap '"                               >>  $job_to_send
686    echo "set +vx"                              >>  $job_to_send
687    if [[ $(echo $remote_host | cut -c1-3) = ibm  ||  $remote_host = nech  ||  $remote_host = lctit ]]
688    then
689       if [[ $remote_host = ibmb  ||  $remote_host = ibmh ]]
690       then
691          return_queue=c1
692       elif [[ $remote_host = ibms ]]
693       then
694          return_queue=p_normal
695       elif [[ $remote_host = ibmy ]]
696       then
697          return_queue=serial
698       elif [[ $remote_host = lctit ]]
699       then
700          return_queue=default
701       elif [[ $remote_host = t3eb ]]
702       then
703          return_queue=berte
704       elif [[ $remote_host = t3ej2  ||  $remote_host = t3ej5 ]]
705       then
706          return_queue=normal
707       elif [[ $remote_host = t3es ]]
708       then
709          return_queue=batch
710       else
711          return_queue=unknown
712       fi
713
714       if [[ $(echo $remote_host | cut -c1-3) = ibm ]]
715       then
716
717          echo "echo \"#!/bin/ksh\" >> scpjob.$kennung"               >>  $job_to_send
718          echo "echo \"# @ job_type = serial\" >> scpjob.$kennung"    >>  $job_to_send
719          echo "echo \"# @ job_name = transfer\" >> scpjob.$kennung"  >>  $job_to_send
720          echo "echo \"# @ resources = ConsumableCpus(1) ConsumableMemory(1 gb)\" >> scpjob.$kennung"  >>  $job_to_send
721          echo "echo \"# @ wall_clock_limit = 00:10:00,00:10:00\" >> scpjob.$kennung "  >>  $job_to_send
722          echo "echo \"# @ output = job_queue/last_job_transfer_protocol\" >> scpjob.$kennung"  >>  $job_to_send
723          echo "echo \"# @ error = job_queue/last_job_transfer_protocol\" >> scpjob.$kennung"  >>  $job_to_send
724          echo "echo \"# @ class = $return_queue\" >> scpjob.$kennung"  >>  $job_to_send
725          echo "echo \"# @ image_size = 10\" >> scpjob.$kennung"      >>  $job_to_send
726          echo "echo \"# @ notification = never\" >> scpjob.$kennung" >>  $job_to_send
727
728          echo "echo \"# @ queue\" >> scpjob.$kennung"                >>  $job_to_send
729          echo "echo \" \" >> scpjob.$kennung"                        >>  $job_to_send
730
731          echo "echo \"set -x\" >> scpjob.$kennung"                   >>  $job_to_send
732          echo "echo \"batch_scp  -d  -w 10  -u $local_user  $local_addres  ${job_catalog}/$remote_dayfile  \\\"$job_catalog\\\"  $local_dayfile\" >> scpjob.$kennung"  >>  $job_to_send
733          echo "echo \"exit\" >> scpjob.$kennung"                     >>  $job_to_send
734
735       elif [[ $remote_host = nech ]]
736       then
737          echo "cd /pf/b/${remote_user}/job_queue" >>  $job_to_send
738          echo "cat > scpjob.$kennung << %%END%%"  >>  $job_to_send
739          echo "#PBS -l ${qsubmem}=1GB,${qsubtime}=100"  >>  $job_to_send
740          echo "#PBS -o last_job_transfer_protocol"      >>  $job_to_send
741          echo "#PBS -j o"                         >>  $job_to_send
742          echo " "                                 >>  $job_to_send
743          echo "set -x"                            >>  $job_to_send
744          echo "cd /pf/b/${remote_user}/job_queue" >>  $job_to_send
745          echo "batch_scp  -d  -w 10  -u $local_user $local_addres  $remote_dayfile  \"$job_catalog\"  $local_dayfile"  >>  $job_to_send
746          echo "[[ \"\$for_subjob_to_do\" != \"\" ]]  &&  eval \$for_subjob_to_do"  >>  $job_to_send
747          echo "%%END%%"                           >>  $job_to_send
748
749       elif [[ $remote_host = lctit ]]
750       then
751          echo "cat > scpjob.$kennung << %%END%%"          >>  $job_to_send
752          echo "set -x"                                    >>  $job_to_send
753          echo "PATH=\$PATH:$job_catalog/../pub"           >>  $job_to_send
754          echo "cd $job_catalog"                           >>  $job_to_send
755          echo "batch_scp  -d  -w 10  -u $local_user $local_addres  $remote_dayfile  \"$job_catalog\"  $local_dayfile"  >>  $job_to_send
756          echo "[[ \"\$for_subjob_to_do\" != \"\" ]]  &&  eval \$for_subjob_to_do"  >>  $job_to_send
757          echo "%%END%%"                                   >>  $job_to_send
758
759       else
760
761          echo "cat > scpjob.$kennung << %%END%%"  >>  $job_to_send
762          echo "# @\\\$-q $return_queue"           >>  $job_to_send
763          echo "# @\\\$-l${qsubtime} 10"           >>  $job_to_send
764          echo "# @\\\$-l${qsubmem} 10mb"          >>  $job_to_send
765          if [[ $remote_host = t3ej2  ||  $remote_host = t3ej5  ||  $remote_host = t3es ]]
766          then
767             echo "# @\$-l mpp_p=0"                >>  $job_to_send
768          fi
769          echo '# @\$-lF 10mb'                     >>  $job_to_send
770#          echo '# @\$-o /dev/null'                 >>  $job_to_send
771          echo '# @\$-o job_queue/last_job_transfer_protocol'    >>  $job_to_send
772          echo '# @\\\$-eo'                          >>  $job_to_send
773          echo " "                                 >>  $job_to_send
774          if [[ $remote_host = t3ej2  ||  $remote_host = t3ej5 ]]
775          then
776             echo "set +vx"                        >>  $job_to_send
777             echo ". .profile"                     >>  $job_to_send
778          fi
779          echo "set -x"                            >>  $job_to_send
780          echo "batch_scp  -d  -w 10  -u $local_user $local_addres  ${job_catalog}/$remote_dayfile  \"$job_catalog\"  $local_dayfile  >  /dev/null"  >>  $job_to_send
781          echo "[[ \"\$for_subjob_to_do\" != \"\" ]]  &&  eval \$for_subjob_to_do"  >>  $job_to_send
782          echo "%%END%%"                           >>  $job_to_send
783       fi
784
785       if [[ $(echo $remote_host | cut -c1-3) = ibm ]]
786       then
787          echo "llsubmit  scpjob.$kennung"      >>  $job_to_send
788       elif [[ $remote_host = lctit ]]
789       then
790          echo "chmod  u+x  scpjob.$kennung"    >>  $job_to_send
791          echo "rm -rf ${job_catalog}/last_job_transfer_protocol"  >>  $job_to_send
792          echo "n1ge  -N jobtransfer  -q $return_queue  -sgeout ${job_catalog}/last_job_transfer_protocol  scpjob.$kennung"  >>  $job_to_send
793          echo "sleep 10"                       >>  $job_to_send
794       elif [[ $remote_host = t3eb  ||  $remote_host = t3eh  ||  $remote_host = t3ej2  ||  $remote_host = t3ej5 ]]
795       then
796          echo "qsub -J n  scpjob.$kennung"     >>  $job_to_send
797       elif [[ $remote_host = t3es ]]
798       then
799          echo "qsub -J n  -s /bin/ksh  scpjob.$kennung"     >>  $job_to_send
800       else
801          echo "qsub  scpjob.$kennung"          >>  $job_to_send
802       fi
803       echo "rm  scpjob.$kennung"               >>  $job_to_send
804       if [[ $remote_host = nech ]]
805       then
806          echo "cd -"                           >>  $job_to_send
807       fi
808    else
809#       echo "ftpcopy  -d  $local_addres  ${job_catalog}/$remote_dayfile  \"$job_catalog\"  $local_dayfile"  >>  $job_to_send
810       echo "nohup  ftpcopy  -d  -w 15  $local_addres  ${job_catalog}/$remote_dayfile  \"$job_catalog\"  $local_dayfile  >  /dev/null  &"  >>  $job_to_send
811    fi
812    echo "set -x"                               >>  $job_to_send
813    echo "     ' exit"                          >>  $job_to_send
814    echo "set -x"                               >>  $job_to_send
815 fi
816
817
818
819    # EIGENTLICHE JOB-DATEI AN QSUB-KOMMANDOS ANHAENGEN
820 cat  $file_to_send  >>  $job_to_send
821 if [[ $remote_host = ibm ]]
822 then
823    echo " "         >>  $job_to_send
824    echo "exit"      >>  $job_to_send
825 fi
826
827
828
829    # USER-NAME AUF ZIELRECHNER AUS .NETRC-DATEI ERMITTELN
830 if [[ -z $remote_user ]]
831 then
832    if [[ $remote_host = t3eb  ||  $remote_host = t3eh  ||  $remote_host = t3ej2  ||  $remote_host = t3ej5  ||  $remote_host = t3es  ||  $remote_host = vpp ]]
833    then
834       grep  $remote_addres  ~/.netrc | read dum dum dum remote_user dum dum
835    fi
836 fi
837
838
839
840    # JOB AUF ZIELRECHNER TRANSFERIEREN BZW. INS JOBVERZEICHNIS KOPIEREN
841 if [[ $no_submit = false ]]
842 then
843    if [[ $remote_host != $local_host ]]
844    then
845       [[ $verify = true ]]  &&  printf "\n >>> transfering job to \"$remote_host\"..."
846       if [[ $filetransfer_protocol = scp ]]
847       then
848          if [[ $remote_host = ibms  ||  $remote_host = ibmy ]]    # ssh on ibms cannot handle "~/"
849          then
850             job_catalog_save=$job_catalog
851             job_catalog=job_queue
852          elif [[ $remote_host = nech ]]
853          then
854             job_catalog_save=$job_catalog
855             job_catalog=/hpf/b/${remote_user}/job_queue
856          fi
857          if [[ $local_host = decalpha ]]
858          then
859                # VERWENDUNG VON SCP AUF DECALPHA FRAGT FEHLERHAFTERWEISE
860                # PASSWORT AB
861             /bin/scp  $job_to_send  ${remote_user}@${remote_addres}:${job_catalog}/$job_on_remhost
862          elif [[ $remote_host = nech ]]
863          then
864                # DATEIEN KOENNEN NUR UEBER DEN ARCHIVE-SERVER DES DKRZ
865                # TRANSFERIERT WERDEN
866             scp  $job_to_send  ${remote_user}@136.172.44.205:${job_catalog}/$job_on_remhost
867          else
868             scp  $job_to_send  ${remote_user}@${remote_addres}:${job_catalog}/$job_on_remhost
869          fi
870          if [[ $? = 1 ]]
871          then
872             locat=scp; exit
873          fi
874          if [[ $remote_host = ibms ]]
875          then
876             job_catalog=$job_catalog_save
877          fi
878       else
879          ftpcopy -s -o  $remote_addres  $job_to_send  "$job_catalog"  $job_on_remhost
880          if [[ $? = 1 ]]
881          then
882             locat=ftpcopy; exit
883          fi
884       fi
885       [[ $verify = true ]]  &&  printf "\n >>> finished\n"
886    else
887       eval  job_catalog=$job_catalog
888       cp  $job_to_send  ${job_catalog}/$job_on_remhost
889    fi
890
891
892
893       # NQS- BZW. LOADLEVELER-JOB STARTEN
894    if [[ $remote_host != $local_host ]]
895    then
896       [[ $verify = true ]]  &&  printf "\n >>> submitting job using \"qsub\"...\n"
897       if [[ $filetransfer_protocol = scp ]]
898       then
899          if [[ $remote_host != lctit ]]
900          then
901             ssh  $remote_addres  -l $remote_user  "cd $job_catalog; $submcom $job_on_remhost; rm $job_on_remhost"
902          else
903                # TIT ERLAUBT NUR DIE AUSFÜHRUNG GANZ BESTIMMTER KOMMANDOS
904                # MIT SSH, DESHALB AUFRUF PER PIPE
905                # UEBERGANGSWEISE CHECK, OB N1GE ENVIRONMENT WIRKLICH VERFUEGBAR
906             print  "cd $job_catalog; chmod u+x $job_on_remhost"  |  ssh  $remote_addres  -l $remote_user  > /dev/null  2>&1
907             echo "first try" > send_protocol
908             while [[ $(cat send_protocol | grep -c "Forwarding to N1GE") = 0 ]]
909             do
910                if [[ $(cat send_protocol | grep -c "first try") = 1 ]]
911                then
912                   printf "\n trying to submit job to TIT cluster..."
913                else
914                   printf "\n +++ failed ... trying to submit again ..."
915                fi
916                print  "cd $job_catalog; $submcom $job_on_remhost"  |  ssh  $remote_addres  -l $remote_user  >  send_protocol  2>&1
917                cat send_protocol
918             done
919             sleep 10
920             print  "cd $job_catalog;  rm $job_on_remhost"  |  ssh  $remote_addres  -l $remote_user  > /dev/null  2>&1
921             echo "$submcom  $job_on_remhost"
922             rm  send_protocol
923          fi
924       else
925          if [[ $remote_host = ibms ]]
926          then
927             password=`cat ~/.netrc | grep $remote_addres | awk '{print $6}'`
928             echo "echo \"$remote_user\" "       >  telnet_script
929             echo "sleep 5"                      >> telnet_script
930             echo "echo \"$password\" "          >> telnet_script
931             echo "sleep 10"                     >> telnet_script
932             echo "echo \"\" "                   >> telnet_script
933             echo "sleep 2"                      >> telnet_script
934             echo "echo \"cd $job_catalog; $submcom $job_on_remhost; rm -rf $job_on_remhost\" " >> telnet_script
935             echo "sleep 10"                     >> telnet_script
936             echo "echo \"exit\" "               >> telnet_script
937
938             chmod  u+x  telnet_script
939             telnet_script  |  telnet $remote_addres  2>&1  |  grep "llsubmit:"
940             rm  telnet_script
941          elif [[ $remote_host = t3es ]]
942          then
943             password=`cat ~/.netrc | grep $remote_addres | awk '{print $6}'`
944             echo "printf \"$remote_user\\\n\" " >  telnet_script
945             echo "sleep 10"                     >> telnet_script
946             echo "printf \"$password\\\n\" "    >> telnet_script
947             echo "sleep 10"                     >> telnet_script
948             echo "printf \"\\\n\" "             >> telnet_script
949             echo "sleep 5"                      >> telnet_script
950             echo "printf \"\\\n\" "             >> telnet_script
951             echo "sleep 5"                      >> telnet_script
952             echo "printf \"cd $job_catalog; $submcom $job_on_remhost; rm -f $job_on_remhost\\\n\" " >> telnet_script
953             echo "sleep 10"                     >> telnet_script
954             echo "printf \"exit\\\n\" "         >> telnet_script
955
956             chmod  u+x  telnet_script
957             cat telnet_script
958             telnet_script | telnet $remote_addres  |  grep $remote_user
959             rm  telnet_script
960          else
961             remcom.x  $remote_addres  "cd $job_catalog; $submcom $job_on_remhost; rm $job_on_remhost"
962          fi
963       fi
964       [[ $verify = true ]]  &&  printf " >>> o.k.\n"
965    else
966       cd  $job_catalog
967       if [[ $(echo $local_host | cut -c1-3) = ibm ]]
968       then
969          eval  $submcom  $job_on_remhost
970       elif [[ $local_host = lctit ]]
971       then
972          eval  $submcom  $job_on_remhost
973          echo "$submcom  $job_on_remhost"
974          chmod  u+x  $job_on_remhost
975          sleep 5   # WEIL N1GE IM HINTERGRUND ARBEITET UND DATEI SONST EVTL.
976                    # SCHON WIEDER GELOESCT IST
977       elif [[ $local_host = nech ]]
978       then
979          if [[ $queue = default ]]
980          then
981             eval  $submcom  $job_on_remhost 
982          else
983             eval  $submcom  -q $queue  $job_on_remhost 
984          fi
985       else
986          qsub  $job_on_remhost
987       fi
988       rm  $job_on_remhost
989       cd  -  > /dev/null
990    fi
991 fi
992
993
994
995    # ABSCHLUSSARBEITEN
996
997 if [[ $no_submit = false ]]
998 then
999    rm  $job_to_send
1000 fi
1001 [[ $verify = true ]]  &&  printf "\n\n *** SUBJOB finished \n\n"
Note: See TracBrowser for help on using the repository browser.