source: palm/trunk/SCRIPTS/mrun @ 1103

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

small bugfixes; mrun and subjob scripts are made bash compatible; further adjustments for lckyuh

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