Fortran toolkit
gridfunction grid(maxv,minv,n,s) result(v)
implicit none
real(kind=8) :: v(n) ! output: generated grid
real(kind=8) :: maxv ! input: upper-bound of x
real(kind=8) :: minv ! input: lower-bound of x
integer :: n ! input: number of points in the grid
real(kind=8) , optional :: s ! input: (optional) curvatura parameter
This function creates a grid of n points between minv and maxv with a curvature of s, $v(i) = \texttt{minv} + \left(\frac{i-1}{n-1}\right)^s(\texttt{maxv}-\texttt{minv})$:
s=1 or missing: linear grid (default)s>1: more grid points around minvs<1: more grid points around maxvThe grid requires n $\geq 2$ and s $>0$; otherwise the function prints an error message and returns a vector of zeros.
Internal dependencies: error
Example
! create a linear grid with 100 points between 0 and 10
vector = grid( 10.d0 , 0.0d0 , 100 )
! create a quadratic grid with 500 points between -1 and 1
vector = grid( 1.d0 , -1.0d0 , 500 , 2.0d0 )