source: palm/trunk/SCRIPTS/mrun @ 1201

Last change on this file since 1201 was 1201, checked in by witha, 11 years ago

script adjustments for Forwind cluster (lcflow)

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