source: palm/trunk/SCRIPTS/mrun @ 1278

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

last commit documented

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