source: palm/trunk/SCRIPTS/mrun @ 414

Last change on this file since 414 was 412, checked in by raasch, 14 years ago

data asignments for dvrp arrays switched back to old settings due to runtime problems; type problem in mpi_waitall (poisfft_hybrid) fixed for mpi2 libraries

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