source: palm/trunk/SCRIPTS/mrun @ 1755

Last change on this file since 1755 was 1755, checked in by maronga, 8 years ago

minor bugfix for last commit

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