source: palm/trunk/SCRIPTS/mrun @ 1598

Last change on this file since 1598 was 1598, checked in by raasch, 9 years ago

bugfix for creating hostfile in openmp-mode if run on one node

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