source: palm/trunk/SCRIPTS/mrun @ 1123

Last change on this file since 1123 was 1123, checked in by heinze, 10 years ago

last commit documented

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