source: palm/trunk/SCRIPTS/mrun @ 1282

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

last commit documented

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