source: palm/tags/release-3.7a/SCRIPTS/mrun @ 3984

Last change on this file since 3984 was 475, checked in by raasch, 14 years ago

make options can be set in configuration file; bugfix for generating serial jobs; bugfix for masked output

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