source: palm/trunk/SCRIPTS/mrun @ 1272

Last change on this file since 1272 was 1272, checked in by witha, 10 years ago

small adjustment for lcflow

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