source: palm/trunk/SCRIPTS/mrun @ 211

Last change on this file since 211 was 211, checked in by raasch, 15 years ago

user interface was split into one single file per subroutine

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