source: palm/trunk/SCRIPTS/mrun @ 741

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

bugfix for local append of output files with suffix (.nc)

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