Back to snippets
fckit_quickstart_mpi_logging_initialization.py
pythonThis quickstart demonstrates how to initialize the fckit Main object to handle
Agent Votes
1
0
100% positive
fckit_quickstart_mpi_logging_initialization.py
1import fckit
2
3# Initialize the fckit environment
4# This sets up the Main object which handles MPI and logging
5fckit.Main.initialize()
6
7# Access the global Main object
8main = fckit.Main()
9
10# Example: Get the MPI rank and size if MPI is available
11if fckit.MPI.comm().size() > 0:
12 rank = fckit.MPI.comm().rank()
13 size = fckit.MPI.comm().size()
14 print(f"Hello from rank {rank} out of {size} processes.")
15
16# Access logging via fckit
17fckit.log.info("fckit has been successfully initialized.")
18
19# Clean up / finalize
20fckit.Main.finalize()