source: palm/trunk/SCRIPTS/mrun @ 82

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

vorlaeufige Standalone-Version fuer Linux-Cluster

  • Property svn:keywords set to Rev
File size: 142.9 KB
Line 
1#!/bin/ksh
2# mrun - Plot-Shellskript
3# $Id: mrun 61 2007-03-12 05:42:06Z raasch $
4
5     # Prozedur zum Starten von Modellaeufen
6
7     # letzte Aenderung:
8     # 03/03/94 - Siggi - Entwicklungsbeginn
9     # 21/03/94 - Siggi - Entwicklungsabschluss (Version 1.0)
10     # 09/12/94 - Siggi - allexport unterbunden; statt dessen werden jetzt ein-
11     #                    zelne Variable exportiert. Dies ist noetig, weil an-
12     #                    sonsten irgendein Speicher ueberlaeuft und von mrun
13     #                    aufgerufene Programme (z.B. stageout) mit Fehlern
14     #                    abbrechen (too many arguments)
15     # 20/06/95 - Siggi - noclobber muss explizit abgeschaltet, da jetzt
16     #                    defaultmaessig im RRZN-Profile eingeschaltet
17     # 10/06/97 - Siggi - Zusaetzliche Option -C bei cpp, damit // nicht
18     #                    wegfallen
19     # 25/04/00 - Siggi - Version 1.5
20     #                    remote_addres und remote_user in return_addres bzw.
21     #                    return_username umbenannt, return_username wird dem
22     #                    mrun-Aufruf im Job ueber Option -U mitgegeben.
23     #                    Neue Variable remote_username, die beim interaktiven
24     #                    mrun-Aufruf zwingend ueber die neue Option -u oder
25     #                    in der Konfigurationsdatei angegeben werden muss.
26     # 08/02/01 - Siggi - Alle mrun-Meldungen ins englische uebersetzt,
27     #                    Version 1.7
28     # 05/05/02 - Siggi - Uebersetzungen mittels make-Mechanismus moeglich
29     # 21/11/02 - Siggi - ENV-Variable XLFRTEOPTS wird vor Ausfuehrung auf
30     #                    IBM gesetzt, um Record-Laenge der NAMELIST-Dateien,
31     #                    zu bestimmen; Praeprozessoroptionen haben nun alle
32     #                    die Form -Dtext=text, weil auf IBM sonst text durch
33     #                    die leere Zeichenkette ersetzt wird
34     # 01/08/03 - Siggi  - Test of implementing dvrp+1PE on ibm
35     # 07/01/04 - Siggi  - additional preprocessor directive for ibm included
36     #                     (-D$OMP=OMP) in order to avoid problems with
37     #                     OMP_NUM_THREADS
38     # 04/01/05 - Siggi  - archiving on hanni and berni is done in separate
39     #                     tar files, one for each node used
40     # 07/01/04 - Siggi  - old code for t3e, vpp and hpcs eliminated
41     # 09/01/05 - Siggi  - workaround for getting the IP address on gfdl3
42     # 17/01/05 - Siggi  - job for data transfer to local machine now within
43     #                     job class c1 (HLRN)
44     # 27/01/05 - Siggi  - IP address workaround for gfdl3 removed
45     # 28/01/05 - Siggi  - tar-filenames on $PERM (HLRN) now include the
46     #                     base filename and cycle number
47     # 16/02/05 - Gerald - hababai validated
48     # 14/03/05 - Siggi  - abort on NEC after first runtime error (F_ERRCNT)
49     # 29/03/05 - Marcus - berni*-en0 validated
50     # 21/04/05 - Siggi  - transfer-job-protocol for avs-data is no more stored
51     # 24/04/05 - Siggi  - netcdf support on lcmuk
52     # 25/04/05 - Siggi  - netcdf support on gfld3 (decalpha)
53     # 11/05/05 - Siggi  - files with non-numeric extensions (.xxx after cycle
54     #                     number) can now be used within interactive runs
55     # 12/05/05 - Siggi  - netcdf support on ibm
56     # 13/05/05 - Siggi  - error in tar-filenames on $PERM (HLRN) removed
57     # 18/05/05 - Siggi  - netcdf support on nec
58     # 24/05/05 - Siggi  - netcdf support on ibms
59     # 14/06/05 - Siggi  - sleep interval after submit of restart job increased
60     #                     to 30 seconds
61     # 28/06/05 - Siggi  - bora adjusted to new intel compiler (LD_LIBRARY_
62     #                     PATH is temporarily set)
63     # 07/09/05 - Siggi  - setting of MP_EAGER_LIMIT switched off because it
64     #                     caused warnings in the job protocol
65     # 20/10/05 - Siggi  - update of netcdf-version on decalpha (gfdl3)
66     # 25/10/05 - Siggi  - error in listing files for getting the cycle number
67     #                     removed
68     # 26/10/05 - Siggi  - new paths for dvrp-library, transfer of catalogs
69     #                     realized by file attribute trpe
70     # 28/10/05 - Siggi  - if existing, the file extension is output in case
71     #                     of missing input file - no job abort in case of
72     #                     missing input files with file extensions
73     #                     (preliminary solution)
74     # 31/10/05 - Siggi  - data transfer from nech now within seperate job
75     # 04/11/05 - Siggi  - netcdf 3.6.0-p1 on ibmh/ibmb
76     # 07/12/05 - Siggi  - gallego and elephanta admitted
77     # 30/12/05 - Siggi  - gfdl5 (ibmy) admitted
78     # 10/01/06 - Siggi  - cpp directive for NetCDF 64bit support
79     # 20/01/06 - Siggi  - cpp directive for ibmy
80     # 09/02/06 - Siggi  - ibmy admitted for batch mode
81     # 13/04/06 - Siggi  - ostria admitted
82     # 18/04/06 - Siggi  - usage of OpenMP implemented (additional option -O)
83     # 10/05/06 - Siggi  - environment variable XLSMPOPTS set on IBM for
84     #                     optimization of OpenMP runs (option stacksize is
85     #                     necessary for large gridpoint numbers because
86     #                     otherwise a segmentation fault occurs)
87     # 23/05/05 - Siggi  - lctit (SUN Fire X4600) admitted
88     # 21/08/06 - Siggi  - standard mrun path on scirocco is as on bora
89     # 23/08/06 - Siggi  - netcdf support for scirocco (notebook)
90     # 20/09/06 - Marcus - add DVRP library on nech
91     # 24/10/06 - Siggi  - Environment variables for PALM steering are written
92     #                     on local NAMELIST file ENVPAR
93     # 24/11/06 - Siggi  - levanto admitted, maestro switched to ifc 9.1
94     # 28/11/06 - Siggi  - call to interpret_config.x_levanto because of SuSe 10
95     # 06/02/07 - Siggi  - add DVRP library on lcmuk
96     # 07/02/07 - Siggi  - revision of source code handling, source code is
97     #                     now expected in directory given by source_path and
98     #                     not in the current working directory, source code
99     #                     files provided in add_source_path are allways
100     #                     compiled, source code to be compiled is allways
101     #                     sampled in SOURCES_FOR_RUN_$fname which is a
102     #                     subdirectory of the current working directory,
103     #                     -s TEST  changed to  -s WRITE_PERMIT  or -s WP,
104     #                     adapted for RIAM (neck)
105     #                     bugfix for cycle number of output file (extout)
106     #                     all hpmuk-related code removed
107     # 14/02/07 - Siggi  - dvrp support for neck added
108     # 28/02/07 - Siggi  - empty lines in configuration file are accepted
109     #                     mrun_path replaced by PALM_BIN,
110     #                     all machines are calling interpret_config.x
111     # 14/03/07 - Siggi  - fimm admitted, revision number added to terminal
112     #                     output
113     # 16/03/07 - Siggi  - adjustments for lctit
114     # 29/03/07 - Siggi  - global revision transfered to batch job by new
115     #                     option -G
116     # 30/03/07 - Siggi  - compilation "by hand" removed, cpp-directives/options
117     #                     + netcdf/dvrp-options are read from configuration
118     #                     file, host identifier (local_host) is read from
119     #                     config file, code related to ftp filetransfer
120     #                     removed (incl. option -f)
121
122
123
124 
125    # VARIABLENVEREINBARUNGEN + DEFAULTWERTE
126
127 set +o allexport    # SICHERHEITSHALBER UNTERBINDEN, DA SONST EVTL. STAGEOUT
128                     # NICHT LAUEFT (TOO MANY ARGUMENTS - PROBLEM)
129 set +o noclobber    # EXISTIERENDE DATEIEN DUERFEN UEBERSCHRIEBEN WERDEN
130
131 AddFilenames=""
132 additional_conditions=""
133 add_source_path=""
134 afname=""
135 archive_save=true
136 archive_system=none
137 compiler_name=""
138 cond1=""
139 cond2="" 
140 config_file=.mrun.config
141 cpp_opts=""
142 cpp_options=""
143 cpumax=0
144 cpurest=0
145 delete_temporary_catalog=true
146 do_batch=false
147 do_compile=true
148 do_remote=false
149 do_stagein=true
150 do_stageout=true
151 do_trace=false
152 email_notification=""
153 exclude=""
154 executable=""
155 execution_error=false
156 fimm=false
157 fname=test
158 fromhost=""
159 global_revision=""
160 host=""
161 host_file=""
162 hp=""
163 ignore_archive_error=false
164 input_list=""
165 interpreted_config_file=""
166 job_on_file=""
167 keep_data_from_previous_run=false
168 localhost_realname=$(hostname)
169 local_compile=false
170 locat=normal
171 mainprog=""
172 makefile=""
173 mc=$0
174 while [[ $(echo $mc | grep -c "/") != 0 ]]
175 do
176    mc=`echo $mc | cut -f2- -d"/"`
177 done
178 module_files=""
179 mrun_script_name=$mc
180 netcdf_inc=""
181 netcdf_lib=""
182 netcdf_support=false
183 node_usage=default
184 numprocs=""
185 OOPT=""
186 openmp=false
187 output_list=""
188 package_list=""
189 punkte="..........................................................."
190 queue=none
191 read_from_config=""
192 restart_run=false
193 return_addres=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}')
194 if [[ $return_addres = 130.75.105.158 ]]
195 then
196    return_addres=172.20.25.41
197    echo "+++ WARNING: return_addres changed to $return_addres !!!!!"
198 fi
199# if [[ $return_addres = 210.117.65.1 ]]
200# if [[ $(nslookup `hostname` 2>&1 | grep -c 210.117.65.1) = 1 ]]
201# then
202#    [[ $localhost_realname = gfdl3.yonsei.ac.kr ]]  &&  return_addres=165.132.26.56
203# fi
204 return_password=""
205 return_username=$LOGNAME
206 remotecall=false
207 remote_username=""
208 run_mode=""
209 scirocco=false
210 store_on_archive_system=true
211 striche="  ----------------------------------------------------------------------------"
212 silent=false
213 source_list=""
214 source_path=SOURCE
215 tasks_per_node=""
216 threads_per_task=1
217 tmpcreate=false
218 tmp_data_catalog=""
219 transfer_problems=false
220 usern=$LOGNAME
221 working_directory=`pwd`
222 TOPT=""
223 XOPT=""
224 zeit=$( date | cut -c 12-19 )
225
226 typeset -i  iec=0 iic=0 iin=0 ioc=0 iout=0 memory=0 stagein_anz=0 stageout_anz=0
227 typeset -i  cputime i ii icycle inode ival jobges jobsek maxcycle minuten nodes pes sekunden tp1
228
229 typeset  -R30 calltime
230 typeset  -L20 spalte1
231 typeset  -L40 spalte2
232 typeset  -L60 spalte3
233 typeset  -L35 string1=`date`
234 typeset  -L12 string2=$usern
235 typeset  -L12 string3=$localhost_realname
236 typeset  -L12 string4
237 typeset  -L12 string5
238 typeset  -L30 version="MRUN  2.0 Rev$Rev: 82 $"
239
240
241
242    # EINZELNE VARIABLE FUER HAUPTPROGRAMM EXPORTIEREN
243 export  cpurest fname host localhost return_addres return_username remotecall tasks_per_node
244
245    # FOLGENDE VARIABLEN MUESSEN FUER DIE INTERPRETATION DER KONFIGURATIONSDATEI
246    # EXPORTIERT WERDEN
247 export  afname config_file cpp_opts cpumax do_batch do_trace fname fromhost
248 export  input_list memory numprocs output_list queue run_mode
249
250
251 
252    # FEHLERBEHANDLUNG
253    # BEI EXIT:
254 trap 'rm -rf  tmp_mrun
255       if [[ $locat != localhost ]]
256       then
257#          if [[ ! -f ${mrun_path}/statistik/mrun_statistik ]]
258#          then
259#             cat  >  ${mrun_path}/statistik/mrun_statistik  <<  %STATEND%
260#MRUN-calls on $localhost
261#
262#date and time                      user        localhost   remotehost  termination mrun-command
263#--------------------------------------------------------------------------------------------------------------------
264#%STATEND%
265#             chmod  666  ${mrun_path}/statistik/mrun_statistik
266#          fi
267#
268#             # EINTRAG IN DIE STATISTIK-DATEI
269#          string4=$host
270#          string5=$locat
271#          if [[ "$job_on_file" = ""  &&  $locat != control_c  &&  $locat != user_abort ]]
272#          then
273#             if [[ $do_batch = true ]]
274#             then
275#                printf "$string1$string2$string3$string4$string5$mrun_com \n"  >>  ${mrun_path}/statistik/mrun_statistik
276#             else
277#                printf "$string1$string2$string3$string4$string5$mc \n"  >>  ${mrun_path}/statistik/mrun_statistik
278#             fi
279#          fi
280          echo " " > /dev/null
281       fi
282
283       if [[ $locat != normal  &&  $locat != control_c  &&  $locat != local_compile ]]
284       then
285
286              # EVENTUELLE ERROR-KOMMANDOS ABARBEITEN
287          (( i = 0 ))
288          while (( i < iec ))
289          do
290             (( i = i + 1 ))
291             printf "\n  *** Execution of ERROR-command:\n"
292             printf "  >>> ${err_command[$i]}\n"
293             eval  ${err_command[$i]}
294          done
295          if [[ -n $interpreted_config_file ]]  then
296             rm -rf  $interpreted_config_file
297          fi
298          if [[ -n .mrun_environment ]]  then
299             rm -rf  .mrun_environment
300          fi
301          if [[ $tmpcreate = true ]]
302          then
303             printf "\n  *** Contents of \"$TEMPDIR\":\n"
304             ls -al; cd
305             [[ $delete_temporary_catalog = true ]]  &&  rm -rf $TEMPDIR
306          fi
307          if [[ -f ~/job_queue/JOBINFO.$QSUB_REQID ]]
308          then
309             rm -rf  ~/job_queue/JOBINFO.$QSUB_REQID
310          fi
311          printf "\n\n+++ MRUN killed \n\n"
312       elif [[ $locat != control_c ]]
313       then
314          printf "\n\n --> all actions finished\n\n"
315          printf "     Bye, bye $usern !!\n\n"
316       fi' exit
317
318
319    # BEI TERMINAL-BREAK:
320 trap 'rm -rf  tmp_mrun
321       [[ $tmpcreate = true ]]  &&  (cd; rm -rf $TEMPDIR)
322       if [[ -f ~/job_queue/JOBINFO.$QSUB_REQID ]]
323       then
324          rm -rf  ~/job_queue/JOBINFO.$QSUB_REQID
325       fi
326       printf "\n+++ MRUN killed by \"^C\" \n\n"
327       locat=control_c
328       exit
329      ' 2
330
331
332    # CHECK IF THE PATH FOR THE PALM BINARIES (SCRIPTS+UTILITY-PROGRAMS) HAS
333    # BEEN SET
334 if [[ "$PALM_BIN" = "" ]]
335 then
336    printf "\n  +++ environment variable PALM_BIN has not been set"
337    printf "\n      please set it to the directory where the PALM scripts are located"
338    locat=palm_bin; exit
339 fi
340
341
342
343    # SHELLSCRIPT-OPTIONEN EINLESEN UND KOMMANDO NEU ZUSAMMENSETZEN, FALLS ES
344    # FUER FOLGEJOBS BENOETIGT WIRD
345 while  getopts  :a:AbBc:Cd:D:FG:h:H:i:IkK:m:M:n:o:Op:P:q:r:R:s:St:T:u:U:vxX: option
346 do
347   case  $option  in
348       (a)   afname=$OPTARG;;
349       (A)   store_on_archive_system=false; mc="$mc -A";;
350       (b)   do_batch=true; mc="$mc -b";;
351       (B)   delete_temporary_catalog=false; mc="$mc -B";;
352       (c)   config_file=$OPTARG; mc="$mc -c$OPTARG";;
353       (C)   restart_run=true; mc="$mc -C";;
354       (d)   fname=$OPTARG; mc="$mc -d$OPTARG";;
355       (D)   cpp_opts="$cpp_opts $OPTARG"; mc="$mc -D$OPTARG";;
356       (F)   job_on_file="-D"; mc="$mc -F";;
357       (G)   global_revision=$OPTARG; mc="$mc -G'$OPTARG'";;
358       (h)   host=$OPTARG; mc="$mc -h$OPTARG";;
359       (H)   fromhost=$OPTARG; mc="$mc -H$OPTARG";;
360       (i)   input_list=$OPTARG; mc="$mc -i'$OPTARG'";;
361       (I)   ignore_archive_error=true; mc="$mc -I";;
362       (k)   keep_data_from_previous_run=true; mc="$mc -k";;
363       (K)   additional_conditions="$OPTARG"; mc="$mc -K$OPTARG";;
364       (m)   memory=$OPTARG; mc="$mc -m$OPTARG";;
365       (M)   makefile=$OPTARG; mc="$mc -M$OPTARG";;
366       (n)   node_usage=$OPTARG; mc="$mc -n$OPTARG";;
367       (o)   output_list=$OPTARG; mc="$mc -o'$OPTARG'";;
368       (O)   use_openmp=true; mc="$mc -O";;
369       (p)   package_list=$OPTARG; mc="$mc -p'$OPTARG'";;
370       (P)   return_password=$OPTARG; mc="$mc -P$OPTARG";;
371       (q)   queue=$OPTARG; mc="$mc -q$OPTARG";;
372       (r)   run_mode=$OPTARG; mc="$mc -r'$OPTARG'";;
373       (R)   remotecall=true;return_addres=$OPTARG; mc="$mc -R$OPTARG";;
374       (s)   source_list=$OPTARG; mc="$mc -s'$OPTARG'";;
375       (S)   read_from_config=false; mc="$mc -S";;
376       (t)   cpumax=$OPTARG; mc="$mc -t$OPTARG";;
377       (T)   tasks_per_node=$OPTARG; mc="$mc -T$OPTARG";;
378       (u)   remote_username=$OPTARG; mc="$mc -u$OPTARG";;
379       (U)   return_username=$OPTARG; mc="$mc -U$OPTARG";;
380       (v)   silent=true; mc="$mc -v";;
381       (x)   do_trace=true;set -x; mc="$mc -x";;
382       (X)   numprocs=$OPTARG; mc="$mc -X$OPTARG";;
383       (\?)  printf "\n  +++ unknown option $OPTARG \n"
384             printf "\n  --> type \"$0 ?\" for available options \n"
385             locat=parameter;exit;;
386   esac
387 done
388
389
390    # EVTL. POSITIONSPARAMETER EINLESEN
391    # ZUR ZEIT GIBT ES NUR DEN PARAMETER ? (=KURZINFO)
392 shift OPTIND-1
393
394
395    # KURZE AUFRUFBESCHREIBUNG WIRD HIER AUSGEGEBEN
396 if [[ "$1" = "?" ]]
397 then
398   (printf "\n  *** mrun can be called as follows:\n"
399    printf "\n      $mrun_script_name  -b -c.. -d.. -D.. -f.. -F -h.. -i.. -I -K.. -m.. -o.. -p.. -r.. -R -s.. -t.. -T.. -v -x -X..  <modus>\n"
400    printf "\n      Description of available options:\n"
401    printf "\n      Option  Description                              Default-Value"
402    printf "\n        -a    base name of input files                 equiv. -d"
403    printf "\n        -A    no archiving when using file-attribute fl"
404    printf "\n        -b    batch-job on local machine               ---"
405    printf "\n        -B    do not delete temporary directory at end ---"
406    printf "\n        -c    configuration file                       .mrun.config"
407    printf "\n        -d    base name of files attached to program   test"
408    printf "\n        -D    preprocessor(cpp)-directives             \"\" "
409    printf "\n        -F    create remote job file only              ---"
410    printf "\n        -h    execution host                           $localhost_realname"
411    printf "\n        -i    INPUT control list                       \"\" "
412    printf "\n        -I    archiving errors of previous batch-jobs"
413    printf "\n              will be ignored"
414    printf "\n        -k    keep data from previous run"
415    printf "\n        -K    additional conditions for controling"
416    printf "\n              usage of conditional code and"
417    printf "\n              env-variables in configuration file      \"\" "
418    printf "\n        -m    memory demand in MB (batch-jobs)         0 MB"
419    printf "\n        -M    Makefile name                            Makefile"
420    printf "\n        -n    node usage (shared/not_shared)           depending on -h"
421    printf "\n        -o    OUTPUT control list                      \"\" "
422    printf "\n        -O    use OpenMP                               ---"
423    printf "\n        -p    software package list                    \"\" "
424    printf "\n        -q    queue                                    \"$queue\" "
425    printf "\n        -r    run control list (combines -i -o)        \"\" "
426    printf "\n        -s    filenames of routines to be compiled     \"\" "
427    printf "\n              must end with .f, .f90, .F, or .c !"
428    printf "\n              use \"..\" for more than one file and wildcards"
429    printf "\n              -s TEST compiles all files with w-permit"
430    printf "\n        -S    config file interpreted by shellscript   ---"
431    printf "\n        -t    allowed cpu-time in seconds (batch)      0"
432    printf "\n        -T    tasks per node                           depending on -h"
433    printf "\n        -u    username on remote machine               \"\" "
434    printf "\n        -v    no prompt for confirmation               ---"
435    printf "\n        -x    tracing of mrun for debug purposes       ---"
436    printf "\n        -X    # of processors (on parallel machines)   1"
437    printf "\n "
438    printf "\n      Possible values of positional parameter <modus>:"
439    printf "\n        \"?\"       -  this outline \n\n") | more
440    exit
441 elif [[ "$1" != "" ]]
442 then
443    printf "\n  +++ positional parameter $1 unknown \n"
444    locat=parameter; exit
445 fi
446
447
448
449    # KURZE STARTMELDUNG
450 printf "\n*** $version "
451 printf "\n    will be executed.     Please wait ..."
452
453
454
455    # PRUEFEN, OB KONFIGURATIONS-DATEI VORHANDEN
456 if [[ ! -f $config_file ]]
457 then
458    printf "\n\n  +++ configuration file: "
459    printf "\n           $config_file"
460    printf "\n      does not exist"
461    locat=connect; exit 
462 fi
463
464
465    # HOST-IDENTIFIER (local_host) AUS KONFIGURATIONSDATEI BESTIMMEN
466 line=""
467 grep  "%host_identifier"  $config_file  >  tmp_mrun
468 while read line
469 do
470    if [[ "$line" != ""  ||  $(echo $line | cut -c1) != "#" ]]
471    then
472       HOSTNAME=`echo $line | cut -d" " -s -f2`
473       host_identifier=`echo $line | cut -d" " -s -f3`
474       if [[ "$HOSTNAME" = $localhost_realname ]]
475       then
476          localhost=$host_identifier
477          break
478       fi
479    fi
480 done < tmp_mrun
481
482 if [[ "$localhost" = "" ]]
483 then
484    printf "\n\n  +++ no host identifier found in configuration file \"$config_file\""
485    printf "\n      for local host \"$localhost_realname\"."
486    printf "\n      Please add line"
487    printf "\n      \"\%host_identifier $localhost_realname <identifier>\""
488    printf "\n      to the configuration file."
489    locat=localhost; exit
490 fi
491
492
493
494    # HOSTSPEZIFISCHE VARIABLEN SETZEN
495 case  $localhost_realname  in
496     (breg*-en0|berni*-en0)  archive_system=tivoli;;
497     (cs*)                   archive_system=ut;;
498     (fimm.bccs.uib.no)      fimm=true;;
499     (gate|n-sx)             PATH=$PALM_BIN:$PATH:/usr/bin/nqsII;;
500     (hreg*-en0|hanni*-en0)  archive_system=tivoli;;
501     (scirocco)              scirocco=true;;
502 esac
503
504
505 
506    # BASISNAME DER INPUT-DATEIEN GLEICH ALLGEMEINEM BASISNAMEN SETZEN,
507    # WENN NICHT VOM BENUTZER ANDERS BESTIMMT
508 [[ "$afname" = "" ]]  &&  afname=$fname
509
510
511    # EVTL. RUN-MODUS DEN I/O-LISTEN HINZUFUEGEN
512 if [[ "$run_mode" != "" ]]
513 then
514    input_list="$input_list $run_mode"
515    output_list="$output_list $run_mode"
516 fi
517
518
519    # RECHNERNAMEN ABSPEICHERN, VON DEM AUS JOB GESTARTET WIRD,
520    # ALLERDINGS NUR DANN, WENN NICHT PER OPTION -H BEREITS EIN WERT
521    # ZUGEWIESEN WURDE (MRUN MACHT DIES IMMER, WENN ES SELBST BATCH-JOBS
522    # STARTET)
523 if [[ "$fromhost" = "" ]]
524 then
525    fromhost=$localhost
526 fi
527
528
529     # PRUEFEN, OB MRUN NUR TESTWEISE AUF DER LOKALEN MASCHINE KOMPILIEREN SOLL
530 if [[ "$source_list" = LOCAL_COMPILE_TEST ]]
531 then
532    source_list=TEST
533    local_compile=true
534    host=$localhost
535 fi
536   
537
538    # PRUEFEN, OB AUF REMOTE-MASCHINE GERECHNET WERDEN SOLL
539    # WERT VON do_remote WIRD FUER DATEIVERBINDUNGEN BENOETIGT.
540    # WENN AUF REMOTE-MASCHINE GERECHNET WIRD, IST GLEICHZEITIG KLAR,
541    # DASS EIN BATCH-JOB GESTARTET WERDEN MUSS
542 if [[ -n $host  &&  "$host" != $localhost ]]
543 then
544    do_batch=true
545    do_remote=true
546    case  $host  in
547        (ibm|ibmb|ibmh|ibms|ibmy|nech|neck|lctit|unics)  true;;
548        (*)  printf "\n"
549             printf "\n  +++ execution host \"$host\" not admitted for MRUN,"
550             printf "\n      or NQS not available on execution host!"
551             locat=nqs; (( iec = 0 )); exit;;
552    esac
553 else
554    host=$localhost
555 fi
556
557
558     # ZUSATZBEDINGUNGEN (OPTION -K) AUSWERTEN
559 if [[ -n $additional_conditions ]]
560 then
561#    echo $additional_conditions | cut -d" " -f1-3 | read  cond1  cond2  dummy
562    cond1=`echo $additional_conditions | cut -d" " -f1`
563    cond2=`echo $additional_conditions | cut -d" " -s -f2`
564    dummy=`echo $additional_conditions | cut -d" " -s -f3`
565    if [[ -n $dummy ]]
566    then
567       printf "\n  +++ more than 2 additional conditions given for Option \"-K\""
568       locat=options; exit
569    fi
570 fi
571
572
573    # PRUEFEN, OB EVTL. BEI VORHERGEHENDEM LAUF (KETTENJOB) EINE
574    # ARCHIVIERUNG FEHLGESCHLAGEN IST
575 if [[ -f ~/job_queue/ARCHIVE_ERROR_$fname ]]
576 then
577    if [[ $ignore_archive_error = false ]]
578    then
579       printf "\n  +++ data archiving of previous run failed"
580       printf "\n      see directory \~/job_queue on remote machine"
581       locat=archive; exit
582    else
583       printf "\n  +++ warning: data archiving in a previous run failed"
584       printf "\n      MRUN continues, trying to get backup copy"
585    fi
586 fi
587
588
589
590    # LESEN UND INTERPRETIEREN DER KONFIGURATIONS-DATEI VOM SHELLSCRIPT AUS
591    # VORUEBERGEHEND ZWINGEND AUF LINUX-RECHNERN
592 if [[ "$read_from_config" = false ]]
593 then
594
595    [[ $silent = false ]]  &&  printf "\n    Reading the configuration file... "
596    while  read zeile
597    do
598        [[ $silent = false ]]  &&  printf "."
599
600
601          # ZUERST EVENTUELL VORKOMMENDE ENVIRONMENT-VARIABLEN DURCH IHRE WERTE
602          # ERSETZEN
603       eval  zeile=\"$zeile\"
604
605
606          # INTERPRETATION DER ZEILE
607       if [[ "$(echo $zeile)" = "" ]]
608       then
609             # LEERZEILE, KEINE AKTION
610          continue
611
612       elif [[ "$(echo $zeile | cut -c1)"  =  "#" ]]
613       then
614
615             # ZEILE IST KOMMENTARZEILE
616          true
617
618       elif [[ "$(echo $zeile | cut -c1)"  =  "%" ]]
619       then
620
621             # ZEILE DEFINIERT ENVIRONMENT-VARIABLE
622          zeile=$(echo $zeile | cut -c2-)
623#          echo $zeile | cut -d" " -f1-5 | read  var  value  for_host  for_cond1  for_cond2
624          var=`echo $zeile | cut -d" " -f1`
625          value=`echo $zeile | cut -d" " -s -f2`
626          for_host=`echo $zeile | cut -d" " -s -f3`
627          for_cond1=`echo $zeile | cut -d" " -s -f4`
628          for_cond2=`echo $zeile | cut -d" " -s -f5`
629
630          if [[ "$for_host" = ""  ||  ( "$for_host" = $host  &&  "$for_cond1" = "$cond1"  &&  "$for_cond2" = "$cond2" )  ||  $(echo "$input_list$output_list"|grep -c "$for_host") != 0 ]]
631          then
632
633                # BEI COMPILER- CPP- ODER LINKEROPTIONEN EVTL ":" DURCH " "
634                # ERSETZEN. "::" WIRD DURCH ":" ERSETZT.
635             value=`echo $value | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
636
637
638                # ENVIRONMENT-VARIABLE WIRD WERT AUS KONFIGURATIONSDATEI
639                # ZUGEWIESEN, WENN SIE SELBST NOCH KEINEN WERT UEBER DIE
640                # ENTSPRECHENDE SCRIPT-OPTION ERHALTEN HAT. SOLCHE
641                # VARIABLEN HAETTEN DANN DEN WERT "" ODER IM INTEGER-FALL DEN
642                # WERT 0.  ALLGEMEINE REGEL ALSO: SCRIPT-OPTION GEHT UEBER
643                # KONFIGURATIONSDATEI
644             if [[ "$(eval echo \$$var)" = ""  ||  "$(eval echo \$$var)" = "0" ]]
645             then
646                eval  $var=\$value
647
648                   # EVTL. BILDSCHIRMAUSGABEN DER ENVIRONMENT-VARIABLEN
649                if [[ $do_trace = true ]]
650                then
651                   printf "\n*** ENVIRONMENT-VARIABLE $var = $value"
652                fi
653             fi
654
655                # WENN ENVIRONMENT-VARIABLE HOST VEREINBART, DANN SOFORT AUSWERTEN
656                # WERT VON do-remote WIRD BEI DATEIVERBINDUNGEN BENOETIGT
657                # WENN AUF REMOTE-MASCHINE GERECHNET WIRD, IST GLEICHZEITIG KLAR,
658                # DASS EIN BATCH-JOB GESTARTET WERDEN MUSS
659             if [[ $var = host ]]
660             then
661                if [[ -n $host  &&  "$host" != $localhost ]]
662                then
663                   do_batch=true
664                   do_remote=true
665                   case  $host  in
666                       (ibm|ibms|ibmy|lctit|nech|neck|unics)  true;;
667                       (*)  printf "\n  +++ no queueing system available on execution host \"$host\""
668                            locat=nqs; exit;;
669                   esac
670                else
671                   host=$localhost
672                fi
673             fi
674
675                # VOM BENUTZER DEFINIERTE ENVIRONMENT VARIABLEN MUESSEN PRINZIPIELL
676                # EXPORTIERT WERDEN, DA SIE VIELLEICHT IN WEITER UNTEN AUFZURUFEN-
677                # DEN PROGRAMMEN BENOETIGT WERDEN
678             export  $var
679          fi
680
681
682
683
684       elif [[ "$(echo $zeile | cut -c1-3)" = "EC:" ]]
685       then
686
687             # ZEILE DEFINIERT ERROR-KOMMANDO
688          (( iec = iec + 1 ))
689          zeile=$(echo $zeile | cut -c4-)
690          err_command[$iec]="$zeile"
691
692       elif [[ "$(echo $zeile | cut -c1-3)" = "IC:" ]]
693       then
694
695             # ZEILE DEFINIERT INPUT-KOMMANDO
696          (( iic = iic + 1 ))
697          zeile=$(echo $zeile | cut -c4-)
698          in_command[$iic]="$zeile"
699
700       elif [[ "$(echo $zeile | cut -c1-3)" = "OC:" ]]
701       then
702
703             # ZEILE DEFINIERT OUTPUT-KOMMANDO
704          (( ioc = ioc + 1 ))
705          zeile=$(echo $zeile | cut -c4-)
706          out_command[$ioc]="$zeile"
707
708       else
709
710             # ZEILE DEFINIERT DATEIVERBINDUNG. EINLESEN DER DATEIEIGENSCHAFTEN
711             # s2a: in/out - Feld
712             # s2b: loc    - Feld (optional)
713             # s2c: tr/ar  - Feld (optional)
714#          echo $zeile | cut -d" " -f1-2 | read  s1  s2
715          s1=`echo $zeile | cut -d" " -f1`
716          s2=`echo $zeile | cut -d" " -s -f2`
717          s2a=$(echo $s2 | cut -d":" -f1)
718          if [[ $(echo $s2 | grep -c ":") = 0 ]]
719          then
720             s2b=""
721             s2c=""
722          else
723#             echo $s2 | cut -d":" -f2-3 | sed 's/:/ /g' | read  s2b  s2c
724             s2b=`echo $s2 | cut -d":" -f2 | sed 's/:/ /g'`
725             s2c=`echo $s2 | cut -d":" -s -f3 | sed 's/:/ /g'`
726          fi
727#          echo $zeile | cut -d" " -f3-6 | read  s3  s4  s5  s6
728          s3=`echo $zeile | cut -d" " -f3`
729          s4=`echo $zeile | cut -d" " -s -f4`
730          s5=`echo $zeile | cut -d" " -s -f5`
731          s6=`echo $zeile | cut -d" " -s -f6`
732
733       
734             # ABSPEICHERN DER DATEIVERBINDUNG, FALLS IN INPUT- ODER OUTPUT-LIST
735             # VERMERKT. VARIABLE S3 KANN AUCH LISTE ENTHALTEN (FELDTRENNER ":")
736             # DATEIVERBINDUNG WIRD DANN NICHT ABGESPEICHERT UND GEPRUEFT, WENN
737             # PROGRAMMLAUF AUF REMOTE-MASCHINE ERFOLGT UND DATEI NUR LOKAL VOR-
738             # HANDEN SEIN MUSS (D.H. s2b = loc)
739          IFSALT="$IFS"; IFS="$IFS:"
740          if [[ "$s2a" = in  &&  ! ( $do_remote = true  &&  ( "$s2b" = loc  ||  "$s2b" = locopt ) ) ]]
741          then
742             found=false
743             for  actual  in  $input_list
744             do
745                for  formal  in  $s3
746                do
747                   [[ $actual = $formal  ||  "$formal" = "-" ]]  &&  found=true
748                done
749             done
750             if [[ $found = true ]]
751             then
752                (( iin = iin + 1 ))
753                localin[$iin]=$s1; transin[$iin]=$s2b; actionin[$iin]=$s2c;
754                typein[$iin]=$s3; pathin[$iin]=$s4; endin[$iin]=$s5;
755                extin[$iin]=$s6
756             fi
757          elif [[ "$s2a" = out  &&  ! ( $do_remote = true  &&  "$s2b" = loc ) ]]
758          then
759             found=false
760             for  actual  in  $output_list
761             do
762                for  formal  in  $s3 
763                do
764                   [[ $actual = $formal  ||  "$formal" = "-"  ]]  &&  found=true
765                done
766             done
767             if [[ $found = true ]]
768             then
769                (( iout = iout + 1 ))
770                localout[$iout]=$s1; actionout[$iout]=$s2c; typeout[$iout]=$s3;
771                pathout[$iout]=$s4; endout[$iout]=$s5; extout[$iout]=$s6
772             fi
773          elif [[ "$s2a" != in  &&  "$s2a" != out ]]
774          then
775             printf "\n  +++ I/O-attribute in configuration file $config_file has the invalid"
776             printf "\n      value \"$s2\". Only \"in\" and \"out\" are allowed!"
777             locat=connect; exit
778          fi
779          IFS="$IFSALT"
780       fi
781    done < $config_file
782
783 else
784
785
786       # INTERPRETATION DER KONFIGURATIONSDATEI MITTELS FORTRAN 90 - PROGRAMM
787    [[ $silent = false ]]  &&  printf "..."
788    export  cond1 cond2 config_file do_remote do_trace input_list localhost output_list
789    export  interpreted_config_file=.icf.$RANDOM
790
791#    case  $localhost_realname  in
792#        (caurus|twister)      interpret_config.hp;;
793#        (bora|breva|elephanta|gallego|gregale|hababai|maestro|orkan|ostria)  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/muksoft/packages/intel_ifc/8.1/lib/; interpret_config_9.x;;
794#        (levanto|vorias)      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/muksoft/packages/intel/ifort/9.1.037/lib/; interpret_config_9.x_levanto;;
795#        (quanero)             export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel_fc_80/lib; interpret_config_9.x;;
796#        (*)                   interpret_config.x;;
797#    esac
798
799
800       # ENVIRONMENT-VARIABLEN FUER INTERPRET_CONFIG UEBER NAMELIST_DATEI ZUR
801       # VERFUEGUNG STELLEN
802    cat  >  .mrun_environment  <<  %%END%%
803 &mrun_environment  cond1 = '$cond1', cond2 = '$cond2',
804                    config_file = '$config_file', do_remote = '$do_remote',
805                    do_trace = '$do_trace', host = '$host',
806                    input_list = '$input_list', icf = '$interpreted_config_file',
807                    localhost = '$localhost', output_list = '$output_list' /
808
809%%END%%
810
811       # WERTE VON MRUN-OPTIONEN SICHERN UND DAMIT GEGEBENENFALLS SPAETER DIE
812       # IN DER KONFIGURAIONSDATEI ANGEGEBENEN WERTE UEBERSTEUERN
813    mrun_memory=$memory
814    mrun_cpumax=$cpumax
815    mrun_numprocs=$numprocs
816
817    if [[ $localhost_realname = "gate" ]]
818    then
819       interpret_config_gate.x
820    else
821       interpret_config.x
822    fi
823    rm .mrun_environment
824
825
826       # AUSFUEHRUNG DER GENERIERTEN SHELL-KOMMANDOS IN DIESER SHELL
827    chmod  u+x  $interpreted_config_file
828    export PATH=$PATH:.
829    . $interpreted_config_file
830    rm  $interpreted_config_file
831
832
833       # OPTIONSWERTE UEBERSTEUERN KONFIGURATIONSDATEI
834    [[ $mrun_memory     != 0  ]]  &&  memory=$mrun_memory
835    [[ $mrun_cpumax     != 0  ]]  &&  cpumax=$mrun_cpumax
836    [[ "$mrun_numprocs" != "" ]]  &&  numprocs=$mrun_numprocs
837
838 fi
839
840
841    # QUELLTEXTVERZEICHNIS AUF LOKALER MASCHINE AUS KONFIGURATIONSDATEI
842    # BESTIMMEN (WUERDE SONST EVTL. DAS VERZEICHNIS DES JEWEILS UNTER -h
843    # ANGEGEBENEN REMOTE-RECHNERS SEIN)
844    # BEI BATCH-JOBS SIND DIE ZU UEBERSETZENDEN PROGRAMMTEILE SCHON KOMPLETT
845 if [[ "$SOURCES_COMPLETE" = "" ]]
846 then
847
848       # ZUERST PRUEFEN, OB EIN GLOBALER QUELLTEXTPFAD FUER ALLE RECHNER
849       # VEREINBART WURDE
850    source_path=""
851    line=""
852    grep "%source_path" $config_file  >  tmp_mrun
853    while read line
854    do
855       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
856       then
857          if [[ "$(echo $line | cut -d" " -f3)" = "" ]]
858          then
859             global_source_path=`echo $line | cut -d" " -f2`
860          fi
861       fi
862    done  <  tmp_mrun
863
864    line=""
865    found=false
866    grep  " $localhost" $config_file | grep "%source_path"  >  tmp_mrun
867    while read line
868    do
869       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
870       then
871          if [[ $found = true ]]
872          then
873             printf "\n\n  +++ more than one source path found in configuration file"
874             printf "\n      for local host \"$localhost\" "
875             locat=source_path; exit
876          fi
877          source_path=`echo $line | cut -d" " -f2`
878          found=true
879       fi
880    done  <  tmp_mrun
881    rm  tmp_mrun
882
883    if [[ "$source_path" = "" ]]
884    then
885       if [[ "$global_source_path" != "" ]]
886       then
887          source_path=$global_source_path
888       else
889          printf "\n\n  +++ no source path found in configuration file"
890          printf "\n      for local host \"$localhost\" "
891          locat=source_path; exit
892       fi
893    fi
894    eval source_path=$source_path
895
896    if [[ ! -d $source_path ]]
897    then
898       printf "\n\n  +++ source path \"$source_path\" on local host"
899       printf "\n      \"$localhost\" does not exist"
900       locat=source_path; exit
901    fi
902
903 fi
904
905
906    # GLOBALE REVISIONSNUMMER ERMITTELN (FORTSETZUNGSLAEUFEN WIRD DIESE
907    # DURCH OPTION -G MITGETEILT)
908 if [[ "$global_revision" = "" ]]
909 then
910    global_revision=`svnversion $source_path  2>/dev/null`
911    global_revision="Rev: $global_revision"
912 fi
913
914
915    # NOCHMAL PRUEFEN, OB AUF REMOTE-MASCHINE GERECHNET WERDEN SOLL
916    # (HOST KANN IN KONFIGURATIONSDATEI ANDERS FESTGELEGT WORDEN SEIN)
917    # WERT VON do_remote WIRD FUER DATEIVERBINDUNGEN BENOETIGT.
918    # WENN AUF REMOTE-MASCHINE GERECHNET WIRD, IST GLEICHZEITIG KLAR,
919    # DASS EIN BATCH-JOB GESTARTET WERDEN MUSS
920 if [[ -n $host  &&  "$host" != $localhost ]]
921 then
922    do_batch=true
923    do_remote=true
924    case  $host  in
925        (ibm|ibmb|ibmh|ibms|ibmy|lctit|nech|neck|unics)  true;;
926        (*)  printf "\n"
927             printf "\n  +++ execution host \"$host\" not admitted for MRUN,"
928             printf "\n      or no queueing system available on execution host!"
929             locat=nqs; (( iec = 0 )); exit;;
930    esac
931 else
932    host=$localhost
933 fi
934
935
936    # PRUEFUNG EINIGER PROZESSORZAHLANGABEN BEI RECHNUNGEN AUF PARALLELRECHNERN
937 if [[ "$cond1" = parallel  ||  "$cond2" = parallel ]]
938 then
939
940       # PRUEFEN, OB DIE ANZAHL DER ZU VERWENDENDEN PES ANGEGEBEN WURDE
941    if [[ ! -n $numprocs ]]
942    then
943       printf "\n"
944       printf "\n  +++ option \"-K parallel\" requires additional specification"
945       printf "\n      of the number of processors to be used by"
946       printf "\n      mrun-option \"-X\" or by environment-variable"
947       printf "\n      \"numprocs\" in the configuration file"
948       locat=numprocs; (( iec = 0 )); exit
949    fi
950
951       # PRUEFEN, OB DIE PROZESSORANZAHL PRO KNOTEN ANGEGEBEN WURDE (GGF.
952       # DEFAULT-WERT SETZEN) UND OB SIE EIN GANZZAHLIGER TEILER DER
953       # GESAMTPROZESSORANZAHL IST
954    if [[ $host = nech  ||  $host = neck  ||  $host = ibmh  ||  $host = ibmb  ||  $host = ibms ]]
955    then
956       [[ "$tasks_per_node" = "" ]]  &&  tasks_per_node=6
957       (( ival = $tasks_per_node ))
958       (( pes = numprocs ))
959#       if [[ $(echo $package_list | grep -c dvrp_graphics+1PE) = 1 ]]
960#       then
961#          (( pes = pes - 1 ))
962#       fi
963       (( ii = pes / ival ))
964       if (( pes - ii * ival > 0 ))
965       then
966          printf "\n"
967          printf "\n  +++ tasks per node (option \"-T\") must be an integral"
968          printf "\n      divisor of the total number of processors (option \"-X\")"
969          printf "\n      values of this mrun-call: \"-T $tasks_per_node\" \"-X $numprocs\""
970          locat=tasks_per_node; (( iec = 0 )); exit
971       fi
972    fi
973
974       # IBMY HAT NUR EINEN KNOTEN
975    if [[ $host = ibmy ]]
976    then
977       if [[ "$tasks_per_node" != ""  &&  "$tasks_per_node" != "$numprocs" ]]
978       then
979          printf "\n"
980          printf "\n  +++ on ibmy, tasks per node (option \"-T\") must be equal to the"
981          printf "\n      total number of processors (option \"-X\")"
982          printf "\n      values of this mrun-call: \"-T $tasks_per_node\" \"-X $numprocs\""
983          locat=tasks_per_node; (( iec = 0 )); exit
984       fi
985    fi
986
987       # FALLS OPENMP PARALLELISIERUNG VERWENDET WERDEN SOLL, ANZAHL VON THREADS
988       # SETZEN UND ZAHL DER TASKS PRO KNOTEN AUF 1 SETZEN
989    if [[ $use_openmp = true ]]
990    then
991       threads_per_task=$tasks_per_node
992       tasks_per_node=1
993    fi
994    OOPT="-O $threads_per_task"
995    TOPT="-T $tasks_per_node"
996
997       # GESAMTZAHL DER KNOTEN BESTIMMEN
998    if [[ "$tasks_per_node" != "" ]]
999    then
1000       (( nodes = numprocs / ( tasks_per_node * threads_per_task ) ))
1001    fi
1002
1003       # PRUEFEN, OB NODE USAGE EINEN ERLAUBTEN WERT HAT BZW. DEN DEFAULT
1004       # SETZEN
1005    if [[ $node_usage = default ]]
1006    then
1007       if [[ $host = ibms ]]
1008       then
1009          node_usage=shared
1010       else
1011          node_usage=not_shared
1012       fi
1013    fi
1014    if [[ $node_usage != shared  &&  $node_usage != not_shared ]]
1015    then
1016       printf "\n"
1017       printf "\n  +++ node usage (option \"-n\") is only allowed to be set"
1018       printf "\n      \"shared\" or \"not_shared\""
1019       locat=tasks_per_node; (( iec = 0 )); exit
1020    fi
1021
1022 fi
1023
1024    # PRUEFEN, OB HOSTFILE EXISTIERT
1025 if [[ -n $hostfile ]]
1026 then
1027    if [[ ! -f $hostfile ]]
1028    then
1029       printf "\n"
1030       printf "\n  +++ hostfile \"$hostfile\" does not exist"
1031       locat=hostfile; exit
1032    fi
1033 fi
1034
1035    # PRUEFEN, OB RHOSTS DATEI EXISTIERT. GEGEBENENFALLS ANLEGEN BZW. ERWEITERN
1036 if [[ $host = ibmy  &&  $do_remote = false ]]
1037 then
1038    if [[ ! -f $HOME/.rhosts ]]
1039    then
1040       echo  "gfdl5.yonsei.ac.kr"  >  $HOME/.rhosts
1041       printf "\n\n  *** file:"
1042       printf "\n           $HOME/.rhosts"
1043       printf "\n      was created\n"
1044    fi
1045    if [[ $(grep -c gfdl5.yonsei.ac.kr $HOME/.rhosts) = 0 ]]
1046    then
1047       echo  "gfdl5.yonsei.ac.kr"  >>  $HOME/.rhosts
1048       printf "\n\n  *** file:"
1049       printf "\n           $HOME/.rhosts"
1050       printf "\n      was extended by the name of the current host\n"
1051    fi
1052 fi
1053
1054
1055
1056    # FALLS NICHT VORGEGEBEN, DEFAULT-QUEUE AUF DER ZIELMASCHINE FESTLEGEN
1057 if [[ $queue = none ]]
1058 then
1059    case  $host  in
1060        (ibmb)       if [[ $node_usage = shared ]]
1061                     then
1062                        queue=cshare
1063                     else
1064                        queue=csolo
1065                     fi;;
1066        (ibmh)       if [[ $node_usage = shared ]]
1067                     then
1068                        queue=cshare
1069                     else
1070                        queue=csolo
1071                     fi;;
1072        (ibmy)       queue=parallel;;
1073        (lctit)      queue=default;;
1074        (nech)       queue=none;;
1075        (neck)       queue=P;;
1076        (unics)      queue=unics;;
1077    esac
1078 fi
1079
1080
1081    # EVTL. NETCDF-UNTERSTUETZUNG SETZEN
1082# case  $host  in
1083#     (decalpha)   netcdf_support=true
1084#                  netcdf_path=/usr/local/netcdf-3.5.1;;
1085#     (ibmb|ibmh)  netcdf_support=true
1086#                  netcdf_path=/aws/dataformats/netcdf-3.6.0-p1/64-32;;
1087#     (ibms)       netcdf_support=true
1088#                  netcdf_path=/applic/lib/NETCDF64;;
1089#     (ibmy)       netcdf_support=true
1090#                  netcdf_path=/usr1/users/raasch/pub/netcdf-3.6.0-p1;;
1091#     (lcmuk)      if [[ $scirocco = true ]]
1092#                  then
1093#                     netcdf_path=/opt/netcdf/3.6.2-beta4
1094#                  elif [[ $fimm = true ]]
1095#                  then
1096#                     netcdf_path=/local/netcdf
1097#                  else
1098#                     netcdf_path=/muksoft/packages/netcdf/linux
1099#                  fi;;
1100#     (lctit)      netcdf_support=true
1101#                  netcdf_path=/home2/usr5/mkanda/netcdf-3.6.2;;
1102#     (nech)       netcdf_support=true
1103#                  netcdf_path=/pool/SX-6/netcdf/netcdf-3.6.0-p1;;
1104#     (neck)       netcdf_support=true
1105#                  netcdf_path=/home/DSRC/NC/tatuyama/pub/netcdf-3.6.0-p1;;
1106# esac
1107
1108
1109    # VOLLSTAENDIGE DATEINAMEN DER INPUT-FILES BILDEN,
1110    # INPUT-DATEIEN AUF VORHANDENSEIN PRUEFEN UND EVTL. HOECHSTE ZYKLUSNUMMER
1111    # ERMITTELN
1112 (( i = 0 ))
1113 while (( i < iin ))
1114 do
1115    (( i = i + 1 ))
1116    (( maxcycle = 0 ))
1117
1118       # NAMENSBILDUNG (EVTL. IST FESTER DATEINAME VORGEGEBEN)
1119    if [[ "${actionin[$i]}" = di ]]
1120    then
1121       remotepathin[$i]=${pathin[$i]}/${endin[$i]}  # REMOTE-PFAD ERST AUF
1122                                                    # REM-MASCHINE AUSWERTEN
1123       eval filename=${pathin[$i]}/${endin[$i]}
1124    else
1125       remotepathin[$i]=${pathin[$i]}/${afname}${endin[$i]}  # REMOTE-PFAD ERST AUF
1126                                                             # REM-MASCHINE AUSWERTEN
1127       eval filename=${pathin[$i]}/${afname}${endin[$i]}
1128    fi
1129
1130       # PRUEFEN AUF VORHANDENSEIN
1131    if [[ $(ls $filename* 2>&1 | grep -c "not found") = 1  || \
1132          $(ls $filename* 2>&1 | grep -c "No such file") = 1  || \
1133          $(ls $filename* 2>&1 | grep -c "does not exist") = 1 ]]
1134    then
1135          # DATEIEN MIT EXTENSION (Z.B. NC) MUESSEN NICHT ZWINGEND VORHANDEN
1136          # SEIN, DESHALB IN SOLCHEN FAELLEN KEIN ABBRUCH. DIES IST NUR EINE
1137          # VORUEBERGEHENDE LOESUNG (OKT 05). NICHT ZWINGEND BENOETIGTE
1138          # EINGABEDATEIEN SOLLTEN EINE SPEZIELLE OPTION IN DER DATEI-
1139          # VERBINDUNGSANWEISUNG BEKOMMEN (Z.B. inopt?)
1140       if [[ "${transin[$i]}" != "locopt" ]]
1141       then
1142          printf "\n\n  +++ INPUT-file: "
1143          if [[ "${extin[$i]}" = "" ]]
1144          then
1145             printf "\n           $filename"
1146          else
1147             printf "\n           $filename.${extin[$i]}"
1148          fi
1149          printf "\n      does not exist\n"
1150          locat=input; exit
1151       else
1152          transin[$i]="unavailable"
1153       fi
1154    else
1155
1156          # ZYKLUSNUMMER FESTSTELLEN
1157       ls -1 -d $filename    >   filelist  2>/dev/null
1158       ls -1 -d $filename.*  >>  filelist  2>/dev/null
1159       while  read zeile
1160       do
1161          cycle=$(print $zeile | cut -f2 -d".")
1162          if [[ "$cycle" = "$zeile" ]]
1163          then
1164             (( icycle = 0 ))
1165          elif [[ "$cycle" = "${extin[$i]}" ]]
1166          then
1167             (( icycle = 0 ))
1168          else
1169             (( icycle = $cycle ))
1170          fi
1171          if (( icycle > maxcycle ))
1172          then
1173             (( maxcycle = icycle ))
1174             file_to_be_used=$zeile
1175          fi
1176       done <filelist
1177       rm filelist
1178
1179          # EVTL. ZYKLUSNUMMER AN DATEINAMEN ANFUEGEN
1180       if (( maxcycle > 0 ))
1181       then
1182          if [[ "${extin[$i]}" != " "  &&   "${extin[$i]}" != "" ]]
1183          then
1184             filename=${filename}.$maxcycle.${extin[$i]}
1185          else
1186             filename=${filename}.$maxcycle
1187          fi
1188       else
1189          if [[ "${extin[$i]}" != " "  &&   "${extin[$i]}" != "" ]]
1190          then
1191             filename=${filename}.${extin[$i]}
1192          fi
1193       fi
1194       
1195          # DATEINAMEN OHNE PFAD ABER MIT ZYKLUSNUMMER ABSPEICHERN,
1196          # DA SPAETER BEI RUECKSPEICHERN VOM ARCHIVSYSTEM EVTL. BENOETIGT
1197       absnamein[$i]=$filename
1198       if (( maxcycle > 0 ))
1199       then
1200          if [[ "${actionin[$i]}" = di ]]
1201          then
1202             frelin[$i]=${endin[$i]}.$maxcycle
1203          else
1204             frelin[$i]=${afname}${endin[$i]}.$maxcycle
1205          fi
1206       else
1207          if [[ "${actionin[$i]}" = di ]]
1208          then
1209             frelin[$i]=${endin[$i]}
1210          else
1211             frelin[$i]=${afname}${endin[$i]}
1212          fi
1213       fi
1214
1215    fi
1216 done
1217       
1218
1219    # VOLLSTAENDIGE DATEINAMEN (OHNE $ ODER ~) DER OUTPUT-FILES BILDEN,
1220    # OUTPUT-DATEIEN AUF VORHANDENSEIN PRUEFEN UND EVTL. HOECHSTE ZYKLUSNUMMER
1221    # ERMITTELN ODER, FALLS NICHT VORHANDEN, PRUEFEN, OB SIE SICH ANLEGEN LASSEN
1222    # DIESE AKTIONEN FINDEN NICHT STATT, WENN PROGRAMM AUF REMOTE-MASCHINE
1223    # RECHNET UND DATEI ANSCHLIESSEND TRANSFERIERT WERDEN SOLL!
1224 (( i = 0 ))
1225 while (( i < iout ))
1226 do
1227    (( i = i + 1 ))
1228    if [[ ! ( $fromhost != $localhost  &&  ( "${actionout[$i]}" = tr || "${actionout[$i]}" = tra || "${actionout[$i]}" = trpe ) ) ]]
1229    then
1230       if [[ "${actionout[$i]}" = tr  ||  "${actionout[$i]}" = trpe ]]
1231       then
1232          actionout[$i]=""
1233       elif [[ "${actionout[$i]}" = tra ]]
1234       then
1235          actionout[$i]=a
1236       fi
1237       (( maxcycle = 0 ))
1238       eval filename=${pathout[$i]}/${fname}${endout[$i]}
1239       eval catalogname=${pathout[$i]}
1240       if [[ $(ls $filename* 2>&1 | grep -c "not found") = 1  || \
1241             $(ls $filename* 2>&1 | grep -c "No such file") = 1  || \
1242             $(ls $filename* 2>&1 | grep -c "does not exist") = 1 ]]
1243       then
1244     
1245             # OUTPUT-DATEI NICHT VORHANDEN. PRUEFEN, OB ANLEGEN MOEGLICH.
1246          if  cat /dev/null > $filename 
1247          then
1248             rm  $filename
1249          else
1250
1251                # PRUEFEN, OB KATALOG VORHANDEN UND EVTL. DIESEN ANLEGEN
1252             if [[ ! -d $catalogname ]]
1253             then
1254                if  mkdir -p  $catalogname
1255                then
1256                   printf "\n\n  *** directory:"
1257                   printf "\n           $catalogname"
1258                   printf "\n      was created\n"
1259                else
1260                   printf "\n\n  +++ OUTPUT-file:"
1261                   printf "\n           $filename"
1262                   printf "\n      cannot be created, because directory does not exist"
1263                   printf "\n      and cannot be created either"
1264                   printf "\n"
1265                   locat=output  ; exit
1266                fi 2>/dev/null
1267             else
1268                printf "\n\n  +++ OUTPUT-file:"
1269                printf "\n           $filename"
1270                printf "\n      cannot be created, although directory exists"
1271                printf "\n"
1272                locat=output  ; exit
1273             fi
1274          fi 2>/dev/null
1275       else
1276
1277             # ZYKLUSNUMMER FESTSTELLEN
1278          ls -1 -d $filename    >   filelist  2>/dev/null
1279          ls -1 -d $filename.*  >>  filelist  2>/dev/null
1280          while  read zeile
1281          do
1282             cycle=$(print $zeile | cut -f2 -d".")
1283             if [[ "$cycle" = "$zeile"  ||  "$cycle" = ${extout[$i]} ]]
1284             then
1285                (( icycle = 1 ))
1286             else
1287                (( icycle = $cycle + 1 ))
1288             fi
1289             if (( icycle > maxcycle ))
1290             then
1291                (( maxcycle = icycle ))
1292             fi
1293          done <filelist
1294          rm filelist
1295       fi
1296
1297          # EVTL. ZYKLUSNUMMER AN DATEINAMEN ANFUEGEN UND PRUEFEN, OB SICH
1298          # DATEI AUCH WIRKLICH ANLEGEN LAESST. IM APPEND-FALL MUSS AN DEN
1299          # HOECHSTEN VORHANDENEN ZYKLUS-ANGEHAENGT WERDEN. ANLAGEPRUEFUNG
1300          # IST DANN NATUERLICH NICHT ZULAESSIG BZW. MOEGLICH
1301       if [[ "${actionout[$i]}" != a ]]
1302       then
1303          if (( maxcycle > 0 ))
1304          then
1305             filename=${filename}.$maxcycle
1306             if  cat /dev/null > $filename 
1307             then
1308                rm  $filename
1309             else
1310                printf "\n  +++ OUTPUT-file:"
1311                printf "\n           $filename"
1312                printf "\n      cannot be created"
1313                locat=output  ; exit
1314             fi
1315          fi
1316       else
1317          (( maxcycle = maxcycle - 1 ))
1318          if (( maxcycle > 0 ))
1319          then
1320             filename=${filename}.$maxcycle
1321          fi
1322       fi
1323       
1324          # DATEINAMEN OHNE PFAD ABER MIT ZYKLUSNUMMER ABSPEICHERN,
1325          # DA SPAETER BEI ABLAGE AUF ARCHIVSYSTEM BZW. FUER
1326          # DATEI OUTPUT_FILE_CONNECTIONS EVTL. BENOETIGT
1327       pathout[$i]=$filename
1328       if (( maxcycle > 0 ))
1329       then
1330          frelout[$i]=${fname}${endout[$i]}.$maxcycle
1331       else
1332          frelout[$i]=${fname}${endout[$i]}
1333       fi
1334
1335    fi
1336 done
1337
1338
1339     # PRUEFEN, OB ENTWEDER HAUPTPROGRAMM ODER NUR EIN AUSFUEHRBARES
1340     # PROGRAMM VEREINBART WURDE (IN DIESEM FALL BRAUCHT IM WEITEREN NICHT
1341     # UEBERSETZT ZU WERDEN)
1342 if [[ "$mainprog" = ""  &&  "$executable" = "" ]]
1343 then
1344    printf "\n  +++ neither main program nor executable defined"
1345    locat=source; exit
1346 elif [[ "$mainprog" != ""  &&  "$executable" != "" ]]
1347 then
1348    printf "\n  +++ main program as well as executable defined"
1349    locat=source; exit
1350 elif [[ "$mainprog" = ""  &&  "$executable" != "" ]]
1351 then
1352    do_compile=false
1353 fi
1354
1355
1356    # ALLE ZU UEBERSETZENDEN PROGRAMMTEILE ZUSAMMENSAMMELN
1357    # BEI BATCH-JOBS IST DIES NICHT NOETIG, WEIL DIE PROGRAMMTEILE BEREITS DURCH
1358    # DEN MRUN-AUFRUF ERMITTELT SIND, DER DEN BATCH-JOB GENERIERT HAT, UND
1359    # IM VERZEICHNIS SOURCES_FOR_RUN_... ABGELEGT SIND
1360 if [[ $do_compile = true  &&  "$SOURCES_COMPLETE" = "" ]]
1361 then
1362
1363    [[ "$source_list" = LM ]]  &&  source_list=LOCALLY_MODIFIED
1364    [[ "$source_list" = WP ]]  &&  source_list=WRITE_PERMIT
1365
1366    if [[ $restart_run != true ]]
1367    then
1368       rm -rf  SOURCES_FOR_RUN_$fname
1369       mkdir   SOURCES_FOR_RUN_$fname
1370    fi
1371
1372
1373       # EVTL. ZU UEBERSETZENDE PROGRAMMTEILE DADURCH BESTIMMEN, DASS GEPRUEFT
1374       # WIRD, WELCHE DATEIEN WRITE-PERMIT BESITZEN (DATEIEN SOLLTEN DESHALB
1375       # UNTER RCS-KONTROLLE STEHEN). MIT DER VARIABLEN EXCLUDE KOENNEN
1376       # BESTIMMTE DATEIEN GRUNDSAETZLICH VON DER UEBERSETZUNG AUSGESCHLOSSEN
1377       # WERDEN. DIES IST NUR BEI MANUELLEM START VON MRUN DURCH DEN BENUTZER
1378       # MOEGLICH, DA BEI AUTOMATISCHEN RESTARTS TEST DURCH DIE TATSAECHLICH
1379       # ZU UBERSETZENDEN DATEIEN ERSETZT IST.
1380       # ALLE ERMITTELTEN DATEIEN WERDEN IM VERZEICHNIS SOURCES_FOR_RUN_...
1381       # GESAMMELT
1382    if [[ "$source_list" = WRITE_PERMIT ]]
1383    then
1384
1385       source_list=""
1386       cd  $source_path
1387
1388
1389          # ALLE MOEGLICHEN QUELLCODEDATEIEN AUFLISTEN
1390       Names=$(ls -1 *.f90 2>&1)
1391       [[ $(echo $Names | grep -c '*.f90') = 0 ]]  &&  Filenames="$Names"
1392       Names=$(ls -1 *.F90 2>&1)
1393       [[ $(echo $Names | grep -c '*.F90') = 0 ]]  &&  Filenames="$Filenames $Names"
1394       Names=$(ls -1 *.F 2>&1)
1395       [[ $(echo $Names | grep -c '*.F') = 0   ]]  &&  Filenames="$Filenames $Names"
1396       Names=$(ls -1 *.f 2>&1)
1397       [[ $(echo $Names | grep -c '*.f') = 0   ]]  &&  Filenames="$Filenames $Names"
1398       Names=$(ls -1 *.c 2>&1)
1399       [[ $(echo $Names | grep -c '*.c') = 0   ]]  &&  Filenames="$Filenames $Names"
1400
1401
1402          # DATEIEN MIT WRITE-PERMIT NACH SOURCES_FOR_RUN_... KOPIEREN
1403       for  dateiname  in  $Filenames
1404       do
1405          if [[ -w $dateiname ]]
1406          then
1407             if [[ "$exclude" = ""  ||  $(echo $exclude | grep -c $dateiname) = 0 ]]
1408             then
1409                cp  $dateiname  $working_directory/SOURCES_FOR_RUN_$fname
1410                source_list=$source_list"$dateiname "
1411             fi
1412          fi
1413       done
1414
1415       cd -  > /dev/null
1416
1417
1418    elif [[ "$source_list" = LOCALLY_MODIFIED ]]
1419    then
1420
1421          # MODIFIZIERTE DATEIEN DER SVN-ARBEITSKOPIE BESTIMMEN
1422       source_list=""
1423       cd  $source_path
1424
1425
1426          # PRUEFEN, OB VERZEICHNIS UEBERHAUPT UNTER SVN-KONTROLLE STEHT
1427       if [[ ! -d .svn ]]
1428       then
1429          printf "\n\n  +++ source directory"
1430          printf "\n         \"$source_path\" "
1431          printf "\n         is not under control of \"subversion\"."
1432          printf "\n         Please do not use mrun-option \"-s LOCALLY MODIFIED\"\n"
1433       fi
1434
1435
1436          # ALLE MODIFIZIERTEN QUELLCODEDATEIEN AUFLISTEN
1437       Filenames=""
1438       svn status  >  tmp_mrun
1439       while  read line
1440       do
1441          firstc=`echo $line | cut -c1`
1442          if [[ $firstc = M  ||  $firstc = "?" ]]
1443          then
1444             Name=`echo "$line" | cut -c8-`
1445             extension=`echo $Name | cut -d. -f2`
1446             if [[ "$extension" = f90 || "$extension" = F90 || "$extension" = f || "$extension" = F || "$extension" = c ]]
1447             then
1448                Filenames="$Filenames "$Name
1449             fi
1450          fi
1451       done < tmp_mrun
1452
1453
1454          # DATEIEN NACH SOURCES_FOR_RUN_... KOPIEREN
1455       for  dateiname  in  $Filenames
1456       do
1457          cp  $dateiname  $working_directory/SOURCES_FOR_RUN_$fname
1458          source_list=$source_list"$dateiname "
1459       done
1460
1461       cd -  > /dev/null
1462
1463
1464       # MITTELS OPTION -s ANGEGEBENE DATEIEN NACH SOURCES_FOR_RUN_... KOPIEREN
1465       # BEI AUTOMATISCHEN FORTSETZUNGSLAEUFEN SIND DORT SCHON ALLE DATEIEN
1466       # VORHANDEN
1467    elif [[ "$source_list" != ""  &&  $restart_run != true ]]
1468    then
1469
1470       cd  $source_path
1471
1472       for  filename  in  $source_list
1473       do
1474
1475             # QUELLTEXT-DATEI DARF KEINE PFADE BEINHALTEN
1476          if [[ $(print $filename | grep -c "/") != 0 ]]
1477          then
1478             printf "\n  +++ source code file:  $filename"
1479             printf "\n      must not contain (\"/\") "
1480             locat=source; exit
1481          fi
1482
1483          if [[ ! -f $filename ]]
1484          then
1485             printf "\n  +++ source code file:  $filename"
1486             printf "\n      does not exist"
1487             locat=source; exit
1488          else
1489             cp  $filename  $working_directory/SOURCES_FOR_RUN_$fname
1490          fi
1491
1492       done
1493
1494       cd -  > /dev/null
1495
1496    fi
1497
1498
1499       # PRUEFEN, OB ENTWEDER HAUPTPROGRAMM VORHANDEN UND ES EVTL. IN DER
1500       # LISTE DER ZU UEBERSETZENDEN PROGRAMMTEILE MIT ENTHALTEN IST (WENN
1501       # NICHT, WIRD ES DIESER LISTE HINZUGEFUEGT)
1502    if [[ $restart_run != true ]]
1503    then
1504
1505       if [[ ! -f "$source_path/$mainprog" ]]
1506       then
1507          printf "\n\n  +++ main program:  $mainprog"
1508          printf "\n      does not exist in source directory"
1509          printf "\n      \"$source_path\"\n"
1510          locat=source; exit
1511       else
1512          if [[ $(echo $source_list | grep -c $mainprog) = 0 ]]
1513          then
1514             cp  $source_path/$mainprog  SOURCES_FOR_RUN_$fname
1515             source_list=${mainprog}" $source_list"
1516          fi
1517       fi
1518    fi
1519
1520
1521       # DATEIEN AUS ZUSAETZLICHEM QUELLVERZEICHNIS HINZUFUEGEN
1522    if [[ $restart_run != true  &&  "$add_source_path" != "" ]]
1523    then
1524
1525          # GIBT ES DAS VERZEICHNIS UEBERHAUPT?
1526       if [[ ! -d $add_source_path ]]
1527       then
1528          printf "\n\n  +++ WARNING: additional source code directory"
1529          printf "\n      \"$add_source_path\" "
1530          printf "\n      does not exist or is not a directory."
1531          printf "\n      No source code will be used from this directory!\n"
1532          add_source_path=""
1533          sleep 3
1534       else
1535
1536          cd $add_source_path
1537
1538          Names=$(ls -1 *.f90 2>&1)
1539          [[ $(echo $Names | grep -c '*.f90') = 0 ]]  &&  AddFilenames="$Names"
1540          Names=$(ls -1 *.F90 2>&1)
1541          [[ $(echo $Names | grep -c '*.F90') = 0 ]]  &&  AddFilenames="$AddFilenames $Names"
1542          Names=$(ls -1 *.F 2>&1)
1543          [[ $(echo $Names | grep -c '*.F') = 0   ]]  &&  AddFilenames="$AddFilenames $Names"
1544          Names=$(ls -1 *.f 2>&1)
1545          [[ $(echo $Names | grep -c '*.f') = 0   ]]  &&  AddFilenames="$AddFilenames $Names"
1546          Names=$(ls -1 *.c 2>&1)
1547          [[ $(echo $Names | grep -c '*.c') = 0   ]]  &&  AddFilenames="$AddFilenames $Names"
1548
1549          cd -  > /dev/null
1550          cd  SOURCES_FOR_RUN_$fname
1551
1552          for  dateiname  in  $AddFilenames
1553          do
1554             if [[ -f $dateiname ]]
1555             then
1556                printf "\n  +++ source code file \"$dateiname\" found in additional"
1557                printf "\n      source code directory \"$add_source_path\" "
1558                printf "\n      as well as in directory \"$source_path\"."
1559                locat=source; exit
1560             fi
1561
1562             cp  $add_source_path/$dateiname  .
1563             source_list="$source_list $dateiname"
1564
1565                # Default User-Interface von der Liste entfernen, falls Datei
1566                # ein User-Interface enthaelt
1567             if [[ $( cat $dateiname | grep -c "END SUBROUTINE user_parin" ) != 0 ]]
1568             then
1569                if [[ $dateiname != user_interface.f90  &&  -f user_interface.f90 ]]
1570                then
1571                   rm -rf  user_interface.f90
1572                   source_list=`echo $source_list | sed -e 's/user_interface.f90//'`
1573                   printf "\n\n  *** default \"user_interface.f90\" removed from the files to be translated"
1574                   printf "\n      since a user-interface is found in file"
1575                   printf "\n      \"$add_source_path/$dateiname\" \n"
1576                   sleep 3
1577                else
1578                   printf "\n\n  *** user-interface file \"$dateiname\" "
1579                   printf "\n      added to the files to be translated \n"
1580                   sleep 3
1581                fi
1582             fi
1583          done
1584
1585          cd -  > /dev/null
1586       fi
1587    fi
1588
1589
1590       # ALLE UNTERPROGRAMME, DIE ZU VEREINBARTEN SOFTWAREPAKETEN GEHOEREN,
1591       # DER LISTE DER ZU UEBERSETZENDEN DATEIEN HINZUFUEGEN
1592    if [[ $restart_run != true  &&  -n $package_list ]]
1593    then
1594
1595       cd  $source_path
1596
1597       for  package  in  $package_list
1598       do
1599
1600          [[ $package = "dvrp_graphics+1PE" ]]  &&  package=dvrp_graphics
1601
1602             # ERMITTELE ALLE DATEIEN, DIE ZUM PAKET GEHOEREN
1603             # FEHLERMELDUNGEN WERDEN ABGEFANGEN, DA * AUCH VERZEICHNISSNAMEN
1604             # LIEFERT
1605          package_source_list=`grep "defined( __$package " * 2>/dev/null | cut -f1 -d:`
1606
1607
1608             # FUEGE DIESE DATEIEN DER LISTE DER ZU UEBERSETZENDEN DATEIEN
1609             # HINZU, FALLS SIE NOCH NICHT DAZUGEHOEREN
1610          for  source_list_name  in  $package_source_list
1611          do
1612             if [[ $(echo $source_list | grep -c $source_list_name) = 0 ]]
1613             then
1614
1615                    # NUR DATEIEN MIT GUELTIGEN ENDUNGEN VERWENDEN
1616                ending=`echo $source_list_name | cut -f2 -d.`
1617                if [[ "$ending" = f90  ||  "$ending" = F90  ||  "$ending" = f  ||  "$ending" = F  ||  "$ending" = c ]]
1618                then
1619                   cp  $source_list_name  $working_directory/SOURCES_FOR_RUN_$fname
1620                   source_list="$source_list $source_list_name"
1621                fi
1622             fi
1623          done
1624       done
1625
1626       cd -  > /dev/null
1627    fi
1628
1629
1630       # MAKEFILE AUF VORHANDENSEIN PRUEFEN UND KOPIEREN
1631       # BEI RESTART-LAEUFEN LIEGT ES SCHON IM VERZEICHNIS SOURCES_FOR_RUN...
1632    if [[ "$restart_run" != true ]]
1633    then
1634       [[ "$makefile" = "" ]]  &&  makefile=$source_path/Makefile
1635       if [[ ! -f $makefile ]]
1636       then
1637          printf "\n  +++ file \"$makefile\" does not exist"
1638          locat=make; exit
1639       else
1640          cp  $makefile  SOURCES_FOR_RUN_$fname/Makefile
1641       fi
1642    fi
1643
1644 fi  # do_compile=true
1645
1646
1647    # FALLS PROGRAMMTEILE UEBERSETZT WERDEN SOLLEN, FOLGEN JETZT EINIGE
1648    # UEBERPRUEFUNGEN UND DAS SETZEN DER PRAEPROZESSOR-DIREKTIVEN
1649 if [[ $do_compile = true ]]
1650 then
1651
1652       # PRAEPROZESSOR-DIREKTIVEN ZUM SELEKTIVEN AUSWAEHLEN VON CODETEILEN
1653       # ZUSAMMENSETZEN
1654    if [[ $(echo $localhost | cut -c1-3) = ibm ]]
1655    then
1656       cpp_options="${cpp_options},-D__ibm=__ibm"
1657    elif [[ $(echo $localhost | cut -c1-3) = nec ]]
1658    then
1659       cpp_options="$cpp_options -D__nec"
1660    elif [[ $(echo $localhost | cut -c1-2) = lc ]]
1661    then
1662       cpp_options="$cpp_options -D__lc"
1663    else
1664       cpp_options="$cpp_options -D__$localhost"
1665    fi
1666    if [[ $(echo $localhost | cut -c1-3) = ibm ]]
1667    then
1668       [[ -n $cond1 ]]  &&  cpp_options="${cpp_options},-D__$cond1=__$cond1"
1669       [[ -n $cond2 ]]  &&  cpp_options="${cpp_options},-D__$cond2=__$cond2"
1670#       if [[ $netcdf_support = true ]]
1671#       then
1672#          PPOPTS="$PPOPTS -Dnetcdf=netcdf"
1673#          [[ $localhost != ibms ]]      &&  PPOPTS="$PPOPTS -Dnetcdf_64bit=netcdf_64bit"
1674#       fi
1675#       if [[ $localhost = ibmy ]]
1676#       then
1677#          PPOPTS="$PPOPTS -Dibmy_special=ibmy_special"
1678#       fi
1679    else
1680       [[ -n $cond1 ]]  &&  cpp_options="$cpp_options -D__$cond1"
1681       [[ -n $cond2 ]]  &&  cpp_options="$cpp_options -D__$cond2"
1682#       if [[ $netcdf_support = true ]]
1683#       then
1684#          PPOPTS="$PPOPTS -Dnetcdf"
1685#          [[ $localhost != decalpha  &&  $localhost != lctit ]]  &&  PPOPTS="$PPOPTS -Dnetcdf_64bit"
1686#       fi
1687    fi
1688    if [[ -n $package_list ]]
1689    then
1690       for  package  in  $package_list
1691       do
1692          if [[ $(echo $localhost | cut -c1-3) = ibm ]]
1693          then
1694             if [[ $package != "dvrp_graphics+1PE" ]]
1695             then
1696                cpp_options="${cpp_options},-D__$package=__$package"
1697             else
1698                cpp_options="${cpp_options},-D__dvrp_graphics=__dvrp_graphics"
1699                export use_seperate_pe_for_dvrp_output=true
1700             fi
1701          else
1702             if [[ $package != "dvrp_graphics+1PE" ]]
1703             then
1704                cpp_options="$cpp_options -D__$package"
1705             else
1706                cpp_options="$cpp_options -D__dvrp_graphics"
1707                export use_seperate_pe_for_dvrp_output=true
1708             fi
1709          fi
1710       done
1711    fi
1712    if [[ -n $cpp_opts ]]
1713    then
1714       for  popts  in  $cpp_opts
1715       do
1716          if [[ $(echo $localhost | cut -c1-3) = ibm ]]
1717          then
1718             cpp_options="${cpp_options},-D__$popts=__$popts"
1719          else
1720             cpp_options="$cpp_options -D__$popts"
1721          fi
1722       done
1723    fi
1724
1725       # OPTION ZUM EINSCHALTEN DES PRAEPROZESSORS HINZUFUEGEN
1726#    if [[ $host = decalpha ]]
1727#    then
1728#       C_PPOPTS="-cpp  -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION $PPOPTS"
1729#    elif [[ $(echo $host | cut -c1-3) = ibm ]]
1730#    then
1731#          # blanks in PPOPTS muessen durch "," ersetzt werden
1732#       PPOPTS=`echo $PPOPTS | sed 's/ -/,-/g'`
1733#       C_PPOPTS="-qsuffix=cpp=f90 -WF,-DMPI_REAL=MPI_DOUBLE_PRECISION,$PPOPTS"
1734#    elif [[ $host = lcmuk ]]
1735#    then
1736#       C_PPOPTS="$PPOPTS -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION"
1737#    elif [[ $host = lctit ]]
1738#    then
1739#       C_PPOPTS="$PPOPTS -Mpreprocess -DMPI_REAL=MPI_DOUBLE_PRECISION -DMPI_2REAL=MPI_2DOUBLE_PRECISION"
1740#    elif [[ $(echo $host | cut -c1-3) = nec ]]
1741#    then
1742#       C_PPOPTS="-Ep -DMPI_REAL=MPI_REAL8 -DMPI_2REAL=MPI_2REAL8 -DSCFFT=dzfft -DCSFFT=zdfft $PPOPTS"
1743#    else
1744#       C_PPOPTS="$PPOPTS"
1745#    fi
1746
1747 else
1748
1749
1750       # BEI LOKALEN RECHNUNGEN PRUEFEN, OB EXECUTABLE VORHANDEN
1751    if [[ $do_remote = false ]]
1752    then
1753       if [[ ! -f $executable ]]
1754       then
1755          printf "\n  +++ executable file:  $executable"
1756          printf "\n      does not exist"
1757          locat=executable; exit
1758       fi
1759    fi
1760 fi
1761
1762
1763    # JOBMODUS FESTSTELLEN
1764 if [[ "$ENVIRONMENT" = BATCH  &&  $localhost != lctit  ||  "$QUEUE" != interactive  &&  $localhost = lctit ]]
1765 then
1766    jobmo=BATCH
1767 else
1768    jobmo=INTERACTIVE
1769 fi
1770
1771
1772    # HOSTSPEZIFISCHE DEFAULT-COMPILER SETZEN, FALLS NICHT BEREITS
1773    # DURCH BENUTZER ANDERWEITIG VEREINBART
1774 if [[ "$compiler_name" = "" ]]
1775 then
1776
1777    printf "\n  +++ no compiler specified for \"$localhost $cond1 $cond2\""
1778    locat=compiler_name; exit
1779
1780#    case  $localhost  in
1781#        (unics)                                 compiler_name=f77;;
1782#        (lctit)                                 if [[ "$cond1" = parallel  ||  "$cond2" = parallel ]]
1783#                                                then
1784#                                                   compiler_name=mpif90
1785#                                                   echo ">>> compiler=mpif90"
1786#                                                else
1787#                                                   compiler_name=pgf95
1788#                                                   echo ">>> compiler=pgf95"
1789#                                                fi;;
1790#        (nech)                                  compiler_name=sxmpif90;;
1791#        (decalpha)                              compiler_name=f95;;
1792#        (ibm|ibmb|ibmh|ibms|ibmy)               compiler_name=mpxlf95_r;;
1793#        (*)      printf "\n  +++ unknown host name: $localhost \n";
1794#                 locat=localhost; exit;;
1795#    esac
1796 fi
1797
1798
1799    # COMPILER AUF NECK UEBERSCHREIBEN
1800 [[ $localhost = neck ]]  &&  compiler_name=mpif90
1801
1802
1803
1804    # PRAEPROZESSOR-PFAD BESTIMMEN
1805 case  $localhost  in
1806     (decalpha|ibm|ibmb|ibmh|ibms|ibmy|unics)  praeproc=cpp;;
1807 esac
1808
1809
1810    # TEMPORAEREN KATALOGNAMEN BESTIMMEN
1811 kennung=$RANDOM
1812 if [[ "$tmp_user_catalog" = "" ]]
1813 then
1814    if [[ $localhost = ibmb  ||  $localhost = ibmh ]]
1815    then
1816       tmp_user_catalog=$TMPDIR
1817    elif [[ $localhost = nech ]]
1818    then
1819       tmp_user_catalog=$WRKSHR
1820    else
1821       tmp_user_catalog=/tmp
1822    fi
1823 fi
1824 TEMPDIR=$tmp_user_catalog/${usern}.$kennung
1825
1826
1827    # KATALOGNAMEN FUER ZWISCHENSPEICHERUNG VON FORTSETZUNGSLAUFDATEIEN
1828    # BESTIMMEN
1829 if [[ "$tmp_data_catalog" = "" ]]
1830 then
1831    if [[ $localhost = ibmb  ||  $localhost = ibmh ]]
1832    then
1833       tmp_data_catalog=$WORK/mrun_restart_data
1834    elif [[ $localhost = nech ]]
1835    then
1836       tmp_data_catalog=$WRKSHR/mrun_restart_data
1837    else
1838       tmp_data_catalog=/tmp/mrun_restart_data
1839    fi
1840 fi
1841
1842
1843    # EVENTUELL BEI LOKALEN RECHNUNGEN $-ZEICHEN IN ENVIRONMENT-VARIABLEN
1844    # ERSETZEN
1845 if [[ $do_remote = false  &&  $do_compile = true ]]
1846 then
1847    eval  fopts=\"$fopts\"
1848    eval  lopts=\"$lopts\"
1849 fi
1850
1851
1852
1853    # COMPILE- UND LINK-OPTIONEN BESTIMMEN
1854 fopts="$fopts $netcdf_inc $dvrp_inc"
1855 lopts="$lopts $netcdf_lib $dvrp_lib"
1856 ROPTS="$ropts"
1857 if [[ ( $(echo $host | cut -c1-3) = nec  ||  $(echo $host | cut -c1-3) = ibm  ||  $host = lctit )  &&  -n $numprocs ]]
1858 then
1859    XOPT="-X $numprocs"
1860 fi
1861
1862
1863    # BEI VERWENDUNG VON DVRP-SOFTWARE MUSS ENTSPECHENDE GRAFIK-BIBLIOTHEK
1864    # MIT EINGEBUNDEN WERDEN
1865# if [[ -n $package_list ]]
1866# then
1867#    if [[ $(echo $package_list | grep -c dvrp_graphics) != 0 ]]
1868#    then
1869#
1870#          # DVRP-GRAFIK GIBT ES NUR AUF DER IBM AM HLRN, AUF NECH/NECK UND
1871#          # DEM NOTEBOOK SCIROCCO
1872#       if [[ $host != ibmh  &&  $host != nech  &&  $host != neck  &&  $host != lcmuk  &&  "$local_compile" != true ]]
1873#       then
1874#          printf "\n"
1875#          printf "\n  +++ option -p with package \"dvrp_graphics\" only allowed on nech and ibmh"
1876#          locat=parameter; exit
1877#       fi
1878#       if [[ $host = ibmh ]]
1879#       then
1880#          if [[ $cond1 = debug  ||  $cond2 = debug ]]
1881#          then
1882#             fopts="-I/home/h/hzazchmi/lib/debug  $fopts"
1883#             lopts="$lopts -L/home/h/hzazchmi/lib/debug -lDVRP2 -lftp"
1884#          else
1885#             fopts="-I/home/h/nikevita/lib_stable/optimize  $fopts"
1886#             lopts="$lopts -L/home/h/nikevita/lib_stable/optimize -lDVRP2 -lftp"
1887#          fi
1888#       elif [[ $host = nech ]]
1889#       then
1890#          fopts="-I/import/ds9b/ipf2/b/b323014/lib/optimize  $fopts"
1891#          lopts="$lopts -L/import/ds9b/ipf2/b/b323014/lib/optimize -lDVRP2 -lftp"
1892#       elif [[ $host = neck ]]
1893#       then
1894#          fopts="-I/home/DSRC/NC/tatuyama/pub/dvrp  $fopts"
1895#          lopts="$lopts -L/home/DSRC/NC/tatuyama/pub/dvrp -lDVRP2 -lftp"
1896#       elif [[ $host = lcmuk ]]
1897#       then
1898#          fopts="-I/usr/local/lib/dvrp/optimize  $fopts"
1899#          lopts="$lopts -L/usr/local/lib/dvrp/optimize -lDVRP2 -lftp"
1900#       fi
1901#    fi
1902# fi
1903
1904
1905    # EVTL. EINBINDEN DER NETCDF-BIBLIOTHEK
1906# if [[ $netcdf_support = true ]]
1907# then
1908#    case  $host  in
1909#       (decalpha)   fopts="-I${netcdf_path}/include  $fopts"
1910#                    lopts="$lopts -L${netcdf_path}/lib -lnetcdf";;
1911#       (ibmb|ibmh)  fopts="-I ${netcdf_path}/include-64  $fopts"
1912#                    lopts="$lopts -L${netcdf_path}/lib -lnetcdf";;
1913#       (ibms)       fopts="-I /applic/netcdf64/src/f90  $fopts"
1914#                    lopts="$lopts -L${netcdf_path} -lnetcdf";;
1915#       (ibmy)       fopts="-I ${netcdf_path}/include  $fopts"
1916#                    lopts="$lopts -L${netcdf_path}/lib -lnetcdf";;
1917#       (nech|neck)  fopts="-I ${netcdf_path}/include  $fopts"
1918#                    lopts="$lopts -L${netcdf_path}/lib -lnetcdf";;
1919#       (lctit)      fopts="-I ${netcdf_path}/include  $fopts"
1920#                    lopts="$lopts -L${netcdf_path}/lib -lnetcdf";;
1921#
1922#    esac
1923# fi
1924
1925    # PRUEFEN DER CPU-ZEIT. (CPUMAX WIRD ALS ENV-VARIABLE VOM HAUTPRO-
1926    # GRAMM BENOETIGT
1927 done=false
1928 while [[ $done = false ]]
1929 do
1930    cputime=$cpumax
1931    if (( $cputime == 0 ))
1932    then
1933       printf "\n  +++ cpu-time is undefined"
1934       printf "\n  >>> Please type CPU-time in seconds as INTEGER:"
1935       printf "\n  >>> "
1936       read  cputime  1>/dev/null  2>&1
1937    else
1938       done=true
1939    fi
1940    cpumax=$cputime
1941 done
1942
1943 (( minuten = cputime / 60 ))
1944 (( sekunden = cputime - minuten * 60 ))
1945
1946
1947    # PRUEFEN DER KERNSPEICHERANFORDERUNG
1948 if [[ $do_batch = true ]]
1949 then
1950    done=false
1951    while [[ $done = false ]]
1952    do
1953       if (( memory == 0 ))
1954       then
1955          printf "\n  +++ memory demand is undefined"
1956          printf "\n  >>> Please type memory in  MByte per process  as INTEGER:"
1957          printf "\n  >>> "
1958          read  memory  1>/dev/null  2>&1
1959       else
1960          done=true
1961       fi
1962    done
1963 fi
1964
1965
1966    # PRUEFEN, OB FUER REMOTE-RECHNUNGEN EIN BENUTZERNAME ANGEGEBEN WURDE
1967 if [[ $do_remote = true  &&  -z $remote_username ]]
1968 then
1969    while [[ -z $remote_username ]]
1970    do
1971       printf "\n  +++ username on remote host \"$host\" is undefined"
1972       printf "\n  >>> Please type username:"
1973       printf "\n  >>> "
1974       read  remote_username
1975    done
1976    mc="$mc -u$remote_username"
1977 fi
1978
1979###########################################################################
1980# HEADER-AUSGABE
1981###########################################################################
1982
1983
1984 calltime=$(date)
1985 printf "\n"
1986# [[ $silent = false ]]  &&  clear
1987 printf "#--------------------------------------------------------------# \n"
1988 printf "| $version$calltime | \n"
1989 printf "|                                                              | \n"
1990 spalte1="called on:"; spalte2=$localhost_realname
1991 printf "| $spalte1$spalte2 | \n"
1992 if [[ $local_compile = false ]]
1993 then
1994    if [[ $do_remote = true ]]
1995    then
1996       spalte1="execution on:"; spalte2="$host (username: $remote_username)"
1997    else
1998       spalte1="execution on:"; spalte2="$host ($localhost_realname)"
1999    fi
2000 else
2001    spalte1="compiling test only!"; spalte2=""
2002 fi
2003 printf "| $spalte1$spalte2 | \n"
2004 if [[ -n $numprocs ]]
2005 then
2006    spalte1="number of PEs:"; spalte2=$numprocs
2007    printf "| $spalte1$spalte2 | \n"
2008 fi
2009 if [[ -n $tasks_per_node ]]
2010 then
2011    spalte1="tasks per node:"; spalte2="$tasks_per_node (number of nodes: $nodes)"
2012    printf "| $spalte1$spalte2 | \n"
2013 fi
2014 if [[ $threads_per_task != 1 ]]
2015 then
2016    spalte1="threads per task:"; spalte2="$threads_per_task"
2017    printf "| $spalte1$spalte2 | \n"
2018 fi
2019 printf "|                                                              | \n"
2020 if [[ $do_compile = true ]]
2021 then
2022    spalte1=cpp-directives:; spalte2=$cpp_options
2023    printf "| $spalte1$spalte2 | \n"
2024    zeile=$(echo "$cpp_options" | cut -c41-)
2025    while [[ "$zeile" != "" ]]
2026    do
2027       spalte1=""
2028       spalte2=$zeile
2029       printf "| $spalte1$spalte2 | \n"
2030       zeile=$(echo "$zeile" | cut -c41-)
2031    done
2032
2033    spalte1=compiler-options:; spalte2="$fopts"
2034    printf "| $spalte1$spalte2 | \n"
2035    zeile=$(echo "$fopts" | cut -c41-)
2036    while [[ "$zeile" != "" ]]
2037    do
2038       spalte1=""
2039       spalte2=$zeile
2040       printf "| $spalte1$spalte2 | \n"
2041       zeile=$(echo "$zeile" | cut -c41-)
2042    done
2043
2044    spalte1=linker-options:; spalte2=$lopts
2045    printf "| $spalte1$spalte2 | \n"
2046    zeile=$(echo "$lopts" | cut -c41-)
2047    while [[ "$zeile" != "" ]]
2048    do
2049       spalte1=""
2050       spalte2=$zeile
2051       printf "| $spalte1$spalte2 | \n"
2052       zeile=$(echo "$zeile" | cut -c41-)
2053    done
2054
2055    spalte1="main program":; spalte2=$mainprog
2056    printf "| $spalte1$spalte2 | \n"
2057 else
2058    spalte1=executable:; spalte2=$executable
2059    printf "| $spalte1$spalte2 | \n"
2060 fi
2061 printf "|                                                              | \n"
2062 spalte1="base name of files":; spalte2=$fname
2063 printf "| $spalte1$spalte2 | \n"
2064 if [[ $fname != $afname ]]
2065 then
2066    spalte1="base name of input files":; spalte2=$afname
2067    printf "| $spalte1$spalte2 | \n"
2068 fi
2069 spalte1="INPUT control list":; spalte2=$input_list
2070 printf "| $spalte1$spalte2 | \n"
2071 spalte1="OUTPUT control list":; spalte2=$output_list
2072 printf "| $spalte1$spalte2 | \n"
2073
2074 if [[ $do_batch = true  ||  "$LOADLBATCH" = yes ]]
2075 then
2076    spalte1="memory demand / PE":; spalte2="$memory MB"
2077    printf "| $spalte1$spalte2 | \n"
2078    spalte1=CPU-time:; spalte2="$minuten:$sekunden"
2079    printf "| $spalte1$spalte2 | \n"
2080 fi
2081
2082 if [[ $do_compile = true ]]
2083 then
2084    printf "|                                                              | \n"
2085    printf "| Files to be compiled:                                        | \n"
2086    zeile=$source_list
2087    while [[ "$zeile" != "" ]]
2088    do
2089       spalte3=$zeile
2090       printf "| $spalte3 | \n"
2091       zeile=$(echo "$zeile" | cut -c61-)
2092    done
2093 fi
2094 printf "#--------------------------------------------------------------#"
2095
2096
2097
2098    # BEDINGTE AUSGABE DER DATEIVERBINDUNGEN
2099 if [[ $do_trace = true ]]
2100 then
2101    (( i = 0 ))
2102    while (( i < iin ))
2103    do
2104       (( i = i + 1 ))
2105       if (( i == 1 ))
2106       then
2107          printf "\n\n >>> INPUT-file assignments:\n"
2108       fi
2109       printf "\n     ${localin[$i]} :  ${absnamein[$i]}"
2110    done
2111    (( i = 0 ))
2112    while (( i < iout ))
2113    do
2114       (( i = i + 1 ))
2115       if (( i == 1 ))
2116       then
2117          printf "\n\n >>> OUTPUT-file assignments:\n"
2118       fi
2119       printf "\n     ${localout[$i]} :  ${pathout[$i]}"
2120    done
2121    (( i = 0 ))
2122    while (( i < iic ))
2123    do
2124       (( i = i + 1 ))
2125       if (( i == 1 ))
2126       then
2127          printf "\n\n >>> INPUT-commands:\n"
2128       fi
2129       printf "\n     ${in_command[$i]}" 
2130    done
2131    (( i = 0 ))
2132    while (( i < ioc ))
2133    do
2134       (( i = i + 1 ))
2135       if (( i == 1 ))
2136       then
2137          printf "\n\n >>> OUTPUT-commands:\n"
2138       fi
2139       printf "\n     ${out_command[$i]}" 
2140    done
2141 fi
2142
2143
2144    # ABFRAGEN BEI AUFRUF AUF LOKALER MASCHINE
2145 if [[ $remotecall = false  &&  $silent = false  &&  $jobmo != BATCH ]]
2146 then
2147    antwort=dummy
2148    printf "\n\n"
2149    while [[ "$antwort" != y  &&  "$antwort" != Y  &&  "$antwort" != n  &&  "$antwort" != N ]]
2150    do
2151       printf " >>> everything o.k. (y/n) ?  "
2152       read  antwort
2153    done
2154    if [[ $antwort = n  ||  $antwort = N ]]
2155    then
2156       locat=user_abort; (( iec = 0 )); exit
2157    fi
2158    if [[ $do_batch = true ]]
2159    then
2160       printf " >>> batch-job will be created and submitted"
2161    else
2162       if [[ $local_compile = false ]]
2163       then
2164          printf " >>> MRUN will now continue to execute on this machine"
2165       else
2166          printf " >>> a test compilation will now be carried out on this machine"
2167       fi
2168    fi
2169 fi
2170 
2171
2172
2173
2174     # FALLS AUF DIESER MASCHINE GERECHNET WERDEN SOLL, WERDEN JETZT ENTSPRE-
2175     # CHENDE AKTIONEN DURCHGEFUEHRT
2176 if [[ $do_batch = false ]]
2177 then
2178
2179
2180       # TEMPORAEREN KATALOG ERZEUGEN
2181    mkdir -p  $TEMPDIR
2182    chmod  go+rx  $TEMPDIR
2183    tmpcreate=true
2184
2185
2186       # SAEMTLICHE QUELLTEXT-DATEIEN BZW. AUSFUEHRBARES PROGRAMM IN
2187       # TEMPORAERES VERZEICHNIS KOPIEREN
2188    if [[ $do_compile = true ]]
2189    then
2190
2191          # ON NEC, COMPILATION IS DONE ON HOST CROSS VIA CROSS COMPILING
2192          # CREATE A TEMPORARY DIRECTORY ON THAT MACHINE (HOME MOUNTED VIA NFS)
2193       if [[ $localhost = nech ]]
2194       then
2195          TEMPDIR_COMPILE=$HOME/work/${usern}.$kennung
2196          if  mkdir -p  $TEMPDIR_COMPILE
2197          then
2198             printf "\n  *** \"$TEMPDIR_COMPILE\" "
2199             printf "\n      is generated as temporary directory for cross compiling\n"
2200          else
2201             printf "\n  +++ creating directory \"$TEMPDIR_COMPILE\" "
2202             printf "\n      needed for cross compilation failed"
2203             locat=compile
2204             exit
2205          fi
2206       else
2207          TEMPDIR_COMPILE=$TEMPDIR
2208       fi
2209
2210
2211          # PFADNAMEN FUER DAS MAKE-DEPOSITORY ERMITTELN
2212       line=""
2213       grep "%depository_path" $config_file  >  tmp_mrun
2214       while read line
2215       do
2216          if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
2217          then
2218             if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]]
2219             then
2220                global_depository_path=`echo $line | cut -d" " -s -f2`
2221             fi
2222          fi
2223       done < tmp_mrun
2224
2225       line=""
2226       grep  " $localhost" $config_file | grep "%depository_path"  >  tmp_mrun
2227       while read line
2228       do
2229          if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
2230          then
2231             local_depository_path=`echo $line | cut -d" " -s -f2`
2232          fi
2233       done < tmp_mrun
2234
2235       if [[ "$local_depository_path" = "" ]]
2236       then
2237          if [[ "$global_depository_path" != "" ]]
2238          then
2239             local_depository_path=$global_depository_path
2240          else
2241             printf "\n\n  +++ no depository path found in configuration file"
2242             printf "\n      for local host \"$localhost\" "
2243             printf "\n      please set \"\%depository_path\" in configuration file\n"
2244             locat=config_file; exit
2245          fi
2246       fi
2247       eval local_depository_path=$local_depository_path
2248
2249       basename=`print $mainprog | cut -f1 -d"."`
2250       eval make_depository=${local_depository_path}/${basename}_current_version.tar
2251       if [[ ! -f $make_depository ]]
2252       then
2253          printf "\n"
2254          printf "\n  *** WARNING: make depository \"$make_depository\" not found"
2255          printf "\n               \"make\" will fail, if the Makefile or other source files are missing\n"
2256       else
2257          cp  $make_depository  $TEMPDIR_COMPILE
2258          cd  $TEMPDIR_COMPILE
2259          tar -xf  $make_depository  >  /dev/null  2>&1
2260          cd -  > /dev/null
2261       fi
2262
2263       cp  SOURCES_FOR_RUN_$fname/*  $TEMPDIR_COMPILE
2264
2265          # FALLS USER-INTERFACE VORHANDEN UND AUF DATEI MIT ANDEREM NAMEN
2266          # ALS user_interface.f90 LIEGT, DIESEN GEAENDERTEN NAMEN INS
2267          # MAKEFILE EINTRAGEN
2268       cd  $TEMPDIR_COMPILE
2269       interface_file=`grep -l "END SUBROUTINE user_parin" $source_list`
2270       if [[ "$interface_file" != "" ]]
2271       then
2272          interface_file=`echo $interface_file | cut -d"." -f1`
2273          mv  Makefile  Makefile_old
2274          sed "s/user_interface/$interface_file/g"  Makefile_old  >  Makefile
2275       fi
2276       cd -  > /dev/null
2277    else
2278       cp  $executable   ${TEMPDIR}/a.out
2279    fi
2280
2281
2282       # WECHSEL IN TEMPORAEREN KATALOG
2283    cd $TEMPDIR
2284    printf "\n  *** changed to temporary directory: $TEMPDIR"
2285
2286
2287       # OUTPUT-DATEI-VERBINDUNGEN AUF TEMPORAERER DATEI ABLEGEN
2288       # DIESE DATEI KANN VON SPAETER AUFZURUFENDEN BENUTZERPROZEDUREN GELESEN
2289       # WERDEN, UM ZU LOKALEN DATEINAMEN GEHOERENDE PERMANENTE NAMEN ZU
2290       # ERMITTELN
2291    (( i = 0 ))
2292    while (( i < iout ))
2293    do
2294       (( i = i + 1 ))
2295       if [[ "${actionout[$i]}" = tr  ||  "${actionout[$i]}" = tra  ||  "${actionout[$i]}" = trpe ]]
2296       then
2297          printf "${localout[$i]} ${actionout[$i]}\n${pathout[$i]}\n${localhost}_${fname}${endout[$i]}\n" >> OUTPUT_FILE_CONNECTIONS
2298       else
2299          printf "${localout[$i]} ${actionout[$i]}\n${pathout[$i]}\n${frelout[$i]}\n" >> OUTPUT_FILE_CONNECTIONS
2300       fi
2301    done
2302
2303
2304       # EVTL. UEBERSETZUNGSAKTIONEN STARTEN
2305    if [[ $do_compile = true ]]
2306    then
2307
2308
2309          # COMPILING WITH MAKE (ON NEC COMPILER IS CALLED ON HOST CROSS)
2310       printf "\n\n\n  *** compilation starts \n$striche\n"
2311       printf "  *** compilation with make using following options:\n"
2312       printf "      compilername:             $compiler_name\n"
2313       printf "      options:                  $fopts\n"
2314       printf "      preprocessor-directives:  $cpp_options \n"
2315       printf "      linker-options:           $lopts \n"
2316       printf "      source code files:        $source_list \n"
2317
2318       if [[ $localhost = nech ]]
2319       then
2320          ssh  136.172.44.192 -l $usern ". /SX/opt/etc/initsx.sh; cd \$HOME/work/${usern}.$kennung; sxmake -f Makefile PROG=a.out  F90=$compiler_name  COPT=\"$cpp_options\"  F90FLAGS=\"$fopts\"  LDFLAGS=\"$lopts\" "
2321          cp  $TEMPDIR_COMPILE/a.out  .
2322          [[ $? != 0 ]]  &&  compile_error=true
2323          rm -rf  $TEMPDIR_COMPILE
2324       else
2325          make -f Makefile PROG=a.out  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$fopts"  LDFLAGS="$lopts"
2326       fi
2327
2328       if [[ $? != 0  ||  "$compile_error" = true  ||  "$module_compile_error" = true ]]
2329       then
2330          printf "\n  +++ error occured while compiling or linking"
2331          locat=compile
2332          exit
2333       else
2334          printf "$striche\n  *** compilation finished \n"
2335       fi
2336    fi
2337
2338
2339       # FALLS NUR TESTWEISE KOMPILIERT WERDEN SOLLTE, IST MRUN JETZT FERTIG
2340    if [[ $local_compile = true ]]
2341    then
2342       cd  $HOME
2343       rm -rf $TEMPDIR
2344       locat=local_compile; exit
2345    fi
2346
2347
2348       # BEREITSTELLEN DER INPUT-DATEIEN
2349       # SCHLEIFE UEBER ALLE VOM BENUTZER ANGEGEBENEN DATEIEN
2350    (( i = 0 ))
2351    while (( i < iin ))
2352    do
2353       (( i = i + 1 ))
2354       if (( i == 1 ))
2355       then
2356          printf "\n\n  *** providing INPUT-files:\n$striche"
2357       fi
2358
2359
2360          # OPTIONALE DATEIEN BEI NICHTVORHANDENSEIN UEBERGEHEN
2361       if [[ "${transin[$i]}" = unavailable ]]
2362       then
2363          if [[ "${extin[$i]}" = ""  ||  "${extin[$i]}" = " " ]]
2364          then
2365             printf "\n  +++ WARNING: input file \"${pathin[$i]}/${afname}${endin[$i]}\" "
2366             printf "\n               is not available!"
2367          else
2368             printf "\n  +++ WARNING: input file \"${pathin[$i]}/${afname}${endin[$i]}.${extin[$i]}\" "
2369             printf "\n               is not available!"
2370          fi
2371          continue
2372       fi
2373
2374          # PRUEFEN, OB EINZELDATEI ODER DATEI PRO PROZESSOR
2375       files_for_pes=false; datentyp=file
2376       if [[ "${actionin[$i]}" = pe  &&  -n $numprocs ]]
2377       then
2378          files_for_pes=true; datentyp=directory
2379          actionin[$i]=""
2380       elif [[ "${actionin[$i]}" = pe  &&  ! -n $numprocs ]]
2381       then
2382          actionin[$i]=""
2383       elif [[ "${actionin[$i]}" = arpe  &&  -n $numprocs ]]
2384       then
2385          files_for_pes=true; datentyp=directory
2386          actionin[$i]="ar"
2387       elif [[ "${actionin[$i]}" = arpe  &&  ! -n $numprocs ]]
2388       then
2389          actionin[$i]="ar"
2390       elif [[ "${actionin[$i]}" = flpe  &&  -n $numprocs ]]
2391       then
2392          files_for_pes=true; datentyp=directory
2393          actionin[$i]="fl"
2394       elif [[ "${actionin[$i]}" = flpe  &&  ! -n $numprocs ]]
2395       then
2396          actionin[$i]="fl"
2397       fi
2398
2399       if [[ $files_for_pes = true ]]
2400       then
2401          printf "\n  >>> INPUT: ${absnamein[$i]}/....  to  ${localin[$i]}"
2402       else
2403          printf "\n  >>> INPUT: ${absnamein[$i]}  to  ${localin[$i]}"
2404       fi
2405
2406          # INPUT-DATEI FUER EINEN FORTSETZUNGSLAUF. ES WIRD GEPRUEFT,
2407          # OB DIESE DATEI NOCH AUF DEM TEMPORAEREN DATENKATALOG VORHANDEN
2408          # IST. FALLS NICHT, WIRD VERSUCHT, SIE ANSCHLIESSEND VOM ARCHIV-
2409          # SERVER ZU HOLEN
2410       if [[ "${actionin[$i]}" = fl ]]
2411       then
2412          printf "\n      $datentyp will be fetched from temporary directory \"${tmp_data_catalog}\" !"
2413          if [[ $files_for_pes = false ]]
2414          then
2415             if [[ -f "$tmp_data_catalog/${frelin[$i]}" ]]
2416             then
2417                ln  $tmp_data_catalog/${frelin[$i]}  ${localin[$i]}
2418                got_tmp[$i]=true
2419             elif [[ -f "$WORK/${frelin[$i]}"  &&  $ignore_archive_error = true ]]
2420             then
2421                printf "\n  +++ $datentyp not found in \"$tmp_data_catalog\" !"
2422                printf "\n  *** trying to use backup copy in \"$WORK\" "
2423                cp  $WORK/${frelin[$i]}  ${localin[$i]}
2424             else
2425                printf "\n  +++ $datentyp not found in \"$tmp_data_catalog\" "
2426                printf "\n      or \"$tmp_data_catalog\" does not exist!"
2427                printf "\n  *** trying to get copy from archive"
2428                actionin[$i]=ar
2429             fi
2430          else
2431             if [[ -d "$tmp_data_catalog/${frelin[$i]}" ]]
2432             then
2433                mkdir  ${localin[$i]}
2434                ln  $tmp_data_catalog/${frelin[$i]}/*  ${localin[$i]}
2435                got_tmp[$i]=true
2436             elif [[ -d "$WORK/${frelin[$i]}"  &&  $ignore_archive_error = true ]]
2437             then
2438                printf "\n  +++ $datentyp not found in \"$tmp_data_catalog\" !"
2439                printf "\n  *** trying to use backup copy in \"$WORK\" "
2440                cp -r  $WORK/${frelin[$i]}  ${localin[$i]}
2441             else
2442                printf "\n  +++ $datentyp not found in \"$tmp_data_catalog\" "
2443                printf "\n      or \"$tmp_data_catalog\" does not exist!"
2444                printf "\n  *** trying to get copy from archive"
2445                actionin[$i]=ar
2446             fi
2447          fi
2448       fi
2449
2450
2451          # DATEI LIEGT AUF ARCHIV-SERVER
2452       if [[ "${actionin[$i]}" = ar ]]
2453       then
2454
2455          if [[ $files_for_pes = false ]]
2456          then
2457             printf "\n      file will be restored from archive-system ($archive_system)!"
2458          else
2459             printf "\n      directory will be restored from archive-system ($archive_system)!"
2460          fi
2461
2462          file_restored=false
2463
2464          if [[ $archive_system = asterix ]]
2465          then
2466             do_stagein=true
2467             (( stagein_anz = 0 ))
2468             while [[ $do_stagein = true ]]
2469             do
2470                if [[ $files_for_pes = false ]]
2471                then
2472                   stagein  -O  ${frelin[$i]}  >  STAGEIN_OUTPUT
2473                else
2474                   stagein  -t  -O  ${frelin[$i]}  >  STAGEIN_OUTPUT
2475                fi
2476                cat  STAGEIN_OUTPUT
2477                if [[ $(grep -c "st.msg:i24"  STAGEIN_OUTPUT) != 0 ]]
2478                then
2479                   file_restored=true
2480                   do_stagein=false
2481                else
2482                   (( stagein_anz = stagein_anz + 1 ))
2483                   if (( stagein_anz == 10 ))
2484                   then
2485                      printf "\n  +++ stagein stoped after 10 tries"
2486                      locat=stage
2487                      exit
2488                   fi
2489                   printf "\n  +++ restoring from archive failed, trying again:"
2490                   sleep 900
2491                fi
2492             done
2493          elif [[ $archive_system = DMF ]]
2494          then
2495             if [[ $files_for_pes = false ]]
2496             then
2497                printf "\n  +++ restoring of single files impossible with $archive_system !\n"
2498                locat=DMF
2499                exit
2500             else
2501                find  $ARCHIVE/${frelin[$i]}  -type m  -print  |  dmget
2502                cp  -r $ARCHIVE/${frelin[$i]}  $PWD
2503                file_restored=true
2504             fi
2505          elif [[ $archive_system = tivoli ]]
2506          then
2507             if [[ $files_for_pes = false ]]
2508             then
2509                if [[ $localhost = ibmh ]]
2510                then
2511                   ssh  $usern@hdata.hlrn.de  "cp  $PERM/${frelin[$i]}  $PWD"
2512                else
2513                   ssh  $usern@bdata.hlrn.de  "cp  $PERM/${frelin[$i]}  $PWD"
2514                fi
2515             else
2516                (( inode = 0 ))
2517                while (( inode < nodes ))
2518                do
2519                   if [[ $localhost = ibmh ]]
2520                   then
2521                      ssh  $usern@hdata.hlrn.de  "cd $PWD; tar  xf  $PERM/${frelin[$i]}/${frelin[$i]}.node_$inode.tar"
2522                   else
2523                      ssh  $usern@bdata.hlrn.de  "cd $PWD; tar  xf  $PERM/${frelin[$i]}/${frelin[$i]}.node_$inode.tar"
2524                   fi
2525                   (( inode = inode + 1 ))
2526                done
2527             fi
2528             file_restored=true
2529          elif [[ $archive_system = ut ]]
2530          then
2531             if [[ $files_for_pes = false ]]
2532             then
2533                cp  $UT/${frelin[$i]}  .
2534             else
2535                (( inode = 0 ))
2536                while (( inode < nodes ))
2537                do
2538                   tar  xf  $UT/${frelin[$i]}/${frelin[$i]}.node_$inode.tar
2539                   (( inode = inode + 1 ))
2540                done
2541             fi
2542             file_restored=true
2543          else
2544             printf "\n  +++ archive_system=\"$archive_system\"   restore impossible!"
2545             locat=rearchive
2546             exit
2547          fi
2548
2549          if [[ $file_restored = true ]]
2550          then
2551
2552                # DATEI AUCH AUF TEMPORAERES DATENVERZEICHNIS LEGEN, DAMIT
2553                # SIE BEI WEITEREN ZUGRIFFEN NOCH VORHANDEN IST
2554             [[ ! -d $tmp_data_catalog ]]  &&  mkdir -p  $tmp_data_catalog; chmod  g+rx  $tmp_data_catalog
2555             if [[ $files_for_pes = false ]]
2556             then
2557                ln  -f  ${frelin[$i]}  $tmp_data_catalog/${frelin[$i]}
2558             else
2559                mkdir  $tmp_data_catalog/${frelin[$i]}
2560                ln  -f  ${frelin[$i]}/*  $tmp_data_catalog/${frelin[$i]}
2561             fi
2562             got_tmp[$i]=true
2563
2564                # DATEI UNTER LOKALEM NAMEN ZUR VERFUEGUNG STELLEN
2565             mv  ${frelin[$i]}  ${localin[$i]}
2566
2567          fi
2568       fi
2569
2570
2571          # DATEI LIEGT IM VOM BENUTZER ANGEGEBENEN VERZEICHNIS
2572       if [[ "${actionin[$i]}" = ""  ||  "${actionin[$i]}" = "di"  ||  "${actionin[$i]}" = "npe" ]]
2573       then
2574
2575          if [[ "${actionin[$i]}" = "npe"  &&  -n $numprocs ]]
2576          then
2577
2578                # DATEI WIRD FUER DIE PROZESSOREN EINES PARALLERECHNERS BEREITGESTELLT
2579             printf "\n      file will be provided for $numprocs processors"
2580             mkdir  ${localin[$i]}
2581             ival=$numprocs
2582             (( ii = 0 ))
2583             while (( ii <= ival-1 ))
2584             do
2585                if (( ii < 10 ))
2586                then
2587                   cp  ${absnamein[$i]}  ${localin[$i]}/_000$ii
2588                elif (( ii < 100 ))
2589                then
2590                   cp  ${absnamein[$i]}  ${localin[$i]}/_00$ii
2591                elif (( ii < 1000 ))
2592                then
2593                   cp  ${absnamein[$i]}  ${localin[$i]}/_0$ii
2594                else
2595                   cp  ${absnamein[$i]}  ${localin[$i]}/_$ii
2596                fi
2597                (( ii = ii + 1 ))
2598             done
2599
2600          else
2601
2602             if [[ $files_for_pes = true ]]
2603             then
2604
2605                   # DIE DEN PROZESSOREN EINES PARALLELRECHNERS ZUGEHOERIGEN
2606                   # DATEIEN WERDEN BEREITGESTELLT, INDEM ZUERST DER GESAMTE
2607                   # KATALOGINHALT KOPIERT UND DANN DIE EINZELNEN DATEIEN
2608                   # PER MOVE UMBENANNT WERDEN
2609                printf "\n      providing $numprocs files for the respective processors"
2610                mkdir  ${localin[$i]}
2611                cp -r  ${absnamein[$i]}/*  ${localin[$i]}
2612
2613             else
2614                   # BEREITSTELLUNG AUF EINPROZESSORRECHNERN
2615                cp  ${absnamein[$i]}  ${localin[$i]}
2616             fi
2617          fi
2618       fi
2619
2620    done
2621    if (( i != 0 ))
2622    then
2623       printf "\n$striche\n  *** all INPUT-files provided \n"
2624    fi
2625
2626
2627       # NAMELIST-DATEI MIT WERTEN VON ENVIRONMENT-VARIABLEN ERZEUGEN (ZU
2628       # LESEN VON PALM)
2629    cat  >  ENVPAR  <<  %%END%%
2630 &envpar  run_identifier = '$fname', host = '$localhost',
2631          write_binary = '$write_binary', tasks_per_node = $tasks_per_node,
2632          maximum_cpu_time_allowed = ${cpumax}.,
2633          revision = '$global_revision' /
2634
2635%%END%%
2636
2637
2638       # EVENTUELLE INPUT-KOMMANDOS ABARBEITEN
2639    (( i = 0 ))
2640    while (( i < iic ))
2641    do
2642       (( i = i + 1 ))
2643       if (( i == 1 ))
2644       then
2645          printf "\n\n  *** execution of INPUT-commands:\n$striche"
2646       fi
2647       printf "\n  >>> ${in_command[$i]}"
2648       eval  ${in_command[$i]}
2649       if (( i == iic ))
2650       then
2651          printf "\n$striche\n"
2652       fi
2653    done
2654
2655
2656       # VERBLEIBENDE CPU-ZEIT BERECHNEN
2657    cpurest=${cpumax}.
2658
2659
2660       # PROGRAMMSTART
2661    printf "\n\n  *** execution starts in directory\n      \"`pwd`\"\n$striche\n"
2662    PATH=$PATH:$TEMPDIR
2663
2664    if [[ "$cond1" = debug  ||  "$cond2" = debug ]]
2665    then
2666       if [[ "$ENVIRONMENT" = BATCH ]]
2667       then
2668          printf "\n  +++ debug is allowed in interactive mode only"
2669          locat=debug
2670          exit
2671       fi
2672       if [[ $localhost = decalpha ]]
2673       then
2674          dxladebug  a.out
2675       elif [[ $localhost = ibmb  ||  $localhost = ibmh ]]
2676       then
2677
2678             # SETUP THE IBM MPI ENVIRONMENT
2679          export MP_SHARED_MEMORY=yes
2680          export AIXTHREADS_SCOPE=S
2681          export OMP_NUM_THREADS=$threads_per_task
2682          export AUTHSTATE=files
2683          export XLFRTEOPTS="nlwidth=132:err_recovery=no"    # RECORD-LENGTH OF NAMELIST-OUTPUT
2684
2685             # FOLLOWING OPTIONS ARE MANDATORY FOR TOTALVIEW
2686          export MP_ADAPTER_USE=shared
2687          export MP_CPU_USE=multiple
2688          export MP_TIMEOUT=1200
2689
2690          unset  MP_TASK_AFFINITY
2691
2692             # SO FAR, TOTALVIEW NEEDS HOSTFILE MECHANISM FOR EXECUTION
2693          #(( ii = 1 ))
2694          #while (( ii <= $numprocs ))
2695          #do
2696          #   echo  $localhost_realname  >>  hostfile
2697          #   (( ii = ii + 1 ))
2698          #done
2699          #export MP_HOSTFILE=hostfile
2700
2701          if [[ "$LOADLBATCH" = yes ]]
2702          then
2703             totalview   poe  a.out  $ROPTS
2704          else
2705             echo totalview   poe  -a a.out  -procs $numprocs  -rmpool 0  -nodes 1   $ROPTS
2706             export TVDSVRLAUNCHCMD=ssh
2707             totalview   poe  -a a.out  -procs $numprocs  -rmpool 0  -nodes 1   $ROPTS
2708          fi
2709       else
2710          printf "\n  +++ no debug available on \"$localhost\" "
2711          printf "\n      or not implemented in mrun so far"
2712          locat=debug
2713          exit
2714       fi
2715    else
2716       if [[ -n $numprocs ]]
2717       then
2718
2719             # RUNNING THE PROGRAM ON PARALLEL MACHINES
2720          if [[ $(echo $host | cut -c1-3) = ibm ]]
2721          then
2722                # SETUP THE IBM MPI ENVIRONMENT
2723             export MP_SHARED_MEMORY=yes
2724             export AIXTHREAD_SCOPE=S
2725             export OMP_NUM_THREADS=$threads_per_task
2726             export XLSMPOPTS="spins=0:yields=0:stack=20000000"
2727             export AUTHSTATE=files
2728             export XLFRTEOPTS="nlwidth=132:err_recovery=no"    # RECORD-LENGTH OF NAMELIST-OUTPUT
2729             #  export MP_PRINTENV=yes
2730
2731                # TUNING-VARIABLEN ZUR VERBESSERUNG DER KOMMUNIKATION
2732                # ZEIGEN ABER DERZEIT (SEP 04, FEDERATION) KAUM WIRKUNG
2733             export MP_WAIT_MODE=poll
2734             [[ $node_usage = not_shared ]]  &&  export MP_SINGLE_THREAD=yes
2735#             export MP_EAGER_LIMIT=65535
2736
2737#                # TESTWEISE FUER TURBOMPI (JAN 05)
2738#             export MPJ_MTAB=128
2739#             export MPJ_ALLTOALL=1
2740#             export MPJ_ALLTOALLV=1
2741
2742             if [[ "$LOADLBATCH" = yes ]]
2743             then
2744                printf "\n--- Control: OMP_NUM_THREADS = \"$OMP_NUM_THREADS\" \n"
2745                if [[ "$cond1" = hpmcount  ||  "$cond2" = hpmcount ]]
2746                then
2747                   /opt/optibm/HPM_2_4_1/bin/hpmcount  a.out  $ROPTS  >  aout_output  2>&1
2748                else
2749                   poe ./a.out  $ROPTS  >  aout_output  2>&1
2750                fi
2751             else
2752                if [[ $localhost = ibmb  ||  $localhost = ibmh  ||  $localhost = ibms ]]
2753                then
2754                   poe  a.out  -procs $numprocs  -nodes 1  -rmpool 0  $ROPTS  >  aout_output  2>&1
2755                elif [[ $localhost = ibmy ]]
2756                then
2757                   if [[ -f $hostfile ]]
2758                   then
2759                      cp  $hostfile  hostfile
2760                   else
2761                      (( ii = 1 ))
2762                      while (( ii <= $numprocs ))
2763                      do
2764                         echo  $localhost_realname  >>  hostfile
2765                         (( ii = ii + 1 ))
2766                      done
2767                   fi
2768                   export MP_HOSTFILE=hostfile
2769                   ./a.out  -procs $tasks_per_node  $ROPTS  >  aout_output  2>&1
2770                else
2771                   if [[ "$host_file" = "" ]]
2772                   then
2773                      printf "\n  +++ no hostfile given in configuration file"
2774                      locat=config_file
2775                      exit
2776                   else
2777                      eval host_file=$host_file
2778                   fi
2779                   export MP_HOSTFILE=$host_file
2780                   poe  a.out  -procs $numprocs  -tasks_per_node $numprocs  $ROPTS  >  aout_output  2>&1
2781                fi
2782             fi
2783          elif [[ $host = nech  ||  $host = neck ]]
2784          then
2785             (( ii = nodes ))
2786             if [[ $ii = 1 ]]
2787             then
2788                export F_ERRCNT=0        # acceptable number of errors before program is stopped
2789                export MPIPROGINF=YES
2790                #  export F_TRACE=YES|FMT1|FMT2  # output of ftrace informations to job protocol
2791                echo "*** execution on single node with mpirun"
2792                mpirun  -np $numprocs  ./a.out  $ROPTS  >  aout_output  2>&1
2793             else
2794                (( i = 0 ))
2795                while (( i < ii ))
2796                do
2797                   echo "-h $i  -p $tasks_per_node  -e ./mpi_exec_shell"  >>  multinode_config
2798                   (( i = i + 1 ))
2799                done
2800
2801                echo "#!/bin/sh"                         >   mpi_exec_shell
2802                echo " "                                 >>  mpi_exec_shell
2803                echo "set -u"                            >>  mpi_exec_shell
2804                echo "F_ERRCNT=0"                        >>  mpi_exec_shell
2805                echo "MPIPROGINV=YES"                    >>  mpi_exec_shell
2806                echo "OMP_NUM_THREADS=$threads_per_task" >>  mpi_exec_shell
2807                echo "cpurest=$cpurest"                  >>  mpi_exec_shell
2808                echo "fname=$fname"                      >>  mpi_exec_shell
2809                echo "localhost=$localhost"              >>  mpi_exec_shell
2810                echo "return_addres=$return_addres"      >>  mpi_exec_shell
2811                echo "return_username=$return_username"  >>  mpi_exec_shell
2812                echo "tasks_per_node=$tasks_per_node"    >>  mpi_exec_shell
2813                echo "write_binary=$write_binary"        >>  mpi_exec_shell
2814                echo "use_seperate_pe_for_dvrp_output=$use_seperate_pe_for_dvrp_output"  >>  mpi_exec_shell
2815                echo "  "                                >>  mpi_exec_shell
2816                echo "export F_ERRCNT"                   >>  mpi_exec_shell
2817                echo "export MPIPROGINV"                 >>  mpi_exec_shell
2818                echo "export OMP_NUM_THREADS"            >>  mpi_exec_shell
2819                echo "export cpurest"                    >>  mpi_exec_shell
2820                echo "export fname"                      >>  mpi_exec_shell
2821                echo "export localhost"                  >>  mpi_exec_shell
2822                echo "export return_addres"              >>  mpi_exec_shell
2823                echo "export return_username"            >>  mpi_exec_shell
2824                echo "export tasks_per_node"             >>  mpi_exec_shell
2825                echo "export write_binary"               >>  mpi_exec_shell
2826                echo "export use_seperate_pe_for_dvrp_output"  >>  mpi_exec_shell
2827                echo " "                                 >>  mpi_exec_shell
2828                echo "exec  ./a.out > aout_output  2>&1" >>  mpi_exec_shell
2829
2830                chmod u+x  mpi_exec_shell
2831                export MPIPROGINF=YES
2832                mpirun  -f multinode_config  &
2833                wait
2834
2835             fi
2836          elif [[ $(echo $host | cut -c1-2) = lc  &&  $host != lctit ]]
2837          then
2838
2839                # COPY HOSTFILE FROM SOURCE DIRECTORY OR CREATE IT, IF IT
2840                # DOES NOT EXIST
2841             if [[ -f $hostfile ]]
2842             then
2843                cp  $hostfile  hostfile
2844             else
2845                (( ii = 1 ))
2846                while (( ii <= $numprocs / $threads_per_task ))
2847                do
2848                   echo  $localhost_realname  >>  hostfile
2849                   (( ii = ii + 1 ))
2850                done
2851             fi
2852             (( ii = $numprocs / $threads_per_task ))
2853             eval zeile=\"`head -n $ii  hostfile`\"
2854             printf "\n  *** running on: $zeile"
2855             export OMP_NUM_THREADS=$threads_per_task
2856             if [[ $threads_per_task != 1 ]]
2857             then
2858                printf "\n      threads per task: $threads_per_task"
2859             fi
2860             printf "\n\n"
2861             if [[ $scirocco = true ]]
2862             then
2863                mpiexec  -machinefile hostfile  -n $ii  a.out  $ROPTS   >  aout_output  2>&1
2864             else
2865                mpirun  -machinefile hostfile  -np $ii  a.out  $ROPTS   >  aout_output  2>&1
2866             fi
2867          elif [[ $host = decalpha ]]
2868          then
2869             dmpirun  -np $numprocs  a.out  $ROPTS  >  aout_output  2>&1
2870          elif [[ $host = lctit ]]
2871          then
2872             export runfile=runfile.$kennung
2873
2874             echo "cd $PWD"                                  >   $runfile
2875             echo "export OMP_NUM_THREADS=$OMP_NUM_THREADS"  >>  $runfile
2876             echo "export cpurest=$cpurest"                  >>  $runfile
2877             echo "export fname=$fname"                      >>  $runfile
2878             echo "export localhost=$localhost"              >>  $runfile
2879             echo "export return_addres=$return_addres"      >>  $runfile
2880             echo "export return_username=$return_username"  >>  $runfile
2881             echo "export tasks_per_node=$tasks_per_node"    >>  $runfile
2882             echo "export write_binary=$write_binary"        >>  $runfile
2883             echo "export use_seperate_pe_for_dvrp_output=$use_seperate_pe_for_dvrp_output"  >>  $runfile
2884             echo "./a.out"                                  >>  $runfile
2885             chmod  u+x  $runfile
2886
2887             if [[ "$QUEUE" = interactive ]]
2888             then
2889                mpirun  -np $numprocs  a.out  $ROPTS  >  aout_output  2>&1
2890             else
2891                n1ge  -fore  -g 1S060156  -mpi $numprocs  -mem 4  -N palm  -q $queue  a.out  $ROPTS  >  aout_output  2>&1
2892             fi
2893
2894             rm  $runfile
2895          else
2896             mpprun  -n $numprocs  a.out  $ROPTS  >  aout_output  2>&1
2897          fi
2898          [[ $? != 0 ]]  &&  execution_error=true
2899
2900
2901             # PERFORMANCE-AUSWERTUNG MIT APPRENTICE
2902          if [[ "$cond1" = apprentice  ||  "$cond2" = apprentice ]]
2903          then
2904             apprentice
2905          fi
2906       else
2907          a.out  $ROPTS  >  aout_output  2>&1
2908       fi
2909    fi
2910    if [[ $? != 0  ||  $execution_error = true ]]
2911    then
2912
2913          # ABBRUCH BEI LAUFZEITFEHLER
2914       [[ ! ( "$cond1" = debug  ||  "$cond2" = debug ) ]]  &&  cat  aout_output
2915       printf "\n  +++ runtime error occured"
2916       locat=execution
2917       exit
2918    else
2919       [[ ! ( "$cond1" = debug  ||  "$cond2" = debug ) ]]  &&  cat  aout_output
2920       printf "\n$striche\n  *** execution finished \n"
2921    fi
2922
2923
2924
2925       # EVENTUELLE OUTPUT-KOMMANDOS ABARBEITEN
2926    (( i = 0 ))
2927    while (( i < ioc ))
2928    do
2929       (( i = i + 1 ))
2930       if (( i == 1 ))
2931       then
2932          printf "\n\n  *** execution of OUTPUT-commands:\n$striche"
2933       fi
2934       printf "\n  >>> ${out_command[$i]}"
2935       eval  ${out_command[$i]}
2936       if (( i == ioc ))
2937       then
2938          printf "\n$striche\n"
2939       fi
2940    done
2941
2942
2943       # EVTL. INHALT DES AKTUELLEN VERZEICHNISSES AUSGEBEN
2944    if [[ $do_trace = true ]]
2945    then
2946       printf "\n\n"
2947       ls -al
2948    fi
2949
2950
2951
2952       # OUTPUT-DATEIEN AN IHRE ZIELORTE KOPIEREN
2953    (( i = 0 ))
2954    while (( i < iout ))
2955    do
2956       (( i = i + 1 ))
2957       if (( i == 1 ))
2958       then
2959          printf "\n\n  *** saving OUTPUT-files:\n$striche"
2960       fi
2961
2962          # PRUEFEN, OB EINZELDATEI ODER DATEI PRO PROZESSOR
2963       files_for_pes=false; filetyp=file
2964       if [[ "${actionout[$i]}" = pe  &&  -n $numprocs ]]
2965       then
2966          files_for_pes=true; filetyp=directory
2967          actionout[$i]=""
2968       elif [[ "${actionout[$i]}" = pe  &&  ! -n $numprocs ]]
2969       then
2970          actionout[$i]=""
2971       elif [[ "${actionout[$i]}" = arpe  &&  -n $numprocs ]]
2972       then
2973          files_for_pes=true; filetyp=directory
2974          actionout[$i]="ar"
2975       elif [[ "${actionout[$i]}" = arpe  &&  ! -n $numprocs ]]
2976       then
2977          actionout[$i]="ar"
2978       elif [[ "${actionout[$i]}" = flpe  &&  -n $numprocs ]]
2979       then
2980          files_for_pes=true; filetyp=directory
2981          actionout[$i]="fl"
2982       elif [[ "${actionout[$i]}" = flpe  &&  ! -n $numprocs ]]
2983       then
2984          actionout[$i]="fl"
2985       elif [[ "${actionout[$i]}" = trpe  &&  -n $numprocs ]]
2986       then
2987          files_for_pes=true; filetyp=directory
2988          actionout[$i]="tr"
2989       elif [[ "${actionout[$i]}" = trpe  &&  ! -n $numprocs ]]
2990       then
2991          actionout[$i]="tr"
2992       fi
2993
2994       if [[ ! -f ${localout[$i]}  &&  $files_for_pes = false ]]
2995       then
2996          printf "\n  +++ temporary OUTPUT-file  ${localout[$i]}  does not exist\n"
2997       elif [[ ! -f ${localout[$i]}/_0000  &&  $files_for_pes = true ]]
2998       then
2999          printf "\n  +++ temporary OUTPUT-file  ${localout[$i]}/....  does not exist\n"
3000       else
3001
3002
3003             # KOPIEREN PER FTP/SCP (IMMER IM BINAERMODUS, -M: FALLS ZIELKATALOG
3004             # NICHT VORHANDEN, WIRD VERSUCHT, IHN ANZULEGEN), ABER NUR BEI
3005             # REMOTE-RECHNUNGEN
3006          if [[ "${actionout[$i]}" = tr ]]
3007          then
3008             if [[ $localhost != $fromhost ]]
3009             then
3010                if [[ $files_for_pes = false ]]
3011                then
3012                   cps=""
3013                   cst=""
3014                else
3015                   cps=-c
3016                   cst="/"
3017                fi
3018                if [[ $localhost = ibmh  ||  $localhost = ibmb  ||  $localhost = nech ]]
3019                then
3020
3021                      # TRANSFER IN EIGENSTAENDIGEM JOB
3022                      # ZUERST KOPIE DER DATEI INS TEMPORAERE DATENVERZEICHNIS
3023                   [[ ! -d $tmp_data_catalog/TRANSFER ]]  &&  mkdir -p  $tmp_data_catalog/TRANSFER
3024                   file_to_transfer=${fname}_${localout[$i]}_to_transfer_$kennung
3025                   if [[ $files_for_pes = false ]]
3026                   then
3027                      ln -f  ${localout[$i]}  $tmp_data_catalog/TRANSFER/$file_to_transfer
3028                   else
3029                      mkdir  $tmp_data_catalog/TRANSFER/$file_to_transfer
3030                      ln  ${localout[$i]}/*  $tmp_data_catalog/TRANSFER/$file_to_transfer
3031                   fi
3032
3033                   echo "set -x"                                    >    transfer_${localout[$i]}
3034                   echo "cd  $tmp_data_catalog/TRANSFER"            >>   transfer_${localout[$i]}
3035
3036                   printf "\n  >>> OUTPUT: ${localout[$i]}$cst  by SCP in seperate job to"
3037                   printf "\n              ${pathout[$i]}/${localhost}_${fname}${endout[$i]}$cst"
3038                   printf "\n              or higher cycle\n"
3039                   echo "batch_scp $cps -b -m -u $return_username $return_addres  $file_to_transfer \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]}  ${extout[$i]}"  >>  transfer_${localout[$i]}
3040
3041                   echo "[[ \$? = 0 ]]  &&  rm  $file_to_transfer"  >>  transfer_${localout[$i]}
3042
3043                   if [[ $localhost = nech ]]
3044                   then
3045                      subjob  -d  -c /pf/b/$usern/job_queue  -v  -q pp  -X 0  -m 1000  -t 900  transfer_${localout[$i]}
3046                   else
3047                      if [[ "$LOGNAME" = b323013 ]]
3048                      then
3049                         subjob  -v  -q c1  -X 0  -m 1000  -t 900  transfer_${localout[$i]}
3050                      else
3051                         subjob  -d  -v  -q c1  -X 0  -m 1000  -t 900  transfer_${localout[$i]}
3052                      fi
3053                   fi
3054
3055                else
3056
3057                      # TRANSFER INNERHALB DIESES JOBS
3058                   transfer_failed=false
3059                   printf "\n  >>> OUTPUT: ${localout[$i]}$cst  by SCP to"
3060                   printf "\n              ${pathout[$i]}/${localhost}_${fname}${endout[$i]}$cst\n"
3061                   batch_scp $cps -b -m -u $return_username $return_addres  ${localout[$i]} "${pathout[$i]}" ${localhost}_${fname}${endout[$i]}  ${extout[$i]}
3062                   [[ $? != 0 ]]  &&  transfer_failed=true
3063
3064                      # BEI FEHLGESCHLAGENEM TRANSFER SICHERUNGSKOPIE AUF
3065                      # LOKALER MASCHINE ANLEGEN
3066                   if [[ $transfer_failed = true ]]
3067                   then
3068                      printf "  +++ transfer failed. Trying to save a copy on the local host under:\n"
3069                      printf "      ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung\n"
3070
3071                         # ERSTMAL PRUEFEN, OB VERZEICHNIS EXISTIERT. GEGEBENENFALLS
3072                         # ANLEGEN.
3073                      eval  local_catalog=${pathout[$i]}
3074                      if [[ ! -d $local_catalog ]]
3075                      then
3076                         printf "  *** local directory does not exist. Trying to create:\n"
3077                         printf "      $local_catalog \n"
3078                         mkdir -p  $local_catalog
3079                      fi
3080                      eval  cp  ${localout[$i]}  ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung
3081                      transfer_problems=true
3082                   fi
3083                fi
3084             else
3085
3086                   # WERTZUWEISUNG, SO DASS WEITER UNTEN NUR KOPIERT WIRD
3087                actionout[$i]=""
3088             fi
3089          fi
3090
3091
3092             # APPEND PER FTP/SCP (IMMER IM BINAERMODUS, -M: FALLS ZIELKATALOG
3093             # NICHT VORHANDEN, WIRD VERSUCHT, IHN ANZULEGEN), ABER NUR BEI
3094             # REMOTE-RECHNUNGEN
3095          if [[ "${actionout[$i]}" = tra ]]
3096          then
3097             if [[ $localhost != $fromhost ]]
3098             then
3099                if [[ $localhost = ibmh  ||  $localhost = ibmb  ||  $localhost = nech ]]
3100                then
3101
3102                      # TRANSFER IN EIGENSTAENDIGEM JOB
3103                      # ZUERST KOPIE DER DATEI INS TEMPORAERE DATENVERZEICHNIS
3104                   [[ ! -d $tmp_data_catalog/TRANSFER ]]  &&  mkdir -p  $tmp_data_catalog/TRANSFER
3105                   file_to_transfer=${fname}_${localout[$i]}_to_transfer_$kennung
3106                   ln -f  ${localout[$i]}  $tmp_data_catalog/TRANSFER/$file_to_transfer
3107
3108                   echo "set -x"                                    >    transfer_${localout[$i]}
3109                   echo "cd  $tmp_data_catalog/TRANSFER"            >>   transfer_${localout[$i]}
3110
3111                   printf "\n  >>> OUTPUT: ${localout[$i]}  append by SCP in seperate job to"
3112                   printf "\n              ${pathout[$i]}/${localhost}_${fname}${endout[$i]}"
3113                   printf "\n              or higher cycle\n"
3114                   echo "batch_scp -A -b -m -u $return_username $return_addres  $file_to_transfer \"${pathout[$i]}\" ${localhost}_${fname}${endout[$i]}  ${extout[$i]}"  >>  transfer_${localout[$i]}
3115
3116                   echo "[[ \$? = 0 ]]  &&  rm  $file_to_transfer"  >>  transfer_${localout[$i]}
3117
3118                   if [[ $localhost = nech ]]
3119                   then
3120                      subjob  -d  -c /pf/b/$usern/job_queue  -v  -q pp  -X 0  -m 1000  -t 900  transfer_${localout[$i]}
3121                   else
3122                      if [[ $LOGNAME = b323013 ]]
3123                      then
3124                         subjob  -v  -q c1  -X 0  -m 1000  -t 900  transfer_${localout[$i]}
3125                      else
3126                         subjob  -d  -v  -q c1  -X 0  -m 1000  -t 900  transfer_${localout[$i]}
3127                      fi
3128                   fi
3129
3130                else
3131
3132                      # TRANSFER INNERHALB DIESES JOBS
3133                   transfer_failed=false
3134                   printf "\n  >>> OUTPUT: ${localout[$i]}  append by SCP to"
3135                   printf "\n              ${pathout[$i]}/${localhost}_${fname}${endout[$i]}\n"
3136                   batch_scp -A -b -m -u $return_username  $return_addres ${localout[$i]} "${pathout[$i]}" ${localhost}_${fname}${endout[$i]}  ${extout[$i]}
3137                   [[ $? != 0 ]]  &&  transfer_failed=true
3138
3139                      # BEI FEHLGESCHLAGENEM TRANSFER SICHERUNGSKOPIE AUF
3140                      # LOKALER MASCHINE ANLEGEN
3141                   if [[ $transfer_failed = true ]]
3142                   then
3143                      printf "  +++ transfer failed. Trying to save a copy on the local host under:\n"
3144                      printf "      ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung\n"
3145
3146                         # ERSTMAL PRUEFEN, OB VERZEICHNIS EXISTIERT. GEGEBENENFALLS
3147                         # ANLEGEN
3148                      eval  local_catalog=${pathout[$i]}
3149                      if [[ ! -d $local_catalog ]]
3150                      then
3151                         printf "  *** local directory does not exist. Trying to create:\n"
3152                         printf "      $local_catalog \n"
3153                         mkdir -p  $local_catalog
3154                      fi
3155
3156                      eval  cp  ${localout[$i]}  ${pathout[$i]}/${localhost}_${fname}${endout[$i]}_$kennung
3157                      transfer_problems=true
3158                   fi
3159                fi
3160             else
3161
3162                   # WERTZUWEISUNG, SO DASS WEITER UNTEN NUR APPEND AUF
3163                   # LOKALER MASCHINE DURCHGEFUEHRT WIRD
3164                actionout[$i]=a
3165             fi
3166          fi
3167
3168
3169             # OUTPUT-DATEI FUER EINEN FORTSETZUNGSLAUF. DATEI WIRD PER
3170             # LINK AUF DEN TEMPORAEREN DATENKATALOG GELEGT. OPTION -f WIRD
3171             # VERWENDET, FALLS DORT NOCH EINE DATEI GLEICHEN NAMENS VORHANDEN
3172             # SEIN SOLLTE. ANSCHLIESSEND WIRD SEINE ARCHIVIERUNG ANGESTOSSEN
3173          if [[ "${actionout[$i]}" = fl ]]
3174          then
3175             [[ ! -d $tmp_data_catalog ]]  &&  mkdir -p  $tmp_data_catalog
3176             chmod  g+rx  $tmp_data_catalog
3177             if [[ $files_for_pes = false ]]
3178             then
3179                printf "\n  >>> OUTPUT: ${localout[$i]}  to"
3180                printf "\n              $tmp_data_catalog/${frelout[$i]} (temporary data catalog)\n"
3181                ln -f  ${localout[$i]}  $tmp_data_catalog/${frelout[$i]}
3182             else
3183                printf "\n  >>> OUTPUT: ${localout[$i]}/....  to"
3184                printf "\n              $tmp_data_catalog/${frelout[$i]} (temporary data catalog)\n"
3185                mkdir  $tmp_data_catalog/${frelout[$i]}
3186                ln -f  ${localout[$i]}/*  $tmp_data_catalog/${frelout[$i]}
3187             fi
3188
3189
3190                # ARCHIVIERUNGSJOB WIRD ERZEUGT UND ABGESCHICKT
3191             if [[ $store_on_archive_system = true ]]
3192             then
3193
3194                if [[ $archive_system = asterix ]]
3195                then
3196                   echo "cd  $tmp_data_catalog"                      >> archive_${frelout[$i]}
3197                   if [[ $files_for_pes = false ]]
3198                   then
3199                      echo "stageout  ${frelout[$i]}  > STAGE_OUTPUT${i}_$kennung" >> archive_${frelout[$i]}
3200                   else
3201                      echo "stageout -t  ${frelout[$i]}  > STAGE_OUTPUT${i}_$kennung" >> archive_${frelout[$i]}
3202                   fi
3203                   echo "cat  STAGE_OUTPUT${i}_$kennung"               >> archive_${frelout[$i]}
3204                   echo "if [[ \$(grep -c \"st.msg:150\"  STAGE_OUTPUT${i}_$kennung) != 0 ]]" >> archive_${frelout[$i]}
3205                   echo "then"                                       >> archive_${frelout[$i]}
3206                   echo "   do_stageout=false"                       >> archive_${frelout[$i]}
3207                   echo "else"                                       >> archive_${frelout[$i]}
3208                   echo "   echo \"  +++ $filetyp ${frelout[$i]}  could not be stored on archive-system\" " >> archive_${frelout[$i]}
3209                   echo "   cat  /dev/null  >  ~/job_queue/ARCHIVE_ERROR_$fname" >> archive_${frelout[$i]}
3210                   echo "   cat  STAGE_OUTPUT${i}_$kennung  >  ~/job_queue/archive_${frelout[$i]}_error" >> archive_${frelout[$i]}
3211                   echo "   echo \"  *** $filetyp ${frelout[$i]} will be copied to \$WORK as backup\" " >> archive_${frelout[$i]}
3212                   if [[ $files_for_pes = false ]]
3213                   then
3214                      echo "   cp   ${frelout[$i]}  \$WORK"                    >> archive_${frelout[$i]}
3215                   else
3216                      echo "   cp -r  ${frelout[$i]}  \$WORK/${frelout[$i]}"   >> archive_${frelout[$i]}
3217                   fi
3218                   echo "   echo \"  *** $filetyp ${frelout[$i]} saved\" " >> archive_${frelout[$i]}
3219                   echo "fi"                                         >> archive_${frelout[$i]}
3220                   echo "rm  STAGE_OUTPUT${i}_$kennung"              >> archive_${frelout[$i]}
3221                elif [[ $archive_system = DMF ]]
3222                then
3223                   echo "cd  $tmp_data_catalog"                      >> archive_${frelout[$i]}
3224                   if [[ $files_for_pes = false ]]
3225                   then
3226                      printf "\n  +++ archiving of single files impossible with $archive_system !\n"
3227                      locat=DMF
3228                      exit
3229                   else
3230                         # FUER RECHNER IN JUELICH. DORT KOENNTEN AUCH
3231                         # EINZELNE DATEIEN GESICHERT WERDEN (SPAETER KORR.)
3232                      echo "rm -rf  \$ARCHIVE/${frelout[$i]}"     >> archive_${frelout[$i]}
3233                      echo "cp -r  ${frelout[$i]}  \$ARCHIVE"     >> archive_${frelout[$i]}
3234                   fi
3235                elif [[ $archive_system = tivoli ]]
3236                then
3237                   echo "cd  $tmp_data_catalog"                       >> archive_${frelout[$i]}
3238                   if [[ $files_for_pes = false ]]
3239                   then
3240                         # EVENTUELL NOCH VORHANDENE DATEI IM ARCHIV LOSCHEN
3241                      echo "set -x"                                   >> archive_${frelout[$i]}
3242                      echo "rm  -rf  \$PERM/${frelout[$i]}"           >> archive_${frelout[$i]}
3243                      echo "cp  ${frelout[$i]} \$PERM/${frelout[$i]}" >> archive_${frelout[$i]}
3244                   else
3245
3246                      echo "set -x"                                   >> archive_${frelout[$i]}
3247                      echo "rm  -rf  \$PERM/${frelout[$i]}/*"         >> archive_${frelout[$i]}
3248                      echo "[[ ! -d \$PERM/${frelout[$i]} ]] && mkdir $PERM/${frelout[$i]}" >> archive_${frelout[$i]}
3249                      cd  $tmp_data_catalog
3250                      all_files=`ls -1 ${frelout[$i]}/*`
3251                      cd -  > /dev/null
3252                      (( inode = 0 ))
3253                      (( tp1   = tasks_per_node + 1 ))
3254                      while (( inode < nodes ))
3255                      do
3256#                         echo "*** all_files = \"$all_files\" "
3257                         files=`echo $all_files | cut -d" " -f1-$tasks_per_node`
3258                         all_files=`echo $all_files | cut -d" " -f$tp1-`
3259#                         echo "*** tasks_per_node = \"$tasks_per_node\" "
3260#                         echo "*** files = \"$files\" "
3261#                         echo "*** all_files = \"$all_files\" "
3262                         echo "tar  cvf \$PERM/${frelout[$i]}/${frelout[$i]}.node_$inode.tar $files"   >> archive_${frelout[$i]}
3263                         echo "dsmc incremental  \$PERM/${frelout[$i]}/${frelout[$i]}.node_$inode.tar" >> archive_${frelout[$i]}
3264                         echo "dsmmigrate \$PERM/${frelout[$i]}/${frelout[$i]}.node_$inode.tar"        >> archive_${frelout[$i]}
3265                         (( inode = inode + 1 ))
3266                      done
3267#                      echo "rm  -rf  \$PERM/${frelout[$i]}.tar"       >> archive_${frelout[$i]}
3268#                      echo "tar  cvf \$PERM/${frelout[$i]}.tar ${frelout[$i]}" >> archive_${frelout[$i]}
3269                   fi
3270                elif [[ $archive_system = ut ]]
3271                then
3272                   echo "cd  $tmp_data_catalog"                       >> archive_${frelout[$i]}
3273                   if [[ $files_for_pes = false ]]
3274                   then
3275                         # EVENTUELL NOCH VORHANDENE DATEI IM ARCHIV LOSCHEN
3276                      echo "set -x"                                 >> archive_${frelout[$i]}
3277                      echo "rm  -rf  \$UT/${frelout[$i]}"           >> archive_${frelout[$i]}
3278                      echo "cp  ${frelout[$i]} \$UT/${frelout[$i]}" >> archive_${frelout[$i]}
3279                   else
3280
3281                      echo "set -x"                                 >> archive_${frelout[$i]}
3282                      echo "rm  -rf  \$UT/${frelout[$i]}/*"         >> archive_${frelout[$i]}
3283                      echo "[[ ! -d \$UT/${frelout[$i]} ]] && mkdir $UT/${frelout[$i]}" >> archive_${frelout[$i]}
3284                      cd  $tmp_data_catalog
3285                      all_files=`ls -1 ${frelout[$i]}/*`
3286                      cd -  > /dev/null
3287                      (( inode = 0 ))
3288                      (( tp1   = tasks_per_node + 1 ))
3289                      while (( inode < nodes ))
3290                      do
3291                         files=`echo $all_files | cut -d" " -f1-$tasks_per_node`
3292                         all_files=`echo $all_files | cut -d" " -f$tp1-`
3293                         echo "tar  cvf \$UT/${frelout[$i]}/${frelout[$i]}.node_$inode.tar $files"   >> archive_${frelout[$i]}
3294                         (( inode = inode + 1 ))
3295                      done
3296                   fi
3297                elif [[ $archive_system = none ]]
3298                then
3299                   printf "              +++ archiving on $localhost not available!\n"
3300                fi
3301
3302                if [[ $archive_system != none ]]
3303                then
3304                   if [[ $localhost = ibmh  ||  $localhost = ibmb ]]
3305                   then
3306                      subjob  -d  -v  -q cdata  -X 0  -m 1000  -t 7200  archive_${frelout[$i]}
3307                   elif [[ $localhost = nech ]]
3308                   then
3309                      subjob  -d  -c /pf/b/$usern/job_queue  -v  -q pp  -X 0  -m 1000  -t 7200  archive_${frelout[$i]}
3310                   fi
3311                   printf "              Archiving of $tmp_data_catalog/${frelout[$i]} initiated (batch job submitted)\n"
3312                fi
3313             else
3314                printf "              +++ caution: option -A is switched on. No archiving on $archive_system!\n"
3315             fi
3316
3317
3318                # LEERDATEI IM BENUTZERVERZEICHNIS ANLEGEN, DAMIT BEKANNT IST,
3319                # WIE DIE HOECHSTE ZYKLUSNUMMER AUF DEM ARCHIV-SYSTEM LAUTET
3320             if [[ $files_for_pes = false ]]
3321             then
3322                cat  /dev/null  >  ${pathout[$i]}
3323             else
3324                mkdir -p  ${pathout[$i]}
3325             fi
3326
3327          fi
3328
3329
3330             # KOPIEREN AUF LOKALER MASCHINE ZUM ARCHIV-SYSTEM
3331             # AUSSERDEM MUSS LEERDATEI ANGELEGT WERDEN, DAMIT BEKANNT IST,
3332             # WIE DIE HOECHSTE ZYKLUSNUMMER AUF DEM ARCHIV-SYSTEM LAUTET
3333             # FALLS IRGENDEINE (VON MEHREREN) ARCHIVIERUNGEN SCHIEF GEHT,
3334             # WIRD FLAG GESETZT UND BLEIBT AUCH BEI WEITEREN ORDNUNGS-
3335             # GEMAESSEN ARCHIVIERUNGEN GESETZT
3336          if [[ "${actionout[$i]}" = ar ]]
3337          then
3338             if [[ $files_for_pes = false ]]
3339             then
3340                printf "\n  >>> OUTPUT: ${localout[$i]}  to"
3341                printf "\n              ${pathout[$i]}"
3342                printf "\n              File will be copied to archive-system ($archive_system) !\n"
3343             else
3344                printf "\n  >>> OUTPUT: ${localout[$i]}/_....  to"
3345                printf "\n              ${pathout[$i]}"
3346                printf "\n              Directory will be copied to archive-system ($archive_system) !\n"
3347             fi
3348             mv  ${localout[$i]}  ${frelout[$i]}
3349
3350             file_saved=false
3351
3352             if [[ $archive_system = asterix ]]
3353             then
3354                do_stageout=true
3355                (( stageout_anz = 0 ))
3356                while [[ $do_stageout = true ]]
3357                do
3358                   if [[ $files_for_pes = false ]]
3359                   then
3360                      stageout  ${frelout[$i]}  > STAGE_OUTPUT
3361                   else
3362                      stageout  -t  ${frelout[$i]}  > STAGE_OUTPUT
3363                   fi
3364                   cat  STAGE_OUTPUT
3365                   if [[ $(grep -c "st.msg:150"  STAGE_OUTPUT) != 0 ]]
3366                   then
3367                      file_saved=true
3368                      do_stageout=false
3369                   else
3370                      if [[ $files_for_pes = false ]]
3371                      then
3372                         printf "\n  +++ file ${frelout[$i]}  could not be saved on archive-system"
3373                      else
3374                         printf "\n  +++ directory ${frelout[$i]} could not be saved on archive-system"
3375                      fi
3376                      (( stageout_anz = stageout_anz + 1 ))
3377                      if (( stageout_anz == 10 ))
3378                      then
3379                         printf "\n  +++ stoped after 10 unsuccessful tries!"
3380                         archive_save=false
3381                         do_stageout=false
3382                      else
3383                         printf "\n  *** new try to store on archive after 15 min:"
3384                         sleep 900
3385                      fi
3386                   fi
3387                done
3388             elif [[ $archive_system = DMF ]]
3389             then
3390                if [[ $files_for_pes = false ]]
3391                then
3392                   printf "\n  +++ archiving of single files impossible on $archive_system!\n"
3393                   locat=DMF
3394                   exit
3395                else
3396                   rm -rf  $ARCHIVE/${frelout[$i]}
3397                   cp -r  ${frelout[$i]}  $ARCHIVE
3398                fi
3399                file_saved=true
3400             elif [[ $archive_system = tivoli ]]
3401             then
3402                   # ARCHIVIERUNG NUR PER BATCH-JOB MOEGLICH
3403                   # DATEI MUSS ZWISCHENZEITLICH INS TEMPORAERE DATENVERZEICHNIS
3404                   # GELEGT WERDEN
3405                [[ ! -d $tmp_data_catalog ]]  &&  mkdir -p  $tmp_data_catalog
3406                chmod  g+rx  $tmp_data_catalog
3407                if [[ $files_for_pes = false ]]
3408                then
3409                   ln -f  ${frelout[$i]}  $tmp_data_catalog/${frelout[$i]}
3410                else
3411                   mkdir  $tmp_data_catalog/${frelout[$i]}
3412                   ln -f  ${frelout[$i]}/*  $tmp_data_catalog/${frelout[$i]}
3413                fi
3414
3415                   # BATCH JOB GENERIEREN UND ABSCHICKEN; DATEI MUSS WIEDER
3416                   # AUS TEMPORAEREM DATENVERZEICHNIS ENTFERNT WERDEN
3417                echo "cd  $tmp_data_catalog"                       >  archive_${frelout[$i]}
3418                if [[ $files_for_pes = false ]]
3419                then
3420                      # EVENTUELL NOCH VORHANDENE DATEI IM ARCHIV LOSCHEN
3421                   echo "rm  -rf  \$PERM/${frelout[$i]}"           >> archive_${frelout[$i]}
3422                   echo "cp  ${frelout[$i]} \$PERM/${frelout[$i]}" >> archive_${frelout[$i]}
3423                   echo "rm  -rf  ${frelout[$i]}"                  >> archive_${frelout[$i]}
3424                else
3425                   echo "rm  -rf  \$PERM/${frelout[$i]}.tar"       >> archive_${frelout[$i]}
3426                   echo "tar  cvf \$PERM/${frelout[$i]}.tar ${frelout[$i]}" >> archive_${frelout[$i]}
3427                   echo "rm  -rf  ${frelout[$i]}"                  >> archive_${frelout[$i]}
3428                fi
3429
3430                subjob  -v  -d  -q cdata  -X 0  -m 1000  -t 7200  archive_${frelout[$i]}
3431                printf "              Archiving of $tmp_data_catalog/${frelout[$i]} initiated (batch job submitted)\n"
3432                file_saved=true
3433
3434             elif [[ $archive_system = ut ]]
3435             then
3436                   # ARCHIVIERUNG NUR PER BATCH-JOB MOEGLICH
3437                   # DATEI MUSS ZWISCHENZEITLICH INS TEMPORAERE DATENVERZEICHNIS
3438                   # GELEGT WERDEN
3439                [[ ! -d $tmp_data_catalog ]]  &&  mkdir -p  $tmp_data_catalog
3440                chmod  g+rx  $tmp_data_catalog
3441                if [[ $files_for_pes = false ]]
3442                then
3443                   ln -f  ${frelout[$i]}  $tmp_data_catalog/${frelout[$i]}
3444                else
3445                   mkdir  $tmp_data_catalog/${frelout[$i]}
3446                   ln -f  ${frelout[$i]}/*  $tmp_data_catalog/${frelout[$i]}
3447                fi
3448
3449                   # BATCH JOB GENERIEREN UND ABSCHICKEN; DATEI MUSS WIEDER
3450                   # AUS TEMPORAEREM DATENVERZEICHNIS ENTFERNT WERDEN
3451                echo "cd  $tmp_data_catalog"                       >  archive_${frelout[$i]}
3452                if [[ $files_for_pes = false ]]
3453                then
3454                      # EVENTUELL NOCH VORHANDENE DATEI IM ARCHIV LOSCHEN
3455                   echo "rm  -rf  \$UT/${frelout[$i]}"           >> archive_${frelout[$i]}
3456                   echo "cp  ${frelout[$i]} \$UT/${frelout[$i]}" >> archive_${frelout[$i]}
3457                   echo "rm  -rf  ${frelout[$i]}"                >> archive_${frelout[$i]}
3458                else
3459                   echo "rm  -rf  \$UT/${frelout[$i]}.tar"       >> archive_${frelout[$i]}
3460                   echo "tar  cvf \$UT/${frelout[$i]}.tar ${frelout[$i]}" >> archive_${frelout[$i]}
3461                   echo "rm  -rf  ${frelout[$i]}"                >> archive_${frelout[$i]}
3462                fi
3463
3464                subjob  -v  -c /pf/b/$usern/job_queue  -d  -q pp  -X 0  -m 1000  -t 7200  archive_${frelout[$i]}
3465                printf "              Archiving of $tmp_data_catalog/${frelout[$i]} initiated (batch job submitted)\n"
3466                file_saved=true
3467
3468             else
3469                printf "\n  +++ archive_system=\"$archive_system\"  archiving impossible!"
3470                archive_save=false
3471             fi
3472             if [[ $file_saved = true ]]
3473             then
3474                if [[ $files_for_pes = false ]]
3475                then
3476                   cat  /dev/null  >  ${pathout[$i]}
3477                else
3478                   mkdir -p  ${pathout[$i]}
3479                fi
3480             fi
3481          fi
3482
3483             # APPEND AUF LOKALER MASCHINE
3484          if [[ "${actionout[$i]}" = "a" ]]
3485          then
3486             printf "\n  >>> OUTPUT: ${localout[$i]}  append to  ${pathout[$i]}\n"
3487             cat  ${localout[$i]}  >>  ${pathout[$i]}
3488          fi
3489
3490             # KOPIEREN AUF LOKALER MASCHINE
3491             # ES MUSS KOPIERT WERDEN, DA MOVE NICHT UEBER FILESYSTEM HINAUS MOEGLICH
3492          if [[ "${actionout[$i]}" = ""  &&  $files_for_pes = false ]]
3493          then
3494
3495                # KOPIEREN AUF EINPROZESSORMASCHINE
3496             if [[ "${extout[$i]}" != " "  &&  "${extout[$i]}" != "" ]]
3497             then
3498                printf "\n  >>> OUTPUT: ${localout[$i]}  to  ${pathout[$i]}.${extout[$i]}\n"
3499                cp  ${localout[$i]}  ${pathout[$i]}.${extout[$i]}
3500             else
3501                printf "\n  >>> OUTPUT: ${localout[$i]}  to  ${pathout[$i]}\n"
3502                cp  ${localout[$i]}  ${pathout[$i]}
3503             fi
3504
3505          elif [[ "${actionout[$i]}" = ""  &&  $files_for_pes = true ]]
3506          then
3507
3508                # DIE DEN PROZESSOREN EINES PARALLELRECHNERS ZUGEHOERIGEN
3509                # DATEIEN WERDEN ERST IN EINEM KATALOG GESAMMELT UND DIESER
3510                # WIRD DANN KOPIERT
3511                # PER MOVE UMBENANNT WERDEN
3512             printf "\n  >>> OUTPUT: ${localout[$i]}/_....  to  ${pathout[$i]}\n"
3513             cp -r  ${localout[$i]}  ${pathout[$i]}
3514
3515          fi
3516       fi
3517    done
3518    if (( i != 0 ))
3519    then
3520       if [[ $transfer_problems = true ]]
3521       then
3522          printf "\n$striche\n  *** OUTPUT-files saved"
3523          printf "\n  +++ WARNING: some data transfers failed! \n"
3524       else
3525          printf "\n$striche\n  *** all OUTPUT-files saved \n"
3526       fi
3527    fi
3528
3529
3530       # EVENTUELL FOLGEJOB STARTEN
3531       # DATEI CONTINUE_RUN MUSS VOM BENUTZERPROGRAMM AUS ERZEUGT WERDEN
3532    if [[ -f CONTINUE_RUN ]]
3533    then
3534
3535       if [[ $archive_save = true ]]
3536       then
3537
3538             # ZUERST IN MRUN-AUFRUF OPTIONEN FUER FORTSETZUNGSLAUF, FUER
3539             # STILLES ABARBEITEN (OHNE INTERAKTIVE RUECKFAGEN) UND FUER
3540             # BATCH-BETRIEB (NUR WICHTIG, FALLS BATCH AUF LOKALER MASCHINE
3541             # DURCHGEFUEHRT WERDEN SOLL) EINFUEGEN, FALLS NICHT BEREITS VOR-
3542             # HANDEN
3543          [[ $(echo $mc | grep -c "\-C") = 0 ]]  &&  mc="$mc -C"
3544          [[ $(echo $mc | grep -c "\-v") = 0 ]]  &&  mc="$mc -v"
3545          [[ $(echo $mc | grep -c "\-b") = 0 ]]  &&  mc="$mc -b"
3546          if [[ $(echo $mc | grep -c "#") != 0 ]]
3547          then
3548             mc=`echo $mc | sed 's/#/f/g'`
3549          fi
3550
3551
3552             # JOB STARTEN
3553          printf "\n\n  *** initiating restart-run on \"$return_addres\" using command:\n"
3554          echo "      $mc"
3555          printf "\n$striche\n"
3556          if [[ $localhost != $fromhost ]]
3557          then
3558
3559             if [[ $localhost = nech  ||  $localhost = ibmb  ||  $localhost = ibmh  ||  $localhost = ibms  ||  $localhost = lctit ]]
3560             then
3561                echo "*** ssh will be used to initiate restart-runs!"
3562                echo "    return_addres=\"$return_addres\" "
3563                echo "    return_username=\"$return_username\" "
3564                if [[ $return_addres = 172.20.25.41 ]]
3565                then
3566                      # WORKAROUND AUF SCIROCCO AM TIT
3567                   print  "PATH=\$PATH:$LOCAL_MRUN_PATH;export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc "  |  ssh $return_addres -l $return_username 
3568                else
3569                   ssh $return_addres -l $return_username "PATH=\$PATH:$LOCAL_MRUN_PATH;export PALM_BIN=$LOCAL_MRUN_PATH;cd $LOCAL_PWD; $mc "
3570                fi
3571             else
3572                printf "\n  +++ no restart mechanism available for host \"$localhost\" "
3573                locat=restart; exit
3574             fi
3575
3576                # WARTEN, DAMIT SICH RESTART JOB IN QUEUE EINREIHEN KANN, BEVOR
3577                # DER AKTUELLE JOB ENDET
3578             sleep 30
3579
3580          else
3581
3582                # BEI RECHNUNGEN AUF LOKALER MASCHINE KANN MRUN DIREKT AUFGE-
3583                # RUFEN WERDEN
3584             cd $LOCAL_PWD
3585             eval  $mc                # ' MUESSEN AUSGEWERTET WERDEN
3586             cd -  > /dev/null
3587          fi
3588          printf "\n$striche\n  *** restart-run initiated \n"
3589
3590
3591             # EVENTUELL INPUT-DATEIEN, DIE VON TEMPORAEREM DATENVERZEICHNIS
3592             # GEHOLT WORDEN SIND, LOESCHEN
3593          (( i = 0 ))
3594          while (( i < iin ))
3595          do
3596             (( i = i + 1 ))
3597             if [[ "${got_tmp[$i]}" = true   &&  $keep_data_from_previous_run = false ]]
3598             then
3599                rm -r  $tmp_data_catalog/${frelin[$i]}
3600             fi
3601          done
3602
3603       else
3604
3605          printf "\n  +++ no restart-run possible, since errors occured"
3606          printf "\n      during the archive process"
3607       fi
3608
3609    fi
3610
3611
3612   
3613       # EVTL. EMAIL-BENACHRICHTIGUNG UEBER ABGESCHLOSSENEN LAUF
3614    if [[ "$email_notification" != "" ]]
3615    then
3616
3617       if [[ $localhost != $fromhost ]]
3618       then
3619          if [[ -f CONTINUE_RUN ]]
3620          then
3621             echo "PALM restart run necessary"        >   email_text
3622             echo "description header of actual run:" >>  email_text
3623             cat  CONTINUE_RUN                        >>  email_text
3624             echo "mrun-command to restart:"          >>  email_text
3625             echo "$mc"                               >>  email_text
3626          else
3627             echo "PALM run with base filename \"$fname\" on host \"$localhost\" finished"  >  email_text
3628          fi
3629          mail  $email_notification  <  email_text
3630          printf "\n  *** email notification sent to \"$email_notification\" "
3631       fi
3632    fi
3633
3634
3635
3636       # ALLE ARBEITEN BEENDET. TEMPORAERER KATALOG KANN GELOESCHT WERDEN
3637    cd  $HOME
3638    [[ $delete_temporary_catalog = true ]]  &&  rm -rf $TEMPDIR
3639
3640 else
3641
3642
3643       # FALLS AUF REMOTE-MASCHINE GERECHNET WERDEN SOLL, WERDEN JETZT ENTSPRE-
3644       # CHENDE AKTIONEN DURCHGEFUEHRT
3645
3646       # MRUN-BEFEHL FUER REMOTE-MASCHINE ZUSAMMENSTELLEN
3647    mrun_com="$mrun_script_name -a $afname -c $config_file -d $fname -h $host -H $fromhost -m $memory -t $cpumax -q $queue -R $return_addres -U $return_username -u $remote_username"
3648    [[ "$cpp_opts" != "" ]]       &&  mrun_com=${mrun_com}" -D \"$cpp_opts\""
3649    [[ "$global_revision" != "" ]]  &&  mrun_com=${mrun_com}" -G \"$global_revision\""
3650    [[ $do_compile = true ]]      &&  mrun_com=${mrun_com}" -s \"$source_list\""
3651    [[ "$input_list" != "" ]]     &&  mrun_com=${mrun_com}" -i \"$input_list\""
3652    [[ $ignore_archive_error = true ]]  &&  mrun_com=${mrun_com}" -I"
3653    [[ $keep_data_from_previous_run = true ]]  &&  mrun_com=${mrun_com}" -k"
3654    [[ "$additional_conditions" != "" ]]  &&  mrun_com=${mrun_com}" -K \"$additional_conditions\""
3655#    [[ "$makefile" != "$source_path/Makefile" ]]  &&  mrun_com=${mrun_com}" -M \"$makefile\""
3656    [[ "$output_list" != "" ]]    &&  mrun_com=${mrun_com}" -o \"$output_list\""
3657    [[ "$read_from_config" = false ]]  &&  mrun_com=${mrun_com}" -S"
3658    [[ $do_trace = true ]]        &&  mrun_com=${mrun_com}" -x"
3659    [[ "$numprocs" != "" ]]       &&  mrun_com=${mrun_com}" -X $numprocs"
3660    if [[ $use_openmp = true ]]
3661    then
3662       mrun_com=${mrun_com}" -O"
3663       [[ "$tasks_per_node" != "" ]] &&  mrun_com=${mrun_com}" -T $threads_per_task"
3664    else
3665       [[ "$tasks_per_node" != "" ]] &&  mrun_com=${mrun_com}" -T $tasks_per_node"
3666    fi
3667    [[ $store_on_archive_system = false ]]  &&  mrun_com=${mrun_com}" -A"
3668    [[ $package_list != "" ]]     &&  mrun_com=${mrun_com}" -p \"$package_list\""
3669    [[ $return_password != "" ]]  &&  mrun_com=${mrun_com}" -P $return_password"
3670    [[ $delete_temporary_catalog = false ]]  &&  mrun_com=${mrun_com}" -B"
3671    [[ $node_usage != default ]]  &&  mrun_com=${mrun_com}" -n $node_usage"
3672    if [[ $do_remote = true ]]
3673    then
3674       printf "\n>>>> MRUN-command on execution host:\n>>>> $mrun_com \n"
3675    fi
3676
3677
3678       # ZUSAMMENSTELLUNG DES JOBSCRIPTS AUF DATEI jobfile
3679    jobfile=jobfile.$RANDOM
3680
3681
3682       # TEMPORAERES VERZEICHNIS GENERIEREN UND NACH DORT WECHSELN
3683    echo  "mkdir  $TEMPDIR"      >>  $jobfile
3684    echo  "cd  $TEMPDIR"         >>  $jobfile
3685
3686
3687       # EVENTUELL FEHLERVERFOLGUNG AKTIVIEREN
3688    if [[ $do_trace = true ]]
3689    then
3690       echo  "set -x"                                    >>  $jobfile
3691    else
3692       echo  "set +vx"                                   >>  $jobfile
3693    fi
3694
3695
3696       # ABSPEICHERN DER QUELLTEXTE (NUR FALLS UEBERSETZT WERDEN SOLL)
3697       # SOWIE GEGEBENENFALLS DES MAKEFILES
3698    if [[ $do_compile = true ]]
3699    then
3700
3701       source_catalog=SOURCES_FOR_RUN_$fname
3702
3703           # UNTERVERZEICHNIS FUER QUELLTEXTE UND MAKEFILE ANLEGEN
3704           # MRUN WIRD DIESES VRZEICHNIS UEBER ENVIRONMENT VARIABLE
3705           # MITGETEILT (UEBERSTEUERT ANGABE IN KONFIGURATIONSDATEI)
3706       echo  "mkdir  SOURCES_FOR_RUN_$fname"                >>  $jobfile
3707       echo  "export SOURCES_COMPLETE=true"                 >>  $jobfile
3708       echo  "cd     SOURCES_FOR_RUN_$fname"                >>  $jobfile
3709
3710       for  filename  in  $source_list
3711       do
3712             # ABDECKZEICHEN VERHINDERN, DASS ERSETZUNGEN ERFOLGEN
3713          echo  "cat > $filename << \"%END%\""              >>  $jobfile
3714          cat   $source_catalog/$filename                   >>  $jobfile
3715          echo  " "                                         >>  $jobfile
3716          echo  "%END%"                                     >>  $jobfile
3717          echo  " "                                         >>  $jobfile
3718       done
3719
3720          # ABDECKZEICHEN VERHINDERN, DASS ERSETZUNGEN ERFOLGEN
3721       echo  "cat > Makefile << \"%END%\""               >>  $jobfile
3722       cat   $source_catalog/Makefile                    >>  $jobfile
3723       echo  " "                                         >>  $jobfile
3724       echo  "%END%"                                     >>  $jobfile
3725       echo  " "                                         >>  $jobfile
3726
3727       echo  "cd -  > /dev/null"                         >>  $jobfile
3728
3729    fi
3730
3731
3732       # ABSPEICHERN DER KONFIGURATIONSDATEI
3733       # ABDECKZEICHEN VERHINDERN, DASS ERSETZUNGEN ERFOLGEN
3734    echo  "cat > $config_file << \"%END%\""      >>  $jobfile
3735    cat   $config_file                           >>  $jobfile
3736    echo  "%END%"                                >>  $jobfile
3737    echo  " "                                    >>  $jobfile
3738
3739
3740       # ABSPEICHERN DER AKTUELLEN MRUN-VERSION
3741       # ABDECKZEICHEN VERHINDERN, DASS ERSETZUNGEN ERFOLGEN
3742    echo  "cat > $mrun_script_name <<\"%END%\""  >>  $jobfile
3743    cat   ${PALM_BIN}/$mrun_script_name          >>  $jobfile
3744    echo  "%END%"                                >>  $jobfile
3745    if [[ $host = lctit ]]
3746    then
3747       echo "sed 's/bin\/ksh/home2\/usr5\/mkanda\/pub\/ksh/' < $mrun_script_name > mrun_new" >>  $jobfile
3748       echo "mv  mrun_new  $mrun_script_name"    >>  $jobfile
3749    fi
3750    echo  "chmod u+x $mrun_script_name"          >>  $jobfile
3751    echo  "execute_mrun=true"                    >>  $jobfile
3752    echo  " "                                    >>  $jobfile
3753
3754       # EVTL. BENOETIGTE INPUT-DATEIEN PER FTP HOLEN ODER DEM JOB DIREKT
3755       # MITGEBEN UND AUF DEM REMOTE-RECHNER IM BENUTZERVERZEICHNIS ABLEGEN
3756       # FALLS DIESES NICHT EXISTIERT, WIRD VERSUCHT, DAS JEWEILS LETZTE
3757       # UNTERVERZEICHNIS DES PFADNAMENS ANZULEGEN
3758    if [[ $do_remote = true ]]
3759    then
3760       (( i = 0 ))
3761       while (( i < iin ))
3762       do
3763          (( i = i + 1 ))
3764          echo  "[[ ! -d ${pathin[$i]} ]]  &&  mkdir -p  ${pathin[$i]}"  >>  $jobfile
3765          if [[ "${transin[$i]}" = job ]]
3766          then
3767             echo  "cat > ${remotepathin[$i]} <<\"%END%\""    >>  $jobfile
3768             eval cat   ${pathin[$i]}/${frelin[$i]}           >>  $jobfile
3769             echo  " "                                        >>  $jobfile
3770             echo  "%END%"                                    >>  $jobfile
3771          else
3772             echo  "batch_scp -b -o -g -s -u $return_username $return_addres ${remotepathin[$i]} \"${pathin[$i]}\" ${frelin[$i]}" >>  $jobfile
3773          fi
3774
3775             # UEBERPRUEFEN, OB DATEI ANGELEGT WERDEN KONNTE
3776          echo  "if [[ \$? = 1 ]]"                    >>  $jobfile
3777          echo  "then"                                >>  $jobfile
3778          echo  "   echo \" \" "                      >>  $jobfile
3779          echo  "   echo \"+++ file ${remotepathin[$i]} could not be created\" "   >>  $jobfile
3780          echo  "   echo \"    please check, if directory exists on $host!\" "  >>  $jobfile
3781          echo  "   echo \"+++ MRUN will not be continued\" "  >>  $jobfile
3782          echo  "   execute_mrun=false"               >>  $jobfile
3783          echo  "fi"                                  >>  $jobfile
3784       done
3785    fi
3786
3787       # ARBEITSKATALOG AUF DER LOKALEN MASCHINE FUER EVENTUELLE
3788       # FORTSETZUNGSLAUEFE PER ENV-VARIABLE UEBERGEBEN
3789    echo  "LOCAL_PWD=$working_directory"                >>  $jobfile
3790    echo  "export LOCAL_PWD"                            >>  $jobfile
3791
3792       # EBENSO LOKALEN MRUN-KATALOG UEBERGEBEN
3793    echo  "LOCAL_MRUN_PATH=$PALM_BIN"                   >>  $jobfile
3794    echo  "export LOCAL_MRUN_PATH"                      >>  $jobfile
3795
3796       # WORKAROUND FUER RIAM-NEC-JOBS WEGEN PROFILE-SCHWIERIGKEITEN
3797    if [[ $localhost_realname = "gate"  ||  $localhost = lctit ]]
3798    then
3799       echo  "export PALM_BIN=$PALM_BIN"                >>  $jobfile
3800    fi
3801
3802       # MRUN AUF ZIELRECHNER AUFRUFEN
3803    echo  "set -x"                                      >>  $jobfile
3804    echo  "[[ \$execute_mrun = true ]]  &&  ./$mrun_com"  >>  $jobfile
3805
3806    echo  'ls -al; echo `pwd`'                          >>  $jobfile
3807    echo  "cd \$HOME"                                   >>  $jobfile
3808    echo  "rm -rf  $TEMPDIR"                            >>  $jobfile
3809
3810
3811
3812
3813       # JOB PER SUBJOB STARTEN
3814    if [[ $silent = false ]]
3815    then
3816       printf "\n     "
3817    else
3818       printf "\n\n"
3819    fi
3820
3821    subjob  $job_on_file  -h $host  -u $remote_username  -q $queue  -m $memory  -N $node_usage -t $cpumax  $XOPT  $TOPT  $OOPT  -n $fname  -v   $jobfile
3822    rm -rf  $jobfile
3823
3824
3825 fi  # ENDE REMOTE-TEIL
3826
3827
3828
3829     # ENDE DER PROZEDUR
Note: See TracBrowser for help on using the repository browser.