source: palm/trunk/SCRIPTS/mrun @ 210

Last change on this file since 210 was 210, checked in by raasch, 15 years ago

updates in dvr routines for new dvr version

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