[localhost]
PARALLEL_COMMAND = mpirun -np %_(JOB_NODES)d -bynode %_(COMMAND)s
NAME = SLURM
MANDATORY = False
SUBMIT_COMMAND = sbatch %_(JOB_SCRIPT)s
CANCEL_COMMAND = scancel %_(JOB_ID)s
CHECK_COMMAND = squeue -j %_(JOB_ID)s
SUBMIT_TEMPLATE = #!/bin/bash
        ### Job name
        #SBATCH -J %_(JOB_NAME)s
        ### Outputs (we need to escape the job id as %%j)
        #SBATCH -o %_(JOB_LOGS)s.out
        #SBATCH -e %_(JOB_LOGS)s.err
        ### Partition (queue) name
        ### if the system has only 1 queue, it can be omited
        ### if you want to specify the queue, ensure the name in the scipion dialog matches
        ### a slurm partition, then leave only 1 # sign in the next line
        ##### SBATCH -p %_(JOB_QUEUE)s

        ### Specify time, number of nodes (tasks), cores and memory(MB) for your job
        #SBATCH --time=%_(JOB_TIME)s:00:00 --ntasks=%_(JOB_NODES)d --cpus-per-task=%_(JOB_THREADS)d --mem=%_(JOB_MEMORY)s --gres=gpu:%_(GPU_COUNT)s
        # Use as working dir the path where sbatch was launched
        WORKDIR=$SLURM_SUBMIT_DIR

        #################################
        ### Set environment varible to know running mode is non interactive
        export XMIPP_IN_QUEUE=1

        cd $WORKDIR
        # Make a copy of node file
        echo $SLURM_JOB_NODELIST > %_(JOB_NODEFILE)s
        # Calculate the number of processors allocated to this run.
        NPROCS=`wc -l < %_(JOB_NODEFILE)s`
        # Calculate the number of nodes allocated.
        NNODES=`uniq %_(JOB_NODEFILE)s | wc -l`

        ### Display the job context
        echo Running on host `hostname`
        echo Time is `date`
        echo Working directory is `pwd`
        echo Using ${NPROCS} processors across ${NNODES} nodes
        echo NODE LIST - config:
        cat %_(JOB_NODEFILE)s
        echo CUDA_VISIBLE_DEVICES: $CUDA_VISIBLE_DEVICES
        #################################
        # echo '%_(JOB_COMMAND)s' >> /tmp/slurm-jobs.log
        /home/scipion/scipion3/scipion3 run %_(JOB_COMMAND)s
        find "$SLURM_SUBMIT_DIR" -type f -user $USER -perm 644 -exec chmod 664 {} + 
QUEUES = {
        "debug": [["JOB_MEMORY", "4096", "Memory (MB)", "Select amount of memory (in megabytes) for this job"],
                                    ["JOB_TIME", "12", "Time (hours)", "Select the time expected (in hours) for this job"],
                                    ["GPU_COUNT", "0", "Number of GPUs", "Select the number of GPUs if protocol has been set up to use them"],
                                    ["QUEUE_FOR_JOBS", "N", "Use queue for jobs", "Send individual jobs to queue"]
                                    ]
                  }



