source: palm/trunk/SCRIPTS/mrun @ 1612

Last change on this file since 1612 was 1610, checked in by maronga, 9 years ago

last commit documented

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