source: palm/trunk/SCRIPTS/mrun @ 1787

Last change on this file since 1787 was 1779, checked in by raasch, 8 years ago

pmc array management changed from linked list to sequential loop; further small changes and cosmetics for the pmc

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