source: palm/trunk/SCRIPTS/mrun @ 366

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

speed optomizations +bugfix in init_ocean

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