source: palm/trunk/SCRIPTS/mrun @ 1772

Last change on this file since 1772 was 1759, checked in by maronga, 8 years ago

bugfix for last commit

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