# Programmable Filter: IndexError: out of bounds: only for mpiexec

**URL:** https://discourse.paraview.org/t/programmable-filter-indexerror-out-of-bounds-only-for-mpiexec/11082
**Category:** ParaView Support
**Created:** [December 30, 2022, 12:20am UTC](https://discourse.paraview.org/t/programmable-filter-indexerror-out-of-bounds-only-for-mpiexec/11082 "2022-12-30T00:20:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Saang\_Bum\_Kim](https://discourse.paraview.org/user_avatar/discourse.paraview.org/saang_bum_kim/32/10555_2.png) [@Saang\_Bum\_Kim](https://discourse.paraview.org/u/Saang_Bum_Kim)
#### Post date: [December 30, 2022, 12:20am UTC](https://discourse.paraview.org/t/programmable-filter-indexerror-out-of-bounds-only-for-mpiexec/11082/1 "2022-12-30T00:20:16Z")

</div>

I am using Paraview 5.11.0 on Ubuntu 22.04.1 LTS.

I’m trying to add a new field data from a text file using a programmable filter.  
My ‘Programmable Filter (below)’ shows the following errors when it runs under parallel using ‘mpiexec -np 4 pvserver &’ while it runs well if disconnected to the server.

* * *

Traceback (most recent call last):  
File “”, line 22, in   
File “”, line 69, in RequestData  
IndexError: index 6495 is out of bounds for axis 0 with size 6495  
(‘g\_x’,)

“”"  
import numpy as np  
kk = 0  
s\_file\_data = f’/home/sbkim/Work/urban/case6/results/gx\_z00175\_a{int(kk\*10):04d}.csv’

data = np.genfromtxt( s\_file\_data,  
dtype=None, names=True, delimiter=‘,’, autostrip=True)

input0 = inputs[0]  
u = input0.PointData[“U”]  
g\_x = u/2

n\_x0 = g\_x.GetSize()  
n\_x = len(data[‘g\_x’])  
for i in range(n\_x):  
g\_x.Arrays[0][i] = [data[‘g\_x’][i],0,0]

output.PointData.append(g\_x, “g\_x”)  
output.PointData.append(u\_max, “u\_max”)  
“”"

---

<div class="post-metadata">

### Author: ![jfausty](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jfausty/32/9405_2.png) [@jfausty](https://discourse.paraview.org/u/jfausty)
#### Post date: [December 30, 2022, 8:38am UTC](https://discourse.paraview.org/t/programmable-filter-indexerror-out-of-bounds-only-for-mpiexec/11082/2 "2022-12-30T08:38:06Z")

</div>

Hi @Saang_Bum_Kim,

Welcome to the ParaView discourse and thanks for posting!

It looks to me like your input data to the programmable filter is distributed when run in parallel and the number of components of the array in your text file is the total number of components.

Allow me to elaborate:

- When **not** running in parallel: your data set exists as a whole and the `U` array has as many values as points in your total data set. When you read from your csv file, your `g_x` data is the correct size also having one element per point
- When running in parallel: your input data set is most likely distributed on your 4 running processes and, therefore, so is the `U` array (n\_{x0} \simeq n\_x/4 on average). When you read your csv file, you read it on all 4 processes at the same time and so there are 4 copies of your `data['g_x']` numpy array, one on each process. When you try to add then into your data set, your get an out of bounds error because there are less components locally on at least one of your processes than there are globally.

If you want to run your filter and do parallel IO, you will most likely need to take this into account in your process and write a parallel algorithm.

I hope that helps!

Best regards,
