source: palm/trunk/SCRIPTS/mrun @ 1084

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

last commit documented

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