	pro split_array,x,index, Number=Number, $
first_subscript=first_subscript, last_subscript=last_subscript

;	Splits a given index array after missing values.

a=x-x(0)
n_e=n_elements(a)
a_last=a(n_e-1)
normal_length=a_last-a(0)+1

index=0L

	if normal_length eq n_e then begin
index=[0,n_e-1]
N_el_index=2
goto,exit
	endif

b=a
b0=b(0)
	REPEAT BEGIN

n_e=n_elements(b)

normal_length=b(n_e-1)+1
current_index=where(b eq indgen(normal_length))
ind=[current_index(0),current_index(n_elements(current_index)-1)]

if n_elements(index) eq 1 then index=ind+b0 else index=[index,ind+b0]

	if ind(1) eq a_last then goto,exit

b=b(ind(1)+1 < (n_e-1):*)
b0=b(0)+b0
b=b-b(0)

N_el_index=n_elements(index)

	ENDREP UNTIL index(N_el_index-1) eq a_last

exit:

index=index+x(0)

Number=N_el_index/2

Arg=indgen(Number)*2

first_subscript=index(Arg)
last_subscript=index(Arg+1)


end
