Ignore:
Timestamp:
Jul 28, 2025, 4:56:58 PM (6 days ago)
Author:
jbclement
Message:

PEM:
Bug correction to detect the job time limit with PBS/TORQUE. Making it more robust and automatic for the launching script and the Fortran code.
JBC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh

    r3861 r3869  
    2828    if command -v squeue &> /dev/null; then
    2929        echo "SLURM is installed on $machine."
     30        scheduler="SLURM"
    3031        name_job="#SBATCH --job-name="
    3132        kill_job="scancel"
    32         submit_job="sbatch --parsable"
    33         submit_dependjob="sbatch --parsable --dependency"
    3433    elif command -v qstat &> /dev/null; then
    3534        echo "PBS/TORQUE is installed on $machine."
     35        scheduler="PBS"
    3636        name_job="#PBS -N "
    3737        kill_job="qdel"
    38         submit_job="qsub"
    39         submit_dependjob="qsub -W depend"
    4038    else
    4139        echo "Error: neither SLURM nor TORQUE/PBS is installed on $machine!"
     
    256254            sed -i -E "/^$name_job/s/(.*[^0-9])([0-9]+)(_[^0-9]*)?$/\1${iPCM}\3/" PCMrun${iPCM}.job
    257255            sed -i "s/^k=-\?[0-9]\+$/k=$(echo "$ii - $3 + 2" | bc)/" PCMrun${iPCM}.job
    258             jobID=$(eval "$submit_job PCMrun${iPCM}.job")
     256            if [[ "$scheduler" == "SLURM" ]]; then
     257                jobID=$(sbatch --parsable PCMrun${iPCM}.job)
     258            elif [[ "$scheduler" == "PBS" ]]; then
     259                jobID=$(qsub PCMrun${iPCM}.job | cut -d. -f1)
     260            fi
    259261            # Create a file to cancel the dependent jobs of the cycle
    260262            echo "#!/bin/bash" > kill_launchPEM.sh
     
    283285                sed -i -E "/^$name_job/s/(.*[^0-9])([0-9]+)(_[^0-9]*)?$/\1${iPCM}\3/" PCMrun${iPCM}.job
    284286                sed -i "s/^k=-\?[0-9]\+$/k=$(echo "$i - $3 + 2" | bc)/" PCMrun${iPCM}.job
    285                 jobID=$(eval "$submit_dependjob=afterok:${jobID} PCMrun${iPCM}.job")
     287                if [[ "$scheduler" == "SLURM" ]]; then
     288                    jobID=$(sbatch --parsable --dependency=afterok:${jobID} PCMrun${iPCM}.job)
     289                elif [[ "$scheduler" == "PBS" ]]; then
     290                    jobID=$(qsub -W depend=afterok:${jobID} PCMrun${iPCM}.job | cut -d. -f1)
     291                fi
    286292                echo $kill_job $jobID >> kill_launchPEM.sh
    287293            fi
     
    308314        else # Mode: submitting jobs
    309315            sed -i -E "/^$name_job/s/(.*[^0-9])([0-9]+)(_[^0-9]*)?$/\1${iPEM}\3/" PEMrun.job
    310             jobID=$(eval "$submit_job PEMrun.job")
     316            if [[ "$scheduler" == "SLURM" ]]; then
     317                jobID=$(sbatch --parsable PEMrun.job)
     318            elif [[ "$scheduler" == "PBS" ]]; then
     319                jobID=$(qsub PEMrun.job | cut -d. -f1)
     320            fi
    311321            # Create a file to cancel the dependent jobs of the cycle
    312322            echo "#!/bin/bash" > kill_launchPEM.sh
     
    338348        else # Mode: submitting jobs
    339349            sed -i -E "/^$name_job/s/(.*[^0-9])([0-9]+)(_[^0-9]*)?$/\1${iPEM}\3/" PEMrun.job
    340             jobID=$(eval "$submit_dependjob=afterok:${jobID} PEMrun.job")
     350            if [[ "$scheduler" == "SLURM" ]]; then
     351                jobID=$(sbatch --parsable --dependency=afterok:${jobID} PEMrun.job)
     352            elif [[ "$scheduler" == "PBS" ]]; then
     353                jobID=$(qsub -W depend=afterok:${jobID} PEMrun.job | cut -d. -f1)
     354            fi
    341355            echo $kill_job $jobID >> kill_launchPEM.sh
    342356        fi
Note: See TracChangeset for help on using the changeset viewer.