source: palm/trunk/SCRIPTS/mrun @ 69

Last change on this file since 69 was 69, checked in by raasch, 17 years ago

scripts are running under pdksh

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