source: palm/trunk/SCRIPTS/mrun @ 170

Last change on this file since 170 was 169, checked in by raasch, 16 years ago

property settings for scripts changed

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