title: How do I use sbatch with SLURM and a makefile?
body: <p>I am trying to submit batch jobs to SLURM but I keep getting <code>JobState=FAILED Reason=NonZeroExitCode</code>. I can compile and run the code fine on regular g++ but I have to use SLURM for an assignment for school. I thought I was running them properly and I got a nasty-gram from the root telling me to quit running scripts on the login node. Any help would be appreciated. Here is my batch file and my Makefile:</p>
  
  <pre><code>#!/bin/bash
  #SBATCH -N1 -n1 --mem-per-cpu=100m -t00:05:00
  echo "#SBATCH -N1 -n1 --mem-per-cpu=100m -t00:05:00 --qos=test"
  cd /home/&lt;username&gt;/AFS/cse_430/Project1/Parallel/
  module load gcc/4.9.1
  make clean
  make all
  echo "Running single threaded code..."
  ./run "SeqCA(57;4,10).txt"
  echo "Done experiment. Check log.txt"
  </code></pre>
  
  <p>Makefile:</p>
  
  <pre><code>EXEC=run    # name of executable is run
  CC=g++      # compile with g++
  CFLAGS=-std=c++11 -fopenmp -c -Wall 
  
  all: $(EXEC)
  
  $(EXEC): main.o threeSeq.o fourSeq.o fiveSeq.o
      $(CC) -fopenmp -o $(EXEC) main.o threeSeq.o fourSeq.o fiveSeq.o 
  
  main.o: main.cpp
      $(CC) $(CFLAGS) main.cpp
  
  threeSeq.o: threeSeq.cpp threeSeq.hpp
      $(CC) $(CFLAGS) threeSeq.cpp
  
  fourSeq.o: fourSeq.cpp fourSeq.hpp
      $(CC) $(CFLAGS) fourSeq.cpp
  
  fiveSeq.o: fiveSeq.cpp fiveSeq.hpp
      $(CC) $(CFLAGS) fiveSeq.cpp
  
  clean: 
      rm -f *.o
      rm -f $(EXEC)
      rm -f *log.txt
  </code></pre>