Browse Source

Cleaned Genius skeleton

klein 5 years ago
parent
commit
6a1a56da3f
2 changed files with 18 additions and 16 deletions
  1. 3 2
      coral
  2. 15 14
      templates/scripts/skeleton.sh

+ 3 - 2
coral

@@ -120,8 +120,9 @@ EOT
         if [ -z "$credits" ]; then
              credits="laerocloud"
         fi
- 	echo ${output_script} > script_name       
-        echo ${PWD} > address
+	mkdir -p tmp
+ 	echo ${output_script} > tmp/script_name       
+        echo ${PWD} > tmp/address
         qsub -A $credits "${output_script}" | tee -a coral_jobs;	
 
         sleep 2

+ 15 - 14
templates/scripts/skeleton.sh

@@ -269,18 +269,21 @@ if (( leg_end_epoch < run_end_epoch )) ; then
     elif [ "${submit_command}" == *sbatch* ] ; then
         sbatch $0 $@ | awk '{print $4}' >> ${run_dir}/.coral_jobs
     elif [[ $USER == "vsc"* ]]; then
-        # Retrieve credits
-        if [ -f ${PBS_O_WORKDIR-$PWD}"/"credits_file ]; then
-            credits=`cat ${PBS_O_WORKDIR-$PWD}"/"credits_file`
+        if [ -f ${PBS_O_WORKDIR-$PWD}/tmp/credits_file ]; then
+            credits=`cat ${PBS_O_WORKDIR-$PWD}/tmp/credits_file`
         else
-            logfiletmp=`echo ${PBS_O_WORKDIR-$PWD} | rev | cut -d'/' -f1 | rev`
-            logfiletmp2=`echo $logfiletmp | cut -d'_' -f1`
-            logfile=`ls ${PBS_O_WORKDIR-$PWD}"/"$logfiletmp2*.o*`
-            credits=`grep "account string:" $logfile | sed 's/^.*: //'`
-            echo ${credits} > credits_file
+            #logfiletmp=`echo ${PBS_O_WORKDIR-$PWD} | rev | cut -d'/' -f1 | rev`
+            #logfiletmp2=`echo $logfiletmp | cut -d'_' -f1`
+            #logfile=`ls ${PBS_O_WORKDIR-$PWD}"/"$logfiletmp2*.o*`
+            #credits=`grep "account string:" $logfile | sed 's/^.*: //'`
+            credits_tmp=`grep "account string:" ${PBS_O_WORKDIR-$PWD}/*.o* -R | sed 's/^.*: //'`
+            credits=`echo $credits_tmp | awk '{ print $1 }'`
+
+            mkdir -p tmp
+            echo ${credits} > tmp/credits_file
         fi
-        script_name=`cat ${PBS_O_WORKDIR-$PWD}"/"script_name`
-        run_path=`cat ${PBS_O_WORKDIR-$PWD}"/"address`
+        script_name=`cat ${PBS_O_WORKDIR-$PWD}/tmp/script_name`
+        run_path=`cat ${PBS_O_WORKDIR-$PWD}/tmp/address`
         ssh login2 "cd $run_path; qsub -A $credits $script_name | tee -a coral_jobs"
         sleep 2
         jobid=`cat coral_jobs`
@@ -297,10 +300,8 @@ if (( leg_end_epoch < run_end_epoch )) ; then
     fi
 else
     if [[ $USER == "vsc"* ]]; then
-        run_path=`cat ${PBS_O_WORKDIR-$PWD}"/"address`
-        rm -f $run_path/script_name
-        rm -f $run_path/address
-	rm -f $run_path/credits_file
+        run_path=`cat ${PBS_O_WORKDIR-$PWD}/tmp/address`
+        rm -rf $run_path/tmp
     fi
 
     echo "Nothing left to do. Cleaning and exiting." # FIXME Factorize this (we have two exit points)