Index: palm/trunk/SCRIPTS/palmrun
===================================================================
--- palm/trunk/SCRIPTS/palmrun	(revision 2551)
+++ palm/trunk/SCRIPTS/palmrun	(revision 2566)
@@ -27,4 +27,13 @@
 # -----------------
 # $Id$
+# execute command for combine_plot_fields added
+# "TEMPDIR" renamed "tempdir"
+# temporary working directory for local batch jobs is created immediately within
+# the user's palmrun call, due to a requirement of the "grid engine" batch
+# system, where the working directory is given with batch directive -wd and must
+# already exist when the job is submitted,
+# informative messages in non-trace mode reduced and partly reformatted
+# 
+# 2551 2017-10-18 07:25:11Z raasch
 # TEMPDIR added as replacement string to be used in batch directives
 # 
@@ -137,5 +146,4 @@
  tasks_per_node=0
  threads_per_task=1
- tmpcreate=false
  transfer_problems=false
  user_source_path=""
@@ -161,20 +169,14 @@
              eval  ${err_command[$i]}
           done
-          [[ $delete_temporary_catalog = true ]]  &&  (cd; rm -rf $TEMPDIR)
+          [[ $delete_temporary_catalog = true ]]  &&  (cd; rm -rf $tempdir)
           printf "\n\n+++ palmrun killed \n\n"
        elif [[ $locat != control_c ]]
        then
-          printf "\n\n --> palmrun finished\n\n"
-          if [[ $running_on_remote = true ]]
-          then
-             printf "     Bye, bye $remote_username !!\n\n"
-          else
-             printf "     Bye, bye $local_username !!\n\n"
-          fi
+          printf "\n --> palmrun finished\n\n"
        fi' exit
 
 
     # ACTIONS IN CASE OF TERMINAL-BREAK (CONTROL-C):
- trap 'cd; rm -rf $TEMPDIR
+ trap 'cd; rm -rf $tempdir
        printf "\n+++ palmrun killed by \"^C\" \n\n"
        locat=control_c
@@ -1189,5 +1191,5 @@
     job_id=${fname}.$run_id
 
-    TEMPDIR=$fast_io_catalog/$job_id
+    tempdir=$fast_io_catalog/$job_id
  fi
 
@@ -1523,7 +1525,7 @@
     if [[ $create_batch_job = true  ||  $create_remote_batch_job = true ]]
     then
-       printf " ***  batch-job will be created and submitted"
+       printf "\n ***  batch-job will be created and submitted"
     else
-       printf " ***  PALMRUN will now continue to execute on this machine"
+       printf "\n ***  PALMRUN will now continue to execute on this machine"
     fi
  fi
@@ -1537,7 +1539,7 @@
     if [[ $create_batch_job = true  ||  $create_remote_batch_job  = true ]]
     then
-       printf "\n\n  *** creating executable and other sources for the remote host"
+       printf "\n\n  *** creating executable and other sources for the remote host\n"
     else
-       printf "\n\n  *** creating executable and other sources for the local host"
+       printf "\n\n  *** creating executable and other sources for the local host\n"
     fi
 
@@ -1593,5 +1595,10 @@
        fi
 
-       palmbuild  -v  -h $host_configuration
+       if [[ $do_trace = true ]]
+       then
+          palmbuild  -h $host_configuration
+       else
+          palmbuild  -v  -h $host_configuration
+       fi
 
        if [[ $? != 0 ]]
@@ -1608,4 +1615,5 @@
     fi
 
+       # NOW CREATE THE SOURCES_FOR_RUN FOLDER
     palmbuild  -v  $use_existing_sources_folder  -h $host_configuration  -d $fname
 
@@ -1621,5 +1629,5 @@
     else
 
-       printf "\n$dashes\n  *** executable and other sources created\n"
+       printf "  *** executable and other sources created\n"
        rm -rf  $sources_for_run_catalog
 
@@ -1639,15 +1647,14 @@
           # CREATE THE DIRECTORY AND COPY FILES FROM SOURCES_FOR_RUN_... TO THAT
           # FOLDER
