volume of element

I have been able to get the volume of single element (both in serial and parallel mode with 8 cores.) I used the code as mentioned in the above link. The following code works very well both in series and parallel. I found that wDetJ is 1/8 th of volume of single element. To find the volume of an element, I needed to multiply by 8 (most probably there are 8 gauss points).
Real* wghtDetJac ; Real wDetJ ; Integer elem ; ... wghtDetJac = udfGetElmWDetJ( udfHd ) ; for ( elem = 0 ; elem < nItems ; elem++ ) { wDetJ = wghtDetJac[elem] ; ... }
I have a simple geometry as below. It is 1m x 1m x 1m with (10 x 10 x 1) elements:-
Now, the issue I am having is that I have marker (0-fluid; 1-solid) for each element in the domain above. I want to run a code to calculate the volume of only fluid (i.e marker with 0). I wrote a code that does this. It works very well in series (only 1 core). But, I found when I try to run the same code in parallel (multi cores with 8 cores), wDetJ is correct. But, the total volume (vol) corresponding to 0 marker is not correct in parallel mode--it is correct only in series mode. Would you please help me figure out how to evaluate the volume for the 0 marker only in parallel mode? I figured out that UDF is called several times even in each timestep due to parallelization. The code I ran is: