source: palm/trunk/SCRIPTS/subjob @ 35

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

small bugfix in mbuild, subjob adjusted for RIAM machines

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