linspace Function

public function linspace(start, stop, num, istart, iend, mesh) result(array)

Arguments

Type IntentOptional Attributes Name
real(kind=8) :: start
real(kind=8) :: stop
integer :: num
logical, optional :: istart
logical, optional :: iend
real(kind=8), optional :: mesh

Return Value real(kind=8), (num)


Called by

proc~~linspace~2~~CalledByGraph proc~linspace~2 linspace proc~fft_farray fft_farray proc~fft_farray->proc~linspace~2 proc~fft_tarray fft_tarray proc~fft_tarray->proc~linspace~2 proc~logspace logspace proc~logspace->proc~linspace~2

Source Code

  function linspace(start,stop,num,istart,iend,mesh) result(array)
    real(8)          :: start,stop,step,array(num)
    integer          :: num,i
    logical,optional :: istart,iend
    logical          :: startpoint_,endpoint_
    real(8),optional :: mesh
    !
    if(num<0)stop "linspace: N<0, abort."
    !
    startpoint_=.true.;if(present(istart))startpoint_=istart
    endpoint_=.true.;if(present(iend))endpoint_=iend
    !
    if(startpoint_.AND.endpoint_)then
       if(num<2)stop "linspace: N<2 with both start and end points"
       step = (stop-start)/(dble(num)-1d0)
       forall(i=1:num)array(i)=start + (dble(i)-1d0)*step
    elseif(startpoint_.AND.(.not.endpoint_))then
       step = (stop-start)/dble(num)
       forall(i=1:num)array(i)=start + (dble(i)-1d0)*step
    elseif(.not.startpoint_.AND.endpoint_)then
       step = (stop-start)/dble(num)
       forall(i=1:num)array(i)=start + dble(i)*step
    else
       step = (stop-start)/(dble(num)+1d0)
       forall(i=1:num)array(i)=start + dble(i)*step
    endif
    if(present(mesh))mesh=step
  end function linspace