source: palm/trunk/SCRIPTS/mrun @ 1110

Last change on this file since 1110 was 1109, checked in by raasch, 11 years ago

last commit documented

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