environment-variablesjuliaslurm

How to check if my code runs inside a SLURM environment using Julia?


I would like to answer this question in Julia. I tried to know if there was an environment variable containing SLURM:

julia> sum([occursin("SLURM",ENV[k]) for k in keys(ENV)])
0

But it seems there is not. How should I do?


Solution

  • You're checking if SLURM is the values of the env, not the keys. If you're looking for a variable whose name contains SLURM then you want sum([occursin("XPC",k) for k in keys(ENV)]) (or even better, any([occursin("XPC",k) for k in keys(ENV)]))