source: palm/trunk/SCRIPTS/mrun @ 369

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

additional environment variable for mpt on ice2

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