source: palm/trunk/SCRIPTS/mrun @ 377

Last change on this file since 377 was 377, checked in by raasch, 15 years ago

adjustments for openmp usage on sgi-ice

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