source: palm/tags/release-3.1b/SCRIPTS/subjob @ 4095

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

html-documentation added

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