source: palm/trunk/SCRIPTS/mrun @ 181

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

bugfixes + adjustments for SGI ICE system

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