source: palm/trunk/SCRIPTS/mrun @ 635

Last change on this file since 635 was 635, checked in by raasch, 13 years ago

mrun/mbuild/subjob adjustments for new Tsubama system at Tokyo Institute of Techology (lctit)

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