source: palm/trunk/SCRIPTS/mrun @ 494

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

New:
---
Output in NetCDF4-format. New d3par-parameter netcdf_data_format.

(check_open, check_parameters, close_file, data_output_2d, data_output_3d, header, modules, netcdf, parin)

Modules to be loaded for compilation (mbuild) or job execution (mrun)
can be given in the configuration file using variable modules. Example:

%modules ifort/11.0.069:netcdf lcsgih parallel

This method replaces the (undocumented) mpilib-variable.

WARNING: All fixed settings of modules in the scripts mbuild, mrun, and subjob
have been removed! Please set the modules variable appropriately in your
configuration file. (mbuild, mrun, subjob)

Changed:


Parameters netcdf_64bit and netcdf_64bit_3d have been removed. Use
netcdf_data_format = 2 for choosing the classic 64bit-offset format (this is
the default). The offset-format can not be set independently for the
3d-output-data any more.

Parameters netcdf_format_mask, netcdf_format_mask_av, and variables
nc_format_mask, format_parallel_io removed. They are replaced by the new
parameter netcdf_data_format. (check_open, close_file,
data_output_mask, header, init_masks, modules, parin)

Errors:


bugfix in trunk/UTIL/Makefile: forgot to compile for interpret_config

Bugfix: timeseries data have to be collected by PE0 (user_statistics)

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