source: palm/trunk/SCRIPTS/mrun @ 1069

Last change on this file since 1069 was 1069, checked in by maronga, 11 years ago

allow usage of topography in combination with cloud physics, allow usage of topography in coupled ocean model, minor changes in mbuild and mrun

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