source: palm/trunk/SCRIPTS/mrun @ 1605

Last change on this file since 1605 was 1605, checked in by suehring, 9 years ago

last commit documented

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