source: palm/trunk/SCRIPTS/mrun @ 204

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

mrun for SGI-ICE restarts

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