source: palm/trunk/SCRIPTS/mrun @ 1279

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

tasks_per_node must not be an integral divisor of numprocs any more

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