Thank you for your help.
The error was simpler than that, it was actually a Fortran beginner mistake. I'll put the solution below, in case another Fortran beginner faces the same situation.
I was declaring K and KLOC as allocatable arrays.
INTEGER, ALLOCATABLE :: K(:), KLOC(:)
I was then assigning hard coded values to K (later they will be read from an external file):
IF (I.EQ.1) THEN
K = (/ 860, 861, 862, 863 /)
ELSEIF (I.EQ.2) THEN
K = (/ 850, 851, 852, 853 /)
ELSEIF (I.EQ.3) THEN
K = (/ 839, 840, 841, 842 /)
ENDIF
But I forgot to create storage for KLOC (with ALLOCATE) before calling GLOBAL_TO_LOCAL_POINT. Now, I do it like this:
ALLOCATE(KLOC(SIZE(K)))
! IN PARALLEL
IF(NCSIZE.GT.1) THEN
DO J = 1, SIZE(K)
KLOC(J) = GLOBAL_TO_LOCAL_POINT(K(J), MESH)
ENDDO
! IN SERIAL
ELSE
KLOC = K
ENDIF
The entire working FORTRAN file is attached.