source: palm/trunk/SCRIPTS/mrun_new @ 22

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

compilation of utilities with mbuild, mrun_path replaced by PALM_BIN, no statistik-log

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