source: palm/trunk/SCRIPTS/mrun @ 1271

Last change on this file since 1271 was 1271, checked in by fricke, 10 years ago

last commit documented

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