source: palm/trunk/SCRIPTS/mrun @ 246

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

further changes for dvrp clipping

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