source: palm/trunk/SCRIPTS/mrun @ 1673

Last change on this file since 1673 was 1649, checked in by knoop, 9 years ago

Latex lecture update for PALM seminar in Hong Kong

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