Return an array of evenly-spaced values
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | l | Low-bound for values |
||
real(kind=wp), | intent(in) | :: | h | High-bound for values |
||
integer, | intent(in), | optional | :: | N | Number of values (default 20) |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
function linspace(l,h,N) result(o)
!! Return an array of evenly-spaced values
real(wp),intent(in)::l
!! Low-bound for values
real(wp),intent(in)::h
!! High-bound for values
integer,intent(in),optional::N
!! Number of values (default 20)
real(wp),dimension(:),allocatable::o
integer::Nl,i
Nl = 20
if(present(N)) Nl = N
if(Nl==1) then
o = [ (l+h)/2.0_wp ]
else
o = [( (h-l)*real(i-1,wp)/real(Nl-1,wp)+l , i=1 , Nl )]
end if
end function linspace