source: palm/tags/release-3.2/SCRIPTS/mrun

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

bugfix of last change

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