source: palm/trunk/SCRIPTS/mrun @ 1106

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

New:
---

Porting of FFT-solver for serial runs to GPU using CUDA FFT,
preprocessor lines in transpose routines rearranged, so that routines can also
be used in serial (non-parallel) mode,
transpositions also carried out in serial mode, routines fftx, fftxp replaced
by calls of fft_x, fft_x replaced by fft_x_1d in the 1D-decomposition routines
(Makefile, Makefile_check, fft_xy, poisfft, poisfft_hybrid, transpose, new: cuda_fft_interfaces)

--stdin argument for mpiexec on lckyuh, -y and -Y settings output to header (mrun)

Changed:


Module array_kind renamed precision_kind
(check_open, data_output_3d, fft_xy, modules, user_data_output_3d)

some format changes for coupled atmosphere-ocean runs (header)
small changes in code formatting (microphysics, prognostic_equations)

Errors:


bugfix: default value (0) assigned to coupling_start_time (modules)
bugfix: initial time for preruns of coupled runs is output as -coupling_start_time (data_output_profiles)

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