Public course previewThis is not your assigned passport. No identity, answers, or completion progress are stored here.How to start your passport
Guided lesson
05 / 06About 30 minutesEuler resource planning

Cap And Calculate Euler Job Arrays

Calculate an array's peak demand with another job already active, then choose a cap that fits a supplied budget. Keep the local guided file repair.

Where you will workOn the laptop or desktop in front of you
  1. 1Understand
  2. 2Try it yourself
  3. 3Check and submit

Before you start#

A job array repeats a job for several inputs. Its range gives the total number of tasks; the number after % is the concurrency cap, limiting how many can run together. Each running task requests its own CPUs and system memory. Your other jobs count too. A distinct log name identifies each task and keeps its output separate.

Plan the proposal at the calculation step, then answer the three questions. You can use paper or a calculator.

The guided file repair and the planning example are separate. Keep the practice file at its required cap of one; do not put the proposed caps into it or submit an array to Euler.

A reminder for the calculation

Count simultaneous array tasks first, then work out their CPU and memory requests. Add the resources held by every other job. Compare CPU and memory separately with the budget; fitting one limit is not enough.

--mem-per-cpu requests memory for each allocated CPU. --mem requests memory per node. In this example each array task uses one node and one Slurm task. Do not use both memory options in the same script.

A planning cap is not the required cap-one file repair. Keep them separate.

Start the practice

Practice

Follow the steps

Follow in order

Steps

The supplied file is deliberately unsafe. Edit it locally and never submit it to Euler.

Optional: using the terminal

A command is a line of text that tells a computer to do one task. You paste it into a terminal, the text application used for commands. A shell is the part inside that application that reads the command. PowerShell, zsh, and Bash are shells. Open only the application named for your computer below; it starts its configured shell. Follow the shell named below. You do not need to install a separate Bash or zsh application.

Your computer or local means the laptop or desktop in front of you. Remote means another computer reached through the network. A command affects whichever computer the step names, so check that label before pasting.

  • Windows: press the Windows key, type PowerShell, and open the result named PowerShell. Do not use Command Prompt, Git Bash, or WSL for a block labelled PowerShell.
  • macOS: press Command+Space, type Terminal, and press Return. Terminal normally starts the zsh shell. If it uses another shell, run zsh for this session.
  • Linux: open the app named Terminal from the applications menu. It normally starts the Bash shell. If it uses another shell, run bash for this session.

The prompt is the text beside the blinking cursor. For each card, check the named computer, choose Copy, paste only the command after the prompt, press Enter once, and wait for the prompt to return.

If you have never done this before, first run the harmless terminal-ready practice on the start page. It lets you practise copying, pasting, pressing Enter, and reading output before a setup command.

