source: palm/trunk/SCRIPTS/mrun @ 343

Last change on this file since 343 was 343, checked in by maronga, 15 years ago

adjustments for lcxt4 and ibmy, allow user 2d xy cross section output at z=nzb+1

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