-       mkdir -p  $TEMPDIR
-       chmod  go+rx  $TEMPDIR
-       tmpcreate=true
-       cd  $TEMPDIR
-       cp  ${fast_io_catalog}/${sources_for_run_catalog}/{*,.[!.]*}  $TEMPDIR
-       printf "\n  *** changed to temporary directory: $TEMPDIR"
+       mkdir -p  $tempdir
+       chmod  go+rx  $tempdir
+       cd  $tempdir
+       cp  ${fast_io_catalog}/${sources_for_run_catalog}/{*,.[!.]*}  $tempdir
+       printf "\n  *** changed to temporary directory: $tempdir"
 
     else
 
           # IN BATCH MODE PALMRUN IS CALLED FROM TEMPDIR
-       printf "\n  *** running in temporary directory: $TEMPDIR"
+       printf "\n  *** running in temporary directory: $tempdir"
 
     fi
@@ -1724,7 +1731,7 @@
                 for file in $(ls *)
                 do
-                   ln $file $TEMPDIR/${localin[$i]}
+                   ln $file $tempdir/${localin[$i]}
                 done >|/dev/null 2>&1
-                cd $TEMPDIR
+                cd $tempdir
              fi
 
@@ -1788,5 +1795,5 @@
 		                    ln -f $file  ${localin[$i]}
 		                 done
-		                 cd $TEMPDIR
+		                 cd $tempdir
 		              fi
 
@@ -1862,5 +1869,5 @@
        # STARTING THE EXECUTABLE
     printf "\n\n  *** execution starts in directory\n      \"`pwd`\"\n$dashes\n"
-    PATH=$PATH:$TEMPDIR
+    PATH=$PATH:$tempdir
 
 
@@ -1873,6 +1880,10 @@
 
        # EXECUTION COMMAND FOR COMBINE_PLOT_FIELDS
-    eval line2=\"$line2\"
-    execute_command_for_combine="$line2"
+    if [[ "$execute_command_for_combine" = "" ]]
+    then
+       eval line2=\"$line2\"
+       execute_command_for_combine="$line2"
+    fi
+    
 
 
@@ -1993,12 +2004,4 @@
     done
 
-
-       # IN TRACE-MODE PRINT CONTENTS OF THE CURRENT (TEMPORARY) WORKING DIRECTORY
-    if [[ $do_trace = true ]]
-    then
-       printf "\n\n"
-       ls -al
-    fi
-    
 
        # COPY LOCAL OUTPUT-FILES TO THEIR PERMANENT DESTINATIONS
@@ -2123,5 +2126,5 @@
                 if [[ "$remote_loginnode" != "" ]]
                 then
-                   echo "cd $TEMPDIR; ${fast_io_catalog}/${sources_for_run_catalog}/batch_scp $PORTOPT $catalog_option $append_option -b -m $usecycle_option -u $local_username $return_address  ${localout[$i]} \"${pathout[$i]}\" ${host_configuration}_${fname}${endout[$i]}  ${extout[$i]}"  |  ssh -q $remote_username@$remote_loginnode
+                   echo "cd $tempdir; ${fast_io_catalog}/${sources_for_run_catalog}/batch_scp $PORTOPT $catalog_option $append_option -b -m $usecycle_option -u $local_username $return_address  ${localout[$i]} \"${pathout[$i]}\" ${host_configuration}_${fname}${endout[$i]}  ${extout[$i]}"  |  ssh -q $remote_username@$remote_loginnode
                 else
                    batch_scp $PORTOPT $catalog_option $append_option -b -m $usecycle_option -u $local_username $return_address  ${localout[$i]} "${pathout[$i]}" ${host_configuration}_${fname}${endout[$i]}  ${extout[$i]}
@@ -2241,5 +2244,5 @@
 		                 ln -f $file  ${pathout[$i]}
 		              done >|/dev/null 2>&1
-		              cd $TEMPDIR
+		              cd $tempdir
 	            fi
 
@@ -2342,5 +2345,5 @@
        # ALL ACTIONS FINISHED, TEMPORARY WORKING-DIRECTORY CAN BE DELETED
     cd  $HOME
-    [[ $delete_temporary_catalog = true ]]  &&  rm -rf $TEMPDIR
+    [[ $delete_temporary_catalog = true ]]  &&  rm -rf $tempdir
 
 
@@ -2405,5 +2408,5 @@
     do
        (( i = i + 1 ))
