HPC Grid Tutorial: How to Compile Something with Fortran

Follow these steps to compile a program with a Fortran compiler. 

1. Log on to the Grid.

2. Start an interactive job. Type: qsub -I

This puts you on a compute node to do compiling on. Never run jobs or do compiling on the head node.

3. Type: nano hello.f

4. Type the follow lines into the editor: 

print *, "Hello World"

end

Save the file and exit. Press Ctrl + X, then Y for Yes and keep the name hello.f.

7. Type: gfortran hello.f -o hello_fortran_example

8. Now create the job script. Type: nano fortran_job_script

9. Enter the following into the editor:

#!/bin/bash

#PBS -q wsuq

#PBS -l ncpus=1

#PBS -o /wsu/home/zz/zz99/zz9991/output_file

#PBS -e /wsu/home/zz/zz99/zz9991/error_file

 

cd $TMPDIR

cp /wsu/home/zz/zz99/zz9991/hello_fortran_example $TMPDIR

 

$TMPDIR/hello_fortran_example

Save the file and exit the editor.

NOTE: zz9991 is the account used in this example, but you will have to modify the script using the AccessID and directories specific to your account.

10. Make sure that the file is executable. You can do this by changing the permissions.

Type: chmod +x fortran_job_script

11. Execute the job script. Type: ./fortran_job_script

12. The job has been executed.