source: palm/trunk/SCRIPTS/mrun @ 376

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

bugfix concerning output of averaged 2d/3d quantities

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