source: palm/trunk/SCRIPTS/mrun @ 437

Last change on this file since 437 was 437, checked in by raasch, 14 years ago

script adjustements for lcxt5m

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