source: palm/trunk/SCRIPTS/mrun @ 1090

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

script adjustments for Kyushu-University computing center (lckyut)

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