-       line=`echo  "${batch_directive[$i]}" | sed 's/{{JOB_ID}}/$job_id/g' | sed 's/{{JOBFILE}}/$job_protocol_file/g' | sed 's/{{CPU_HOURS}}/$cpu_hours/g' | sed 's/{{CPU_MINUTES}}/$cpu_minutes/g' | sed 's/{{CPU_SECONDS}}/$cpu_seconds/g' | sed 's/{{NODES}}/$nodes/g' | sed 's/{{CORES}}/$cores/g' | sed 's/{{TASKS_PER_NODE}}/$tasks_per_node/g' | sed 's/{{HOST_CONFIGURATION}}/${host_configuration}/g' | sed 's/{{FNAME}}/$fname/g' | sed 's/{{QUEUE}}/$queue/g' | sed 's/{{MEMORY}}/$memory/g' | sed 's/{{PROJECT_ACCOUNT}}/$project_account/g' | sed 's/{{PREVIOUS_JOB}}/$previous_job/g' | sed 's/{{TEMPDIR}}/$TEMPDIR/g'`
+       line=`echo  "${batch_directive[$i]}" | sed 's/{{JOB_ID}}/$job_id/g' | sed 's/{{JOBFILE}}/$job_protocol_file/g' | sed 's/{{CPU_HOURS}}/$cpu_hours/g' | sed 's/{{CPU_MINUTES}}/$cpu_minutes/g' | sed 's/{{CPU_SECONDS}}/$cpu_seconds/g' | sed 's/{{NODES}}/$nodes/g' | sed 's/{{CORES}}/$cores/g' | sed 's/{{TASKS_PER_NODE}}/$tasks_per_node/g' | sed 's/{{HOST_CONFIGURATION}}/${host_configuration}/g' | sed 's/{{FNAME}}/$fname/g' | sed 's/{{QUEUE}}/$queue/g' | sed 's/{{MEMORY}}/$memory/g' | sed 's/{{PROJECT_ACCOUNT}}/$project_account/g' | sed 's/{{PREVIOUS_JOB}}/$previous_job/g' | sed 's/{{TEMPDIR}}/$tempdir/g'`
        eval line=\"$line\"
        echo  "$line"                               >>  $jobfile
@@ -2466,7 +2469,17 @@
 
        # CREATE TEMPORARY DIRECTORY AND SWITCH TO IT
-    echo  "mkdir  $TEMPDIR"              >>  $jobfile
-    echo  "cd  $TEMPDIR"                 >>  $jobfile
-    echo  "export TEMPDIR=$TEMPDIR"      >>  $jobfile
+    if [[ $create_remote_batch_job = true ]]
+    then
+       echo  "mkdir  $tempdir"           >>  $jobfile
+       echo  "chmod  go+rx  $tempdir"    >>  $jobfile
+    else
+          # DIRECTORY FOR LOCAL BATCH JOBS IS CREATED NOW, DUE TO A
+          # REQUIREMENT OF THE GRID ENGINE BATCH SYSTEM (WORKING DIR IS GIVEN IN
+          # BATCH DIRECTIVE -wd AND MUST ALREADY EXIST WHEN THE JOB IS SUBMITTED)
+       mkdir  $tempdir
+       chmod  go+rx  $tempdir
+    fi
+    echo  "cd  $tempdir"                 >>  $jobfile
+    echo  "export tempdir=$tempdir"      >>  $jobfile
     echo  "cp  ${fast_io_catalog}/${sources_for_run_catalog}/{*,.[!.]*}  ."  >>  $jobfile
     echo  "export PATH=.:\$PATH"         >>  $jobfile
@@ -2533,13 +2546,12 @@
 
           echo " "
-          echo "  *** transfer of job to remote host via scp"
+          echo " *** transfer of job to remote host via scp"
           if [[ $do_trace = true ]]
           then
              echo "     scp $ssh_key $PORTOPT $jobfile ${remote_username}@${remote_ip}:${remote_jobcatalog}/${host_configuration}_${job_id}"
           fi
-          scp $ssh_key $PORTOPT $jobfile ${remote_username}@${remote_ip}:${remote_jobcatalog}/${host_configuration}_${job_id}
-
-          echo " "
-          echo "  *** submit the job (output of submit command, e.g. the job-id, may follow)"
+          scp $ssh_key $PORTOPT $jobfile ${remote_username}@${remote_ip}:${remote_jobcatalog}/${host_configuration}_${job_id}  >  /dev/null
+
+          printf " *** submit the job (output of submit command, e.g. the job-id, may follow)"
           if [[ $do_trace = true ]]
           then
