Supporting code for a tutorial on developing code locally and deploying it on the University of Delaware's DARWIN cluster.
The code is a simple root finder written in C. Compilation is handled through a Makefile and unit tests are included so that portable compilation and testing can be demonstrated as part of the tutorial.
There are two TODOs to implement in root_finding_funcs.c so that the driver code root_finder.c computes a meaningful result.
This repository is a "template repository". This means you can create your own repository based on this one, with the freedom to choose a new name and whichever visibility you prefer (public or private). Refer to GitHub's documentation on creating a repository from a template for instructions on how to do this.
Once you have created your own repository based on this template, you should clone your repository on your local machine and on DARWIN.
Your local machine will need to have a C compiler, GNU Make, and Git installed so that you can follow the tutorial. Guidance is provided below for installing these depenencies on some common operating systems, although this is not an exhaustive list.
Make sure you have administrator/root access to the machine where you want to install these dependencies. Otherwise, the command provided below will not work.
Git should be available by default. You can install a C compiler and GNU Make by running:
sudo apt install build-essential(The build-essential package bundles together several useful packages for C and C++ code development.)
All dependencies can be installed by running:
xcode-select --install(This installs the Xcode command-line tools.)
There are four Make targets:
root_findercompiles the driver code which finds the root of a given function.testscompiles the unit tests.run_testscompiles and runs the unit tests (or just runs them if they have already been compiled).cleanremoves the executables for the driver code and tests.
For example, starting from a clean working directory, running
make run_testswill compile and run the tests.
On DARWIN, you will need to load a recent GCC compiler before running any Make commands. For example:
vpkg_devrequire gcc/14.2Once you have done so, compilation works the same as on your local machine.
The job script root_finder_job.qs submits a job array with three array tasks that start from different initial guesses. To submit this job, run:
sbatch root_finder_job.qs