source: palm/trunk/SCRIPTS/mrun @ 1242

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

Last commmit documented

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