I want to add this water only over the natural vegetation, and for a given gridcell, distribute the water across relevant patches according to the weight of each natural pft.

Here is the pseudocode:

do loop over the number of points with natural vegetation:

current_nat_veg_patch = filter_nat_veg(current_number_in_the_loop)

consumption_flux_for_current_nat_veg_patch = total_consumption_flux_for_current_gridcell * weight_of_current_nat_veg_patch_for_current_gridcell

end loop;

! Important: the weight_of_current_nat_veg_patch_for_current_gridcell when summed over all elements of the loop should be 1 (which means the denominator for this weight should be the total area of only natural vegetation patches and the numerator should be the area of current nat_veg patch).

I found that there is in clm_instur the wt_nat_patch array containing the information I need. But it seems that this array for a given gridcell contain the weights of all the natural vegetation pfts in their given order. While in my loop, there may be situation where some of the possible pfts will not exist in the current gridcell. So I am not sure what to use in as pft index [wt_nat_patch(grid_cell, pft)] so it matches my current patch type.