source: palm/trunk/SCRIPTS/mrun @ 798

Last change on this file since 798 was 759, checked in by raasch, 13 years ago

New:
---

The number of parallel I/O operations can be limited with new mrun-option -w.
(advec_particles, data_output_2d, data_output_3d, header, init_grid, init_pegrid, init_3d_model, modules, palm, parin, write_3d_binary)

Changed:


mrun option -T is obligatory

Errors:


Bugfix: No zero assignments to volume_flow_initial and volume_flow_area in
case of normal restart runs. (init_3d_model)

initialization of u_0, v_0. This is just to avoid access of uninitialized
memory in exchange_horiz_2d, which causes respective error messages
when the Intel thread checker (inspector) is used. (production_e)

Bugfix for ts limitation (prandtl_fluxes)

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