source: palm/trunk/SCRIPTS/mrun @ 74

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

temporary change in mrun removed

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