source: palm/trunk/SCRIPTS/mrun @ 75

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

preliminary update for changes concerning non-cyclic boundary conditions

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