# Solving Null Pointer Error in 3DEC FISH

**URL:** <https://forum.itascainternational.com/t/solving-null-pointer-error-in-3dec-fish/1631>\
**Category:** 3DEC\
**Tags:** fish\
**Created:** [August 13, 2024, 3:21am UTC](https://forum.itascainternational.com/t/solving-null-pointer-error-in-3dec-fish/1631 "2024-08-13T03:21:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahdi.S](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mahdi.S](https://forum.itascainternational.com/u/Mahdi.S)\
**Post date:** [August 13, 2024, 3:21am UTC](https://forum.itascainternational.com/t/solving-null-pointer-error-in-3dec-fish/1631/1 "2024-08-13T03:21:00Z")

</div>

Hi everyone,  
I have created a simple function to monitor damage in a UCS test in 3DEC.  
The function runs for several numerical steps but after that I get an abrupt error:  
“Unable to convert parameter type from Null Pointer to SubcontactThing Pointer.”  
This means that the isubc is ‘null’ in the subcontact list. However, it was not in the cycle before because I could see the damage percentage.

Do you know what would be the possible reason and how can I correct it?

> block group ‘Cohesion=Rock’  
> [subc\_list = block.subcontact.list(block.subcontact.isgroup(::block.subcontact.list,‘Rock’))]  
> [num\_subcontacts = list.size(subc\_list)]  
> def get\_damage  
> bonded\_subcontacts = 0  
> loop foreach isubc subc\_list  
> current\_state = block.subcontact.state(isubc)  
> if current\_state \<1  
> bonded\_subcontacts +=1  
> endif  
> endloop  
> damaged\_percentage = 100 - 100\*(bonded\_subcontacts/num\_subcontacts)  
> end  
> fish history get\_damage  
> fish history damaged\_percentage

Thanks

---

<div class="post-metadata">

**Author:** ![jhazzard](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jhazzard](https://forum.itascainternational.com/u/jhazzard)\
**Post date:** [August 13, 2024, 1:36pm UTC](https://forum.itascainternational.com/t/solving-null-pointer-error-in-3dec-fish/1631/2 "2024-08-13T13:36:48Z")

</div>

If you are running in large strain, it is possible for subcontacts to disappear. It is also possible for new subcontacts to form. So probably you want to recreate the list each time the function is called. i.e.

```
def get_damage
  bonded_subcontacts = 0
  subc_list = block.subcontact.list(block.subcontact.isgroup(::block.subcontact.list,‘Rock’))
  loop foreach isubc subc_list
  ...

```

---

<div class="post-metadata">

**Author:** ![Mahdi.S](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mahdi.S](https://forum.itascainternational.com/u/Mahdi.S)\
**Post date:** [August 14, 2024, 10:05pm UTC](https://forum.itascainternational.com/t/solving-null-pointer-error-in-3dec-fish/1631/3 "2024-08-14T22:05:55Z")

</div>

Many thanks, that is helpful.
