source: palm/trunk/SCRIPTS/mrun @ 1274

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

Adjustments for lccrayh

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