source: palm/trunk/SCRIPTS/mrun @ 509

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

mrun modification for lckyoto

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