Follow these steps to compile a program with a C/C++ compiler.
Step 1
Log on to the Grid.
Step 2
Start an interactive job and type srun -q debug -t 10:0 --pty bash.
Note: This puts you on a compute node for you to do compiling on. Never run jobs or do compiling on the head node Warrior.
Step 3
Type nano hello.c.
Step 4
Type the following lines into the editor:

- The spaces may be important, depending upon the compiler. There are six spaces (a tab) before each line.
- Save the file and exit.
- Press Ctrl + X, then Y for Yes and keep the name hello.c.
Step 5
- Choose a C/C++ compiler. In this example we will use gcc.
- Load the module.
- Type
module load gnu7/7.3.0.
Step 6
To see the pathname of the gcc compiler you will be using type which gcc. This shows you the first instance of it in your path.
Step 7
Type gcc hello.c -o hello_c_example.
Step 8
Now that you're done compiling, end the interactive job by pressing Ctrl + D.
Step 9
Create the job script. Type nano c_job_script.
Step 10
Enter the following into the editor:
#!/bin/bash
# Job name
#SBATCH --job-name C Job
# Submit to the primary QoS
#SBATCH -q primary
# Request one node
#SBATCH -N 1
# Total number of cores, in this example it will 1 node with 1 core each.
#SBATCH -n 1
# Request memory
#SBATCH --mem=5G
# Mail when the job begins, ends, fails, requeues
#SBATCH --mail-type=ALL
# Where to send email alerts
#SBATCH --mail-user=xxyyyy@wayne.edu
# Create an output file that will be output_<jobid>.out
#SBATCH -o output_%j.out
# Create an error file that will be error_<jobid>.out
#SBATCH -e errors_%j.err
# Set maximum time limit
#SBATCH -t 1-:0:0
cd $TMPDIR
cp /wsu/home/zz/zz99/zz9991/hello_c_example $TMPDIR
$TMPDIR/hello_c_example
Step 11
Save the file and exit the editor. Press Ctrl + X, then Y for Yes and keep the name c_job_script.
Note: zz9992 is the account used in this example, but you will have to modify the script using the AccessID and directories specific to your account.
Step 12
Make sure that the file is executable. You can do this by changing the permissions.
Type chmod +x c_job_script.
Step 13
Submit the job. Type sbatch c_job_script.
Step 14
- You can check to see what jobs you're running by using the command qme.
- Once the job is finished running you will have an error and output file.
- Check your home directory by typing
ls.