-
Notifications
You must be signed in to change notification settings - Fork 63
Step 0 Hello World
In this first tutorial we write the Hello World equivalent of t8code.
We will initalize t8code and use it to print a short message on the root process.
You will find the code in tutorials/general/t8_step0_helloworld.cxx, and it creates the executable tutorials/general/t8_step0_helloworld.
To initalize t8code we need to initialize (in this order) MPI, libsc and t8code.
We then use t8_global_productionf to print a message on the root process.
At the end of our program, we need to finalize libsc and then MPI.
Note that libsc wraps all MPI calls and data structures, which is why we prefix these with sc or SC.
#include <t8.h>
int
main (int argc, char **argv)
{
int mpiret;
/* Initialize MPI. This has to happen before we initialize sc or t8code. */
mpiret = sc_MPI_Init (&argc, &argv);
/* Error check the MPI return value. */
SC_CHECK_MPI (mpiret);
/* Initialize the sc library, has to happen before we initialize t8code. */
sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_ESSENTIAL);
/* Initialize t8code with log level SC_LP_PRODUCTION. See sc.h for more info on the log levels. */
t8_init (SC_LP_PRODUCTION);
/* Print a message on the root process. */
t8_global_productionf (" [step0] \n");
t8_global_productionf (" [step0] Hello, this is t8code :)\n");
t8_global_productionf (" [step0] \n");
sc_finalize ();
mpiret = sc_MPI_Finalize ();
SC_CHECK_MPI (mpiret);
return 0;
}To output a message on the root process in this Hello World example we use the function t8_global_productionf.
t8code offers various logging functions and logging levels via libsc.
In short, logging functions of the form t8_global_* (t8_global_essentialf, t8_global_errorf, etc.) only print on the root process, while logging functions without the global print on each process with the MPI rank as part of the message (t8_productionf, t8_essentialf, t8_errorf, t8_debugf). For a description of all logging functions see t8.h.
The logging level is set with t8_init (in the example above it is SC_LP_PRODUCTION) and determines which of these get printed.
The different logging levels are described in sc.h in detail. The most common are
| Log level | description |
|---|---|
| SC_LP_DEBUG | logs almost everything, in particular t8_debugf
|
| SC_LP_PRODUCTION | logs *_production, *_essential and *_error
|
| SC_LP_SILENT | never logs anything |
General
Step 0 Hello World
Step 1 Creating a coarse mesh
Step 2 Creating a uniform forest
Step 3 Adapting a forest
Step 4 Partition,-Balance,-Ghost
Step 5 Store element data
Step 6 Computing stencils
Step 7 Interpolation
Features
Prerequisites & Compilation
t8_time_forest_partition
t8_time_fractal
t8_time_new_refine
t8_time_partition
t8_time_prism
t8_time_set_join_by_vertices
Documentation
Tree Indexing
Element Indexing
Running on JUWELS using Slurm
Overview of the most used API functions
Known issues
Workflow - FreeCAD to t8code
Reproducing Scaling Results
Coding Guidelines
Contribution Workflow
Tips
Debugging with gdb
Debugging with valgrind
Development modules
Generating a code coverage report
Test driven development
Testing with GoogleTest
Writing C interface code