source: palm/trunk/SCRIPTS/mrun @ 2287

Last change on this file since 2287 was 2286, checked in by raasch, 7 years ago

test output for cycle number removed

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