Index: palm/trunk/SCRIPTS/mrun
===================================================================
--- palm/trunk/SCRIPTS/mrun	(revision 1197)
+++ palm/trunk/SCRIPTS/mrun	(revision 1199)
@@ -22,5 +22,8 @@
 # Current revisions:
 # ------------------
-# adjustments for CSC Helsinki (lccrayf)
+# adjustments for CSC Helsinki (lccrayf),
+# executables for batch jobs can be created in advance, in order to avoid calling
+# the compiler within the batch job (only works if batch jobs are submitted on
+# local host)
 #
 # Former revisions:
@@ -122,4 +125,5 @@
  cpumax=0
  cpurest=0
+ create_executable_for_batch=false
  delete_temporary_catalog=true
  do_batch=false
@@ -1747,5 +1751,5 @@
     # FALLS PROGRAMMTEILE UEBERSETZT WERDEN SOLLEN, FOLGEN JETZT EINIGE
     # UEBERPRUEFUNGEN UND DAS SETZEN DER PRAEPROZESSOR-DIREKTIVEN
- if [[ $do_compile = true ]]
+ if [[ $do_compile = true  ||  $create_executable_for_batch = true ]]
  then
 
@@ -1898,5 +1902,5 @@
     # EVENTUELL BEI LOKALEN RECHNUNGEN $-ZEICHEN IN ENVIRONMENT-VARIABLEN
     # ERSETZEN
- if [[ $do_remote = false  &&  $do_compile = true ]]
+ if [[ $do_remote = false  &&  $do_compile = true  ||  $create_executable_for_batch = true ]]
  then
     eval  fopts=\"$fopts\"
@@ -2649,4 +2653,63 @@
 
 
+    # DETERMINE PATH FOR MAKE DEPOSITORY
+ if [[ $do_batch = false  ||  $create_executable_for_batch = true ]]
+ then
+
+    line=""
+    grep "%depository_path" $config_file  >  tmp_mrun
+    while read line
+    do
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+          if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]]
+          then
+             global_depository_path=`echo $line | cut -d" " -s -f2`
+          fi
+       fi
+    done < tmp_mrun
+
+    line=""
+    grep  " $localhost" $config_file | grep "%depository_path"  >  tmp_mrun
+    while read line
+    do
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+          if [[ "$(echo $line | cut -d" " -s -f4)" = "$cond1"  &&  "$(echo $line | cut -d" " -s -f5)" = "$cond2" ]]
+          then
+             local_depository_path=`echo $line | cut -d" " -s -f2`
+          fi
+       fi
+    done < tmp_mrun
+
+    if [[ "$local_depository_path" = "" ]]
+    then
+       if [[ "$global_depository_path" != "" ]]
+       then
+          local_depository_path=$global_depository_path
+       else
+          printf "\n\n  +++ no depository path found in configuration file"
+          printf "\n      for local host \"$localhost\" "
+          printf "\n      please set \"\%depository_path\" in configuration file\n"
+          locat=config_file; exit
+       fi
+    fi
+    eval local_depository_path=$local_depository_path
+    [[ "$cond1" != "" ]]  &&  local_depository_path=${local_depository_path}_$cond1
+    [[ "$cond2" != "" ]]  &&  local_depository_path=${local_depository_path}_$cond2
+
+
+    basename=`echo $mainprog | cut -f1 -d"."`
+    eval make_depository=${local_depository_path}/${basename}_current_version.tar
+    if [[ ! -f $make_depository ]]
+    then
+       printf "\n"
+       printf "\n  *** WARNING: make depository \"$make_depository\" not found"
+       printf "\n               \"make\" will fail, if the Makefile or other source files are missing\n"
+    fi
+
+ fi
+
+
     # FALLS AUF DIESER MASCHINE GERECHNET WERDEN SOLL, WERDEN JETZT ENTSPRE-
     # CHENDE AKTIONEN DURCHGEFUEHRT
@@ -2659,11 +2722,4 @@
     chmod  go+rx  $TEMPDIR
     tmpcreate=true
-
-       # set striping on lustre file system
-#    if [[ $localhost = lcsgih ]]
-#    then
-#       lfs setstripe -s 8192k -c 16  $TEMPDIR
-#       lfs getstripe $TEMPDIR
-#    fi
 
 
@@ -2692,62 +2748,8 @@
        fi
 
