fplot 1.7.1
A Fortran library providing a convenient interface for plotting with Gnuplot.
Loading...
Searching...
No Matches
fplot_core_routines.f90
1! fplot_core_routines.f90
2
3submodule(fplot_core) fplot_core_routines
4contains
5! ------------------------------------------------------------------------------
6 pure module function linspace(start, finish, npts) result(x)
7 ! Arguments
8 real(real64), intent(in) :: start, finish
9 integer(int32), intent(in) :: npts
10 real(real64), allocatable, dimension(:) :: x
11
12 ! Local Variables
13 integer(int32) :: i
14 real(real64) :: dx
15
16 ! Process
17 allocate(x(npts))
18 dx = (finish - start) / (npts - 1.0d0)
19 x(1) = start
20 do i = 2, npts
21 x(i) = x(i-1) + dx
22 end do
23 end function
24
25! ------------------------------------------------------------------------------
26 pure module function logspace(start, finish, npts) result(x)
27 ! Arguments
28 real(real64), intent(in) :: start, finish
29 integer(int32), intent(in) :: npts
30 real(real64), allocatable, dimension(:) :: x
31
32 ! Local Variables
33 integer(int32) :: i
34 real(real64) :: dx, exponent
35
36 ! Process
37 allocate(x(npts))
38 dx = (finish - start) / (npts - 1.0d0)
39 exponent = start
40 do i = 1, npts
41 x(i) = 1.0d1**exponent
42 exponent = exponent + dx
43 end do
44 end function
45
46! ------------------------------------------------------------------------------
47 pure module function meshgrid(x, y) result(xy)
48 ! Arguments
49 real(real64), intent(in), dimension(:) :: x, y
50 real(real64), allocatable, dimension(:,:,:) :: xy
51
52 ! Local Variables
53 integer(int32) :: i, nx, ny
54
55 ! Process
56 nx = size(x)
57 ny = size(y)
58 allocate(xy(ny, nx, 2))
59 do i = 1, ny
60 xy(i,:,1) = x
61 end do
62 do i = 1, nx
63 xy(:,i,2) = y
64 end do
65 end function
66
67end submodule
fplot_core