source: palm/trunk/SCRIPTS/mrun @ 1549

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

Enable interactive debug session with the allinea debugger

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