source: palm/tags/release-3.2b/SCRIPTS/subjob @ 2007

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

vorlaeufige Standalone-Version fuer Linux-Cluster

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