source: palm/trunk/SCRIPTS/mrun @ 191

Last change on this file since 191 was 191, checked in by raasch, 16 years ago

further adjustments and bugfixes for SGI system

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