source: palm/trunk/SCRIPTS/mrun @ 2278

Last change on this file since 2278 was 2268, checked in by raasch, 7 years ago

bugfix for calculating cycle numbers for output files in r2261

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