source: palm/trunk/SCRIPTS/mrun @ 362

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