source: palm/trunk/SCRIPTS/mrun @ 1599

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

last commit documented

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