source: palm/trunk/SCRIPTS/mrun @ 1609

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

minor changes in mrun and bugfix in poismg_fast

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