Browse Source

Fixed legs restart on Genius

klein 5 years ago
parent
commit
d8e77950af
2 changed files with 51 additions and 9 deletions
  1. 28 9
      coral
  2. 23 0
      templates/scripts/skeleton.sh

+ 28 - 9
coral

@@ -114,15 +114,34 @@ EOT
   } 
 
   which qsub &> /dev/null && {
-     #qsub "${output_script}" "$@" | tee -a "${run_dir}"/.coral_jobs;
-     qsub -v PBS_OPTIONS="$@" "${output_script}" | tee -a coral_jobs;
-     sleep 2
-     jobid=`cat coral_jobs`
-     rm -f coral_jobs
-     jobid=${jobid%.*} 
-     mkdir -p "${run_dir:?}"
-     echo "${jobid}" >> "${run_dir}"/.coral_jobs ;
-     qstat -J "${jobid}"
+
+     if [[ $USER == "vsc"* ]]; then
+        credits=$@
+        if [ -z "$credits" ]; then
+             credits="laerocloud"
+        fi
+ 	echo ${output_script} > script_name       
+        echo ${PWD} > address
+        qsub -A $credits "${output_script}" | tee -a coral_jobs;	
+
+        sleep 2
+        jobid=`cat coral_jobs`
+        rm -f coral_jobs
+        jobid=${jobid%%.*}
+        mkdir -p "${run_dir:?}"
+        echo "${jobid}" >> "${run_dir}"/.coral_jobs ;
+        qstat
+     else
+        qsub -v PBS_OPTIONS="$@" "${output_script}" | tee -a coral_jobs;
+        sleep 2
+        jobid=`cat coral_jobs`
+        rm -f coral_jobs
+        jobid=${jobid%.*} 
+        mkdir -p "${run_dir:?}"
+        echo "${jobid}" >> "${run_dir}"/.coral_jobs ;
+        qstat -J "${jobid}"
+     fi
+
      exit 0; 
   } 
   )

+ 23 - 0
templates/scripts/skeleton.sh

@@ -268,6 +268,23 @@ if (( leg_end_epoch < run_end_epoch )) ; then
         exec "$0" "$@"
     elif [ "${submit_command}" == *sbatch* ] ; then
         sbatch $0 $@ | awk '{print $4}' >> ${run_dir}/.coral_jobs
+    elif [[ $USER == "vsc"* ]]; then
+        # Retrieve credits
+        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/^.*: //'`
+        if [ -z "$credits" ]; then
+            credits="laerocloud"
+        fi
+        script_name=`cat ${PBS_O_WORKDIR-$PWD}"/"script_name`
+        run_path=`cat ${PBS_O_WORKDIR-$PWD}"/"address`
+        ssh login2 "cd $run_path; qsub -A $credits $script_name | tee -a coral_jobs"
+        sleep 2
+        jobid=`cat coral_jobs`
+        rm -f coral_jobs
+        jobid=${jobid%%.*}
+        echo "${jobid}" >> "${run_dir}"/.coral_jobs ;
     else
         "qsub" -v PBS_OPTIONS="$@" "$0" | tee -a coral_jobs
         sleep 2
@@ -277,6 +294,12 @@ if (( leg_end_epoch < run_end_epoch )) ; then
         echo "${jobid}" >> "${run_dir}"/.coral_jobs
     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
+    fi
+
     echo "Nothing left to do. Cleaning and exiting." # FIXME Factorize this (we have two exit points)
     for (( n=0 ; n<nem_numproc ; n++ ))
     do