source: palm/trunk/SCRIPTS/mrun @ 71

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

bugfixes in mrun

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