source: palm/trunk/SCRIPTS/mrun @ 562

Last change on this file since 562 was 562, checked in by raasch, 14 years ago

bugfixes for wrong netcdf/3.6.3 module, last revision 561, and setting of MPI_TYPE_DEPTH for netCDF4/HDF5 with mpt -library

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