# Are print statements disabled on non zero ranks in python pipelines?

**URL:** https://discourse.paraview.org/t/are-print-statements-disabled-on-non-zero-ranks-in-python-pipelines/12787
**Category:** In Situ Support
**Created:** [August 31, 2023, 2:47pm UTC](https://discourse.paraview.org/t/are-print-statements-disabled-on-non-zero-ranks-in-python-pipelines/12787 "2023-08-31T14:47:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Alexandre\_Minot](https://discourse.paraview.org/user_avatar/discourse.paraview.org/alexandre_minot/32/7132_2.png) [@Alexandre\_Minot](https://discourse.paraview.org/u/Alexandre_Minot)
#### Post date: [August 31, 2023, 2:47pm UTC](https://discourse.paraview.org/t/are-print-statements-disabled-on-non-zero-ranks-in-python-pipelines/12787/1 "2023-08-31T14:47:22Z")

</div>

I have the following code in my python script:

```auto
if(rank == 0):
    print("print from rank 0")
    os.system("echo echo rank 0")
comm.Barrier()
if(rank == 1):
    print("print from rank 1")
    os.system("echo echo rank 1")
comm.Barrier()
print("hello again from rank %d"%rank)

```

Upon execution by the ParaView implementation of Catalyst 2 through an application running on 2 cores, I get the following output:

```auto
print from rank 0
echo rank 0
echo rank 1
hello again from rank 0

```

Note the absence of print from rank 1. I am quite confused by this. Are print statements disabled on non zero ranks? If yes, how is this done? How do I print on non zero ranks, for instance for debugging? I could not find any reference to this in the documentation. Are there other python methods that are disabled on non zero ranks?

Thanks,  
Alexandre

---

<div class="post-metadata">

### Author: ![Christos\_Tsolakis](https://discourse.paraview.org/user_avatar/discourse.paraview.org/christos_tsolakis/32/4450_2.png) [@Christos\_Tsolakis](https://discourse.paraview.org/u/Christos_Tsolakis)
#### Post date: [September 8, 2023, 12:57am UTC](https://discourse.paraview.org/t/are-print-statements-disabled-on-non-zero-ranks-in-python-pipelines/12787/2 "2023-09-08T00:57:19Z")

</div>

Hi @Alexandre_Minot ,

this is indeed strange. As far as I know we do not do anything special regarding MPI and limiting any kind of screen output from ranks . In fact, there is an [example](https://gitlab.kitware.com/paraview/paraview/-/blob/master/Examples/Catalyst2/Fortran90FullExample/catalyst_pipeline.py) catalyst script that prints per rank information.

In this particular example it could be that the output is buffered and you never get to see it. Try to add `flush=True` as argument in the `print` command or add `sys.stdout.flush()` before each barrier.

---

<div class="post-metadata">

### Author: ![Alexandre\_Minot](https://discourse.paraview.org/user_avatar/discourse.paraview.org/alexandre_minot/32/7132_2.png) [@Alexandre\_Minot](https://discourse.paraview.org/u/Alexandre_Minot)
#### Post date: [September 13, 2023, 6:23pm UTC](https://discourse.paraview.org/t/are-print-statements-disabled-on-non-zero-ranks-in-python-pipelines/12787/3 "2023-09-13T18:23:10Z")

</div>

Thanks for your help. I’m having trouble building the fortran example. It get:

```auto
CMake Error at Catalyst2/Fortran90FullExample/CMakeLists.txt:19 (add_executable):
  Target "Fortran90FullExampleV2" links to target
  "catalyst::catalyst_fortran" but the target was not found. Perhaps a
  find_package() call is missing for an IMPORTED target, or an ALIAS target
  is missing?

```

However, if I run the CxxPolyhedra example, I also get outputs only on rank 0. Could you add the rank number to the prints in the CxxPolyhedra example and post the output you get please?

---

<div class="post-metadata">

### Author: ![Christos\_Tsolakis](https://discourse.paraview.org/user_avatar/discourse.paraview.org/christos_tsolakis/32/4450_2.png) [@Christos\_Tsolakis](https://discourse.paraview.org/u/Christos_Tsolakis)
#### Post date: [September 13, 2023, 7:58pm UTC](https://discourse.paraview.org/t/are-print-statements-disabled-on-non-zero-ranks-in-python-pipelines/12787/4 "2023-09-13T19:58:22Z")

</div>

> I’m having trouble building the fortran example.

You will need to update [catalyst](https://gitlab.kitware.com/paraview/catalyst). Try the `v2.0.0-rc4` tag.

> Could you add the rank number to the prints in the CxxPolyhedra example and post the output you get please?

Sure ! [catalyst\_pipeline\_2.py](https://discourse.paraview.org/uploads/short-url/iEHi4aRr01ihIkD307BcGjqSdJe.py) (1.1 KB) is the new file  
and below what I get using catalyst `v2.0.0-rc4` and a recent ParaView build using commit e423f2cee420dd744027ad226c5f730759d367e1 from master

```auto
$ ./bin/CxxPolyhedraV2 ../catalyst_pipeline_2.py                           
executing catalyst_pipeline
( 0.357s) [pvbatch] v2_internals.py:171 WARN| Module 'catalyst_pipeline_2' missing Catalyst 'options', will use a default options object
====================================================
------------------- rank 0/1 ----------------------                                                                                                                   
executing (cycle=0, time=0.0)
bounds: (0.0, 69.0, 0.0, 64.9, 0.0, 55.9)
velocity-magnitude-range: (0.0, 0.0)
pressure-range: (1.0, 1.0) 
-------------------------------------------------------------

====================================================
------------------- rank 0/1 ----------------------
executing (cycle=1, time=0.1)
bounds: (0.0, 69.0, 0.0, 64.9, 0.0, 55.9)
velocity-magnitude-range: (0.0, 6.490000000000001)
pressure-range: (1.0, 1.0) 
-------------------------------------------------------------

====================================================
...

```

```auto
$ mpirun -np 4 ./bin/CxxPolyhedraV2 ../catalyst_pipeline_2.py 
executing catalyst_pipeline                                  
executing catalyst_pipeline                                                        
executing catalyst_pipeline                        
( 0.417s) [pvbatch] v2_internals.py:171 WARN| Module 'catalyst_pipeline_2' missing Catalyst 'options', will use a default options object
( 0.418s) [pvbatch] v2_internals.py:171 WARN| Module 'catalyst_pipeline_2' missing Catalyst 'options', will use a default options object
( 0.420s) [pvbatch] v2_internals.py:171 WARN| Module 'catalyst_pipeline_2' missing Catalyst 'options', will use a default options object
executing catalyst_pipeline              
( 0.426s) [pvbatch] v2_internals.py:171 WARN| Module 'catalyst_pipeline_2' missing Catalyst 'options', will use a default options object
====================================================                               
------------------- rank 0/4 ----------------------                                
executing (cycle=0, time=0.0)                      
bounds: (0.0, 17.0, 0.0, 64.9, 0.0, 55.9)          
velocity-magnitude-range: (0.0, 0.0)               
pressure-range: (1.0, 1.0)                
-------------------------------------------------------------
                                                                                   
------------------- rank 2/4 ----------------------                                
executing (cycle=0, time=0.0)                      
bounds: (35.0, 52.0, 0.0, 64.9, 0.0, 55.9)         
velocity-magnitude-range: (0.0, 0.0)      
pressure-range: (1.0, 1.0)                         
-------------------------------------------------------------
                                                                                   
------------------- rank 3/4 ----------------------                                
executing (cycle=0, time=0.0)                       
bounds: (52.0, 69.0, 0.0, 64.9, 0.0, 55.9)         
velocity-magnitude-range: (0.0, 0.0)        
pressure-range: (1.0, 1.0)                         
-------------------------------------------------------------
                                                                                   
------------------- rank 1/4 ----------------------                                
executing (cycle=0, time=0.0)                      
bounds: (17.0, 35.0, 0.0, 64.9, 0.0, 55.9)          
velocity-magnitude-range: (0.0, 0.0)               
pressure-range: (1.0, 1.0)                         
-------------------------------------------------------------
                                                                                   
====================================================                               
------------------- rank 0/4 ----------------------                                
executing (cycle=1, time=0.1)                      
bounds: (0.0, 17.0, 0.0, 64.9, 0.0, 55.9)          
velocity-magnitude-range: (0.0, 6.490000000000001) 
pressure-range: (1.0, 1.0)                        
-------------------------------------------------------------
                                                                                   
------------------- rank 2/4 ----------------------                                
executing (cycle=1, time=0.1)                      
bounds: (35.0, 52.0, 0.0, 64.9, 0.0, 55.9)         
velocity-magnitude-range: (0.0, 6.490000000000001)
pressure-range: (1.0, 1.0)                         
-------------------------------------------------------------
...

```

---

<div class="post-metadata">

### Author: ![Alexandre\_Minot](https://discourse.paraview.org/user_avatar/discourse.paraview.org/alexandre_minot/32/7132_2.png) [@Alexandre\_Minot](https://discourse.paraview.org/u/Alexandre_Minot)
#### Post date: [September 13, 2023, 8:06pm UTC](https://discourse.paraview.org/t/are-print-statements-disabled-on-non-zero-ranks-in-python-pipelines/12787/5 "2023-09-13T20:06:42Z")

</div>

I’m getting outputs for rank 0 only with your pipeline. Weird. Must be something on my end. I’ll keep digging, thanks!
