source: palm/trunk/SCRIPTS/mrun @ 1124

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

bugfix: variable memory is exported via typeset option -x, because otherwise an unknown side effect may lead to data loss when getopts is reading the script-option arguments

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