Hi all, in order to observe the progress of the running code, I want to output the computational results from FEniCS/FEniCSX in each iteration. And here is a minimal example:
from mpi4py import MPI
import time
Iter = 0
while Iter < 3:
Iter += 1
if MPI.COMM_WORLD.rank == 0:
print('Iter=%d: some results obtained in FEniCS/FEniCSX' %Iter)
else:
pass
time.sleep(1)
When we run the code in serial, it can give us the result in each iteration immediately:
Iter 1:
Iter=1: some results obtained in FEniCS/FEniCSX
Iter 2:
Iter=2: some results obtained in FEniCS/FEniCSX
Iter 3:
Iter=3: some results obtained in FEniCS/FEniCSX
However, if we run the code in parallel, then it will NOT give us any results until all the calculations are finished. After finishing all the calculations, the results will be given in one shot. Then it is meaningless in terms of observing the progress.
Iter=1: some results obtained in FEniCS/FEniCSX
Iter=2: some results obtained in FEniCS/FEniCSX
Iter=3: some results obtained in FEniCS/FEniCSX
So do we have a way to output the result immediately to the terminal even if we run the code in parallel? I am using VS Code and Docker.
Thanks!