source: palm/trunk/SCRIPTS/mrun @ 1171

Last change on this file since 1171 was 1125, checked in by raasch, 11 years ago

last commit documented

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