source: palm/trunk/SCRIPTS/mrun @ 188

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