source: palm/trunk/SCRIPTS/mrun @ 208

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

ocean-atmosphere coupling realized with MPI-1, adjustments in mrun, mbuild, subjob for lcxt4

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