The idea is that you can fork this project into your own system, and you immediately have a structure and a surrounding CMake environment to compile and test.
This project has been crafted with the scientists of the Centre of Excellence for Climate System Science in mind. Feel free to use it, but don't be confused when some parts of this document are specifically geared towards the computational infrastructure for these scientists.
After you have cloned this repo, go into its main directory and type the following:
mkdir RELEASE
cd RELEASE
cmake ..
make -j
make install
This should build a tiny library lib/static/liblib1.a
with a single funtion is_two(n)
which returns .T.
if and only if the only parameter is indeed 2, and .F.
otherwise,
and a single program bin/exe1
that will write "Hello World" and check for each
number in 1..5 whether this number is indeed 2.
You can also build a DEBUG
version by just renaming the directory.
In DEBUG
, several debug options are selected when compiling, and the code is not
optimised.
If you have pFUnit installed, it should also manage to write a unit test test/test1
that tests the library.
You can run this test by running the following command in your build directory
make test
You only have to re-run the cmake
command from above if you add new files or change
any CMakeLists.txt
files. Otherwise, the make
commands alone will be enough to
build after code changes.
This has been tested on raijin
at the NCI with the following environment:
For serial:
module purge
module load cmake intel-fc/16.0.3.210 intel-cc/16.0.3.210
module use ~access/modules
module load pfunit/3.2.7-serial
For parallel:
module purge
module load cmake intel-fc/16.0.3.210 intel-cc/16.0.3.210 openmpi/1.8.6
module use ~access/modules
module load pfunit/3.2.7
export FC=mpif90
- Create a new subdirectory under
modules
. - Change the
modules/CMakeLists.txt
to include your new subdirectory. - Copy the
modules/lib1/CMakeLists.txt
into your new subdirectory and change the project name.
- Create a new subdirectory under
executables
. - Modify
executables/CMakeLists.txt
to include your new subdirectory. - Copy
executables/exe1/CMakeLists.txt
into your new subdirectory and change the project name. (Also, you might want to remove the dependency tomod1
.)
- Create a new subdirectory under
tests
. - Modify
tests/CMakeLists.txt
to include your new subdirectory. - Copy
tests/test1/CMakeLists.txt
into your new subdirectory and change the project name. - Ensure that you add a dependency to the library you want to test.
- Write your
pFUnit
compliant tests into files with the extension.pf
- Add an
add_test()
line to theCMakeLists.txt
file in the root directory.