function upminterval(start,stop,midpoint,p,q,type,base,mesh) result(array)
integer :: i,p,q,N,Nhalf
real(8) :: start,stop,midpoint,array(2*p*q+1)
real(8),optional :: base,mesh(2*P*Q+1)
real(8) :: base_
integer,optional :: type
integer :: type_
type_= 0 ;if(present(type))type_=type
base_= 2.d0 ;if(present(base))base_=base
N=2*p*q+1
Nhalf=p*q
if(type_==0)then
array(1:Nhalf+1) = upmspace(start,midpoint,p,q,Nhalf+1,base=base_)
array(N:Nhalf+2:-1)= upmspace(stop,midpoint,p,q,Nhalf,base=base_,iend=.false.)
else
array(Nhalf+1:1:-1) = upmspace(midpoint,start,p,q,Nhalf+1,base=base_)
array(Nhalf+2:N) = upmspace(midpoint,stop,p,q,Nhalf,base=base_,istart=.false.)
endif
if(present(mesh))then
do i=1,N-1
mesh(i)=(array(i+1)-array(i))
enddo
Mesh(N)=(array(N)-array(N-1))
endif
end function upminterval