source: palm/trunk/SCRIPTS/mrun @ 1094

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

scp/ssh port can be set explicitly

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