source: palm/trunk/SCRIPTS/mrun @ 1622

Last change on this file since 1622 was 1622, checked in by heinze, 9 years ago

bugfix for Mistral (lcbullhh)

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