source: palm/trunk/SCRIPTS/mrun @ 1083

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

bugfixes in parameter file check

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