Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=8) | :: | start | ||||
real(kind=8) | :: | stop | ||||
integer | :: | num | ||||
logical, | optional | :: | istart | |||
logical, | optional | :: | iend | |||
real(kind=8), | optional | :: | mesh |
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