# Using SaveData multiple times, in parallel with pvbatch

**URL:** https://discourse.paraview.org/t/using-savedata-multiple-times-in-parallel-with-pvbatch/5935
**Category:** ParaView Support
**Created:** [November 30, 2020, 12:33pm UTC](https://discourse.paraview.org/t/using-savedata-multiple-times-in-parallel-with-pvbatch/5935 "2020-11-30T12:33:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mjn1368](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@mjn1368](https://discourse.paraview.org/u/mjn1368)
#### Post date: [November 30, 2020, 12:33pm UTC](https://discourse.paraview.org/t/using-savedata-multiple-times-in-parallel-with-pvbatch/5935/1 "2020-11-30T12:33:38Z")

</div>

Hello everyone,

I try to use pvbatch to optimize my post-processing. To be short, I have a dataset that contains the coordinates of many points. I have created many “subdomains” i.e. blocks, for example here 125 blocks, by using “extractCellsByRegion” filter, and I count the number of points existing in each “extractCellsByRegion”.

To store the data in each timestep, I want to use “SaveData” for each “extractCellsByRegion”, in which any MPI rank takes the responsibility of writing the data for each block. I realized that only one rank performs the “SaveData” job, and the rest of the ranks do nothing for their SaveData.

How can I say to pvbatch to run in parallel and get output from other ranks?

Many thanks in advance for your help.  
Regards,  
Mohammad

* * *

Pseudo code: is written in the simplest form for only two ranks:

from paraview.simple import \*  
import os, sys  
from mpi4py import MPI  
comm = MPI.COMM\_WORLD  
size = comm.Get\_size()  
rank = comm.Get\_rank()  
…  
if rank == 0:  
SaveData(’/home/user/Desktop/prj\_1/c’+str(i+1)+’.csv’, proxy=extractCellsByRegion1, WriteTimeSteps=100,  
Filenamesuffix=’_%d’,  
ChooseArraysToWrite=1,  
PointDataArrays=[],  
CellDataArrays=[],  
FieldDataArrays=[],  
VertexDataArrays=[],  
EdgeDataArrays=[],  
RowDataArrays=[],  
Precision=5,  
UseScientificNotation=0,  
FieldAssociation=‘Point Data’,  
AddMetaData=1,  
AddTime=0)  
elif rank == 1:  
SaveData(’/home/user/Desktop/prj\_1/d’+str(i+1)+’.csv’, proxy=extractCellsByRegion2, WriteTimeSteps=100,  
Filenamesuffix=’_%d’,  
…  
elif rank …  
…

P.S. I included the following piece of code in the python script and it outputs correctly.  
if rank == 0:  
print(“First rank”)  
elif rank == 1:  
print (“Second rank”)  
elif rank == 2:  
print (“Third rank”)  
…
