source: palm/trunk/SCRIPTS/mrun @ 1101

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

mrun script now running under bash; small adjustment for lckyuh

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