Hello Louise!
I don't know if it is what you ask for but in case you want to know how to compute the depth of any 3D node you can instead loop on the 2D nodes first (bottom plane only, NPOIN2) and then on the vertical planes (NPLAN):
DO I2D=1,NPOIN2
DO IPLAN=1,NPLAN
I3D = I2D+NPOIN2*(IPLAN-1)
DEPTH = MAX(1.D-12,Z(I2D+NPOIN2*(NPLAN-1)) - Z(I3D))
!continue here
ENDDO
ENDDO
The value for I2D+NPOIN2*(NPLAN-1) is the surface node corresponding to the inital 2D node (bottom plane). So Z(I2D+NPOIN2*(NPLAN-1)) - Z(I3D) will give you the distance between the surface and the nodes located on the planes below along a same vertical. In can be useful to take the max of DEPTH and a very small value in order to avoid nil or any negative depth values which could trigger some mistakes if using a LOG law in your code...
Good luck!
Best regards
PL