source: palm/trunk/SCRIPTS/mrun @ 1096

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

last commit documented

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