Build the code as normal with the -prof-gen=srcpos -prof-dir=PATH_TO_PROF_DIR/prof-info compiler flag. Where PATH_TO_PROF_DIR is the path to a directory that you have created to store the profiling information.
Run the test/simulation as normal and this should generate a .dyn file in prof-info, which contains dynamic profile information.
Navigate to the prof-info directory.
Use the profmerge tool to merge all .dyn files into one .dpi file. This merges multiple .dyn from successive runs of the application with different runtime parameters (e.g. running test27cells with varying number of particles per cell):
(Note: If you only want code coverage from the last test run remove old .dyn files and the .dpi file in the prof-info directory. As old test runs might cover code that was not covered in the latest test run.)
Run the code coverage tool:
This will generate an HTML file called CODE_COVERAGE.HTML, which contains the code coverage report and show how much of the application was actually executed, line by line.
If you didn't specify the -prof-dir flag you can run the code coverage tool and specify the path to SWIFT library .spi file instead:
codecov -spi swiftsim/src/pgopti.spi
(However this will not contain code coverage for the test source code itself.)