source: palm/trunk/SCRIPTS/mrun @ 41

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

small modification to mrun

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