source: palm/trunk/SCRIPTS/mrun @ 1241

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

Nudging and large scale forcing from external file implemented

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