gjp_quad.f90
Go to the documentation of this file.
1 program gjp_quad
2 
4 use gjp_types, only: dp
5 implicit none
6 
7 integer :: n_points
8 real(dp) :: alpha, beta
9 real(dp), dimension(:), allocatable :: x, w
10 character(len=128) :: arg
11 character(len=:), allocatable :: method
12 integer :: idx
13 
14 if (command_argument_count() /= 4) then
15  print*,"Usage: ./gjp_quad <n_points> <alpha> <beta> <method>"
16  print*," n_points: Number of quadrature points (integer)"
17  print*," alpha: Parameter alpha for Gauss-Jacobi quadrature (must be > -1)"
18  print*," beta: Parameter beta for Gauss-Jacobi quadrature (must be > -1)"
19  print*," method: Method to use for computation (supported: 'rec', 'gw', 'algo665')"
20  print*," "
21  print*,"For Gauss-Jacobi quadrature, the weight function is (b-x)^alpha*(x-a)^beta."
22  error stop "Must supply 4 arguments"
23 end if
24 call get_command_argument(1, arg)
25 read (arg, '(i4)') n_points
26 allocate (x(n_points), w(n_points))
27 
28 call get_command_argument(2, arg)
29 if (index(arg, '.') == 0) then
30  print*,"alpha must include a decimal point"
31  error stop
32 end if
33 read (arg, *) alpha
34 
35 call get_command_argument(3, arg)
36 if (index(arg, '.') == 0) then
37  print*,"beta must include a decimal point"
38  error stop
39 end if
40 read (arg, *) beta
41 
42 call get_command_argument(4, arg)
43 method = trim(arg)
44 
45 call gauss_jacobi(n_points, alpha, beta, x, w, method)
46 
47 do idx = 1, n_points
48  print '(1X, A, 1P, E24.17, 2X, A, 1P, E23.17)', 'Root: ', x(idx), 'Weight: ', w(idx)
49 end do
50 
51 deallocate (x, w)
52 
53 end program gjp_quad
program gjp_quad
Definition: gjp_quad.f90:1
Overall driver for Gauss-Jacobi quadrature.
subroutine gauss_jacobi(npts, alpha, beta, x, wts, method)
Compute the Gauss-Jacobi quadrature nodes and weights.
Module for defining types and precision levels for Gauss-Jacobi Polynomial (GJP) calculations.
Definition: gjp_types.f90:33
integer, parameter, public dp
Define various kinds for real numbers.
Definition: gjp_types.f90:39
Code