source: palm/trunk/SCRIPTS/mrun @ 449

Last change on this file since 449 was 440, checked in by raasch, 14 years ago

lckyoto admitted for mrun and subjob

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