source: palm/trunk/SCRIPTS/mrun @ 1091

Last change on this file since 1091 was 1091, checked in by raasch, 12 years ago

last commit documented

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