source: palm/trunk/SCRIPTS/mrun @ 359

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