-
-          # PFADNAMEN FUER DAS MAKE-DEPOSITORY ERMITTELN
-       line=""
-       grep "%depository_path" $config_file  >  tmp_mrun
-       while read line
-       do
-          if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
-          then
-             if [[ "$(echo $line | cut -d" " -s -f3)" = "" ]]
-             then
-                global_depository_path=`echo $line | cut -d" " -s -f2`
-             fi
-          fi
-       done < tmp_mrun
-
-       line=""
-       grep  " $localhost" $config_file | grep "%depository_path"  >  tmp_mrun
-       while read line
-       do
-          if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
-          then
-             if [[ "$(echo $line | cut -d" " -s -f4)" = "$cond1"  &&  "$(echo $line | cut -d" " -s -f5)" = "$cond2" ]]
-             then
-                local_depository_path=`echo $line | cut -d" " -s -f2`
-             fi
-          fi
-       done < tmp_mrun
-
-       if [[ "$local_depository_path" = "" ]]
-       then
-          if [[ "$global_depository_path" != "" ]]
-          then
-             local_depository_path=$global_depository_path
-          else
-             printf "\n\n  +++ no depository path found in configuration file"
-             printf "\n      for local host \"$localhost\" "
-             printf "\n      please set \"\%depository_path\" in configuration file\n"
-             locat=config_file; exit
-          fi
-       fi
-       eval local_depository_path=$local_depository_path
-       [[ "$cond1" != "" ]]  &&  local_depository_path=${local_depository_path}_$cond1
-       [[ "$cond2" != "" ]]  &&  local_depository_path=${local_depository_path}_$cond2
-
-
-       basename=`echo $mainprog | cut -f1 -d"."`
-       eval make_depository=${local_depository_path}/${basename}_current_version.tar
-       if [[ ! -f $make_depository ]]
-       then
-          printf "\n"
-          printf "\n  *** WARNING: make depository \"$make_depository\" not found"
-          printf "\n               \"make\" will fail, if the Makefile or other source files are missing\n"
-       else
-          cp  $make_depository  $TEMPDIR_COMPILE
-          cd  $TEMPDIR_COMPILE
-          tar -xf  $make_depository  >  /dev/null  2>&1
-          cd -  > /dev/null
-       fi
+       cp  $make_depository  $TEMPDIR_COMPILE
+       cd  $TEMPDIR_COMPILE
+       tar -xf  $make_depository  >  /dev/null  2>&1
+       cd -  > /dev/null
 
        cp  SOURCES_FOR_RUN_$fname/*  $TEMPDIR_COMPILE
@@ -2782,90 +2784,87 @@
 
 
-       # EVTL. UEBERSETZUNGSAKTIONEN STARTEN
+       # IF REQUIRED, START WITH COMPILING ACTIONS
     if [[ $do_compile = true ]]
     then
 
 
-          # COMPILING WITH MAKE (ON NEC COMPILER IS CALLED ON HOST CROSS)
-       printf "\n\n\n  *** compilation starts \n$striche\n"
-       printf "  *** compilation with make using following options:\n"
-       printf "      make depository:          $make_depository"
-       if [[ "$mopts" != "" ]]
-       then
-          printf "      make options:             $mopts\n"
-       fi
-       printf "      compilername:             $compiler_name\n"
-       printf "      compiler options:         $fopts\n"
-       printf "      preprocessor directives:  $cpp_options \n"
-       printf "      linker options:           $lopts \n"
-       if [[ "$modules" != "" ]]
-       then
-          printf "      modules to be load:       $modules \n"
-       fi
-       printf "      source code files:        $source_list \n"
-
-       if [[ $localhost = nech ]]
-       then
-#         init_cmds was ". /SX/opt/etc/initsx.sh;" 
-          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\" "
-          cp  $TEMPDIR_COMPILE/a.out  .
-          [[ $? != 0 ]]  &&  compile_error=true
-          rm -rf  $TEMPDIR_COMPILE
-       elif [[ $localhost = ibmh ]]
-       then
-          printf "      compiler is called via ssh on \"plogin1\" \n"
-          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\" "
-          [[ ! -f a.out ]]  &&  compile_error=true
-          continue   # ANDERENFALLS IST STATUS=1, FALLS A.OUT VORHANDEN
-#       elif [[ $localhost = lccrayf ]]
-#       then
-#          printf "      compiler is called via ssh on \"sisu-login1\" \n"
-#          ssh  $SSH_PORTOPT  sisu-login1  -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\" "
-#          [[ ! -f a.out ]]  &&  compile_error=true
-#          continue   # ANDERENFALLS IST STATUS=1, FALLS A.OUT VORHANDEN
-       elif [[ $localhost = lcsgib ]]
-       then
-          printf "      compiler is called via ssh on \"bicegate0\" \n"
-          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\" "
-          [[ ! -f a.out ]]  &&  compile_error=true
-          continue   # ANDERENFALLS IST STATUS=1, FALLS A.OUT VORHANDEN
-       elif [[ $localhost = lcsgih ]]
-       then
-          printf "      compiler is called via ssh on \"hicegate0\" \n"
-          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 "
-          [[ ! -f a.out ]]  &&  compile_error=true
-          continue   # ANDERENFALLS IST STATUS=1, FALLS A.OUT VORHANDEN
-       elif [[ $localhost = lcflow ]]
-       then 
-          printf "      compiler is called via ssh on \"flow\" \n"
-          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\" "
-          [[ ! -f a.out ]]  &&  compile_error=true
-          continue   # ANDERENFALLS IST STATUS=1, FALLS A.OUT VORHANDEN
-       elif [[ $localhost = lccrayf ]]
-       then
-          module list
-          make $mopts -f Makefile PROG=a.out  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$fopts"  LDFLAGS="$lopts"
+       if [[ -f a.out ]]
+       then
+
+             # EXECUTABLE WAS CREATED DURING INTERACTIVE CALL OF MRUN
+          printf "\n\n\n  *** executable a.out found"
+          printf "\n      no compilation required \n"
+
        else
-          [[ "$init_cmds" != "" ]]  &&  eval $init_cmds
-          [[ "$module_calls" != "" ]]  &&  eval $module_calls
-          make $mopts -f Makefile PROG=a.out  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$fopts"  LDFLAGS="$lopts"
-
-       fi
-
-       if [[ $? != 0  ||  "$compile_error" = true  ||  "$module_compile_error" = true ]]
-       then
-          printf "\n  +++ error occured while compiling or linking"
-          locat=compile
-
-  # WORKAROUND: REMOVE IF CONSTRUCT LATER, BUT KEEP THE EXIT!
-#          if [[ $localhost != lcsgib  &&  $localhost != lcsgih ]]
-#          then
+
+             # COMPILING WITH MAKE (ON NEC COMPILER IS CALLED ON HOST CROSS)
+          printf "\n\n\n  *** compilation starts \n$striche\n"
+          printf "  *** compilation with make using following options:\n"
+          printf "      make depository:          $make_depository"
+          if [[ "$mopts" != "" ]]
+          then
+             printf "      make options:             $mopts\n"
+          fi
+          printf "      compilername:             $compiler_name\n"
+          printf "      compiler options:         $fopts\n"
+          printf "      preprocessor directives:  $cpp_options \n"
+          printf "      linker options:           $lopts \n"
+          if [[ "$modules" != "" ]]
+          then
+             printf "      modules to be load:       $modules \n"
+          fi
+          printf "      source code files:        $source_list \n"
+
+          if [[ $localhost = nech ]]
+          then
+             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\" "
+             cp  $TEMPDIR_COMPILE/a.out  .
+             [[ $? != 0 ]]  &&  compile_error=true
+             rm -rf  $TEMPDIR_COMPILE
+          elif [[ $localhost = ibmh ]]
+          then
+             printf "      compiler is called via ssh on \"plogin1\" \n"
+             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\" "
+             [[ ! -f a.out ]]  &&  compile_error=true
+             continue   # ANDERENFALLS IST STATUS=1, FALLS A.OUT VORHANDEN
+          elif [[ $localhost = lcsgib ]]
+          then
+             printf "      compiler is called via ssh on \"bicegate0\" \n"
+             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\" "
+             [[ ! -f a.out ]]  &&  compile_error=true
+             continue   # ANDERENFALLS IST STATUS=1, FALLS A.OUT VORHANDEN
+          elif [[ $localhost = lcsgih ]]
+          then
+             printf "      compiler is called via ssh on \"hicegate0\" \n"
+             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 "
+             [[ ! -f a.out ]]  &&  compile_error=true
+             continue   # ANDERENFALLS IST STATUS=1, FALLS A.OUT VORHANDEN
+          elif [[ $localhost = lcflow ]]
+          then 
+             printf "      compiler is called via ssh on \"flow\" \n"
+             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\" "
+             [[ ! -f a.out ]]  &&  compile_error=true
+             continue   # ANDERENFALLS IST STATUS=1, FALLS A.OUT VORHANDEN
+          elif [[ $localhost = lccrayf ]]
+          then
+             make $mopts -f Makefile PROG=a.out  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$fopts"  LDFLAGS="$lopts"
+          else
+             [[ "$init_cmds" != "" ]]  &&  eval $init_cmds
+             [[ "$module_calls" != "" ]]  &&  eval $module_calls
+             make $mopts -f Makefile PROG=a.out  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$fopts"  LDFLAGS="$lopts"
+          fi
+
+          if [[ $? != 0  ||  "$compile_error" = true  ||  "$module_compile_error" = true ]]
+          then
+             printf "\n  +++ error occured while compiling or linking"
+             locat=compile
+
              exit
-#          else
-#             locat=normal
-#          fi
-       else
-          printf "$striche\n  *** compilation finished \n"
-       fi
+          else
+             printf "$striche\n  *** compilation finished \n"
+          fi
+
+       fi
+
     fi
 
@@ -3682,5 +3681,4 @@
                 elif [[ $host = lccrayf ]]
                 then
-                    echo "aprun  -n $ii  -N $tasks_per_node  -m ${memory}M  a.out  $ROPTS  < runfile_atmos"
                     aprun  -n $ii  -N $tasks_per_node  -m ${memory}M  a.out  $ROPTS  < runfile_atmos
                 elif [[ $host = lcxe6  ||  $host = lcxt5m ]]
@@ -4754,4 +4752,43 @@
 
 
+       # create executable for batch job
+    if [[ $create_executable_for_batch = true  &&  $restart_run != true ]]
+    then
+
+       printf "\n  *** creating the executable for batch job\n"
+
+          # method only works for batch jobs on local hosts
+       if [[ $host != $localhost ]]
+       then
+          printf "\n  +++ creation of executables is only allowed for batch jobs on local hosts."
+          printf "\n      Please set create_executable_for_batch = false in the config-file.\n"
+          locat=create_executable; exit
+       fi
+
+       mkdir  $working_directory/SOURCES_FOR_RUN_${fname}/TMPDIR_FOR_CREATING_EXECUTABLE
+       cd  $working_directory/SOURCES_FOR_RUN_${fname}/TMPDIR_FOR_CREATING_EXECUTABLE
+
+       cp  $make_depository  .
+       tar -xf  $make_depository  >  /dev/null  2>&1
+       cp  ../*  .   >  /dev/null  2>&1
+
+       make $mopts -f Makefile PROG=a.out  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$fopts"  LDFLAGS="$lopts"
+
+       if [[ $? != 0  ||  "$compile_error" = true  ||  "$module_compile_error" = true ]]
+       then
+          printf "\n  +++ error occured while compiling or linking"
+          locat=compile
+          exit
+       fi
+
+       mv  a.out  ..
+       cd -  >  /dev/null  2>&1
+       rm -rf  $working_directory/SOURCES_FOR_RUN_${fname}/TMPDIR_FOR_CREATING_EXECUTABLE
+
+       printf "  *** executable created in \"$working_directory/SOURCES_FOR_RUN_${fname}\"\n "
+
+    fi
+
+
        # ZUSAMMENSTELLUNG DES JOBSCRIPTS AUF DATEI jobfile
     jobfile=jobfile.$RANDOM
@@ -4785,5 +4822,5 @@
        # BEREITSTELLUNG VON QUELLTEXTEN, MRUN-SCRIPTS UND KONFIGURATIONS-
        # DATEI FUER DEN JOB
-    if [[ $( echo $host | cut -c1-5 ) = lcsgi  ||  $host = ibmkisti ]]
+    if [[ $( echo $host | cut -c1-5 ) = lcsgi  ||  $host = ibmkisti  ||  $host = lccrayf ]]
     then
 
@@ -4801,5 +4838,9 @@
        if [[ $host = $localhost ]]
        then
-          echo  "cp  -r  $working_directory/SOURCES_FOR_RUN_$fname ."  >>  $jobfile
+
+             # DUE TO UNKNOWN REASONS, COPY WITH cp COMMAND CREATES CORRUPT
+             # FILES ON CRAY XC30 SYSTEMS (CSC HELSINKI), rsync IS USED INSTEAD
+          echo  "rsync -ae -t  $working_directory/SOURCES_FOR_RUN_$fname  ."  >>  $jobfile
+
        else
           if [[ $host != ibmkisti ]]
@@ -4818,4 +4859,5 @@
        echo  "mv  SOURCES_FOR_RUN_$fname/$config_file  . "       >>  $jobfile
        echo  "mv  SOURCES_FOR_RUN_$fname/$mrun_script_name  . "  >>  $jobfile
+       echo  "chmod u+rwx  $mrun_script_name"                    >>  $jobfile
        echo  "execute_mrun=true"                                 >>  $jobfile
        echo  " "                                                 >>  $jobfile
