source: palm/trunk/SCRIPTS/mrun @ 1185

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