source: palm/trunk/SCRIPTS/mrun @ 1199

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

further script adjustments for CSC Helsinki (lccrayf), executables for batch jobs can be created in advance, in order to avoid calling the compiler within the batch job

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