Practise one harmless command firstHow to open a terminal and run a command
  1. 01

    Understand an array and its concurrency cap

    Read and answer on this web page

    Read the range and cap distinction above. This is local review only; no array is submitted.

    Look forYou can distinguish total task count from the maximum running at once.

    Explanation and help
    What this means
    Open the deliberately unsafe local practice file.
    Safe recovery
    Do not submit a real array until you can calculate its simultaneous resource total.
  2. 02

    Prepare the array practice file

    On your computer

    Press Prepare practice folder, enter it, and open workspace/slurm/array_job.slurm.txt.

    Look forThe unsafe practice file is open in the separate practice repository.

    Explanation and help
    What this means
    Inspect it without submitting.
    Safe recovery
    Do not create your own replacement script or use Euler for this exercise.
  3. 03

    Inspect the cap and log names

    On your computer

    Read the array and two log directives in the unsafe local file. Which setting bounds simultaneous demand? Which filename placeholders identify the parent and index? Compare your reasoning with the repair steps afterwards; do not submit this file.

    Look forYou can explain the missing concurrency cap and why parent/index labels make array logs easier to trace.

    Explanation and help
    What this means
    Edit only the required directives.
    Safe recovery
    Review the array and log-name explanation before editing.
  4. 04

    Add a small concurrency cap

    On your computer

    Replace the unsafe array directive with the exact line below. It creates ten tasks, numbered 0 through 9, and allows at most one to run at a time.

    Show the required cap-one repair (file content)
    Put in fileBash file
    #SBATCH --array=0-9%1

    Look forThe directive is exactly --array=0-9%1.

    Explanation and help
    What this means
    Make the logs unique.
    Safe recovery
    Do not use an uncapped range or a zero cap.
  5. 05

    Use parent and task IDs in logs

    On your computer

    Replace both log directives with the two exact lines below. %A is the parent job ID and %a is the array task index.

    Show the required parent/index log lines (file content)
    Put in fileBash file
    #SBATCH --output=logs/%x_%A_%a.out
    #SBATCH --error=logs/%x_%A_%a.err

    Look forEach array task has a distinct output and error path.

    Explanation and help
    What this means
    Inspect the local diff.
    Safe recovery
    Correct both settings before pressing Check my work.
  6. 06

    Plan a different array on paper

    Read and answer on this web page

    Plan a different array on paper: 12 tasks, cap 3, 2 CPUs per task and 3 GiB per CPU. Another job holds 2 CPUs and 5 GiB. The fictional combined budget is 10 CPUs and 20 GiB. Assume one node and one Slurm task per array task, with allocated CPUs matching the request.

    Look forCompare peak requested CPUs and system memory with both fictional limits. This is not your Euler entitlement. Keep the practice file at cap one; no job is submitted.

    Explanation and help
    What this means
    Answer the three planning questions after reviewing the local file. For the memory-option comparison, replace the proposal's --mem-per-cpu=3G with --mem=3G; do not add both.
    Safe recovery
    If a calculation does not fit, reduce concurrency on paper. Do not change CPU or memory estimates just to fit a budget: a real program needs measured evidence first.
  7. 07

    Review the edited file

    On your computer

    Confirm that only the fictional practice file changed and that no command submitted it. Slurm ignores directives after the first shell command. Keep every #SBATCH line before commands, with one unquoted long option and literal value per line. Keep each option only once. Use the supplied options; optional --nodes and --ntasks must each be 1.

    RunPowerShell on Windows
    git diff -- workspace/slurm/array_job.slurm.txt
    RunTerminal on macOS (zsh)
    git diff -- workspace/slurm/array_job.slurm.txt
    RunTerminal on Linux (Bash)
    git diff -- workspace/slurm/array_job.slurm.txt

    Look forThe diff changes only the array cap and the two log names.

    If this differsRemove every unrelated change before continuing.

    Explanation and help
    What this means
    Run Check my work.

Finish the lesson

Check and submit

Answer these 3 questions, then confirm the work you checked.

Every answer must be correct. Completion appears after the automatic GitHub check passes.

01The proposed array has 12 tasks, cap 3, 2 CPUs per task and 3 GiB per CPU. Another job holds 2 CPUs and 5 GiB. What is the maximum combined demand?Safety-critical
02An array has 12 tasks, 2 CPUs per task and 3 GiB per CPU. Another job holds 2 CPUs and 5 GiB. Under a fictional combined budget of 10 CPUs and 20 GiB, what is the largest cap that fits both limits?Safety-critical
03A 12-task array is capped at 3. Each task uses one node, 2 CPUs and --mem=3G instead of --mem-per-cpu=3G. Another job holds 2 CPUs and 5 GiB. What is the combined peak request?Safety-critical
Before submitting

The launcher will copy only this lesson's declared fictional practice files into the public submission. Review those files as well as these answers.

Open my real passport first

You can check sample answers here. Open your local Passport to check your practice files and submit the lesson.

Preview onlyYou can try the questions here. This page does not store or submit your answers.
Need help?Open recovery steps and AI-review guidance

If Blocked#

Keep the guided file repair at --array=0-9%1. If a calculation fails, count running tasks, add the separate job, then check CPU and memory against their budgets. A planning cap of two does not change the required cap-one file repair.

If the file check fails, inspect the named file and its diff. Keep it smaller than 100000 bytes; remove only an understood accidental addition. Do not reset the repository, recreate your Passport, submit an array or change an account. Use the local Passport's public help request if the expected result stays unclear; exclude credentials, private logs and real research files.

Useful references, only if needed; return to this lesson afterwards:

Understand Before Accepting AI Output#

Calculate the combined request yourself. An array's cap does not constrain other jobs. A budget is a ceiling, not a target. The numbers in this lesson are fictional; an agent must not treat them as permission to launch real jobs or reduce a real memory estimate without measurements.