source: palm/trunk/SCRIPTS/mrun @ 1804

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

removed parameter file check. update of mrungui for compilation with qt5

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