source: palm/trunk/SCRIPTS/mrun @ 67

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

small adjustments for fimm

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