source: palm/trunk/SCRIPTS/mrun @ 1281

Last change on this file since 1281 was 1281, checked in by raasch, 10 years ago

rsync-copy restricted to Cray machines, since sommand is unavailable on some other systems

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