I tried to submit a job via the command line incorporating --wrap instead of submitting through a submission script. And for some reason none of the slurm_variables are initialized:
sbatch --job-name NVP --time 01:00:00 --nodes 1 --ntasks 1 --cpus-per-task 2 --wrap "echo "var1:" $SLURM_CPUS_PER_TASK "var2:" $SLURM_JOB_NAME"
In this case both $SLURM_CPUS_PER_TASK and $SLURM_JOB_NAME are empty. Once the exact same code is submitted via a script, the variables show up.
I could not figure out what is wrong with my command line submission.