source: palm/trunk/SCRIPTS/mrun @ 221

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

new environment variable mpilib in configuration file, used by mrun, mbuild, and subjob; small bugfix concerning t<0 in init_cloud_physics

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