source: palm/trunk/SCRIPTS/mrun @ 260

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

automatic generation of dvrs/html file for combined dvr streams; automatic call of streaming server

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