source: palm/trunk/SCRIPTS/mrun @ 187

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