source: palm/trunk/SCRIPTS/mrun @ 1107

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

last commit documented

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