The segmentation fault happens when you do something incorrect that even the compiler didn't expect.
First you need to find out exactly where this is happening (the line of code with a problem), then find out why it is happening.
What I do when this kind of thing happens is put a numbered PRINT*, statement after every line to check which one is throwing the segmentation fault. Something like this:
PRINT*, 'I AM HERE 1'
DO I=1,NPOIN2
PRINT*, 'I AM HERE 2'
IF (PRIVE%ADR(1)%P%R(I).GT.0.1D0)THEN !search for points
PRINT*, 'I AM HERE 3'
! DO IPLAN = NPLAN-17,NPLAN-14
PRINT*, 'I AM HERE 4'
I3D = I+NPOIN2*(IPLAN-1)
PRINT*, 'I AM HERE 5'
IF (NPLAN==NPLAN-17) THEN
Also, I just noticed that in the piece of code you posted, the line
DO IPLAN = NPLAN-17,NPLAN-14 is commented. If it is also commented in your code, then your error might be coming from the extra END DO. I think this line should not be commented...
Best regards,
Phelype