@@ -19,7 +19,7 @@ module m_helper
1919
2020 implicit none
2121
22- private;
22+ private;
2323 public :: s_comp_n_from_prim, &
2424 s_comp_n_from_cons, &
2525 s_initialize_nonpoly, &
@@ -487,9 +487,12 @@ contains
487487 call s_mpi_abort
488488 end subroutine s_prohibit_abort
489489
490- !! This function generates the unassociated legendre poynomials with input
491- ! mode number and evaluates them at input x
490+ !> This function generates the unassociated legendre poynomials
491+ !! @param x is the input value
492+ !! @param l is the degree
493+ !! @return P is the unassociated legendre polynomial evaluated at x
492494 recursive function unassociated_legendre(x, l) result(P)
495+
493496 integer, intent(in) :: l
494497 real(kind(0d0)), intent(in) :: x
495498 real(kind(0d0)) :: P
@@ -504,50 +507,61 @@ contains
504507
505508 end function unassociated_legendre
506509
507- !! This function generated the spherical harmonic function valu, Y,
508- !based on inputs of x, phi, l and m
509-
510+ !> This function calculates the spherical harmonic function evaluated at x and phi
511+ !! @param x is the x coordinate
512+ !! @param phi is the phi coordinate
513+ !! @param l is the degree
514+ !! @param m is the order
515+ !! @return Y is the spherical harmonic function evaluated at x and phi
510516 recursive function spherical_harmonic_func(x, phi, l, m) result(Y)
517+
511518 integer, intent(in) :: l, m
512519 real(kind(0d0)), intent(in) :: x, phi
513520 real(kind(0d0)) :: Y, prefactor, pi
514521
515522 pi = acos(-1d0)
516- prefactor = sqrt((2*l + 1)/(4*pi)*factorial(l - m)/factorial(l + m));
523+ prefactor = sqrt((2*l + 1)/(4*pi)*factorial(l - m)/factorial(l + m));
517524 if (m == 0) then
518- Y = prefactor*associated_legendre(x, l, m);
525+ Y = prefactor*associated_legendre(x, l, m);
519526 elseif (m > 0) then
520- Y = (-1d0)**m*sqrt(2d0)*prefactor*associated_legendre(x, l, m)*cos(m*phi);
527+ Y = (-1d0)**m*sqrt(2d0)*prefactor*associated_legendre(x, l, m)*cos(m*phi);
521528 end if
522- end function spherical_harmonic_func
523529
524- !! This function generates the associated legendre polynomials evaluated
525- !at x with inputs l and m
530+ end function spherical_harmonic_func
526531
532+ !> This function generates the associated legendre polynomials evaluated
533+ !! at x with inputs l and m
534+ !! @param x is the input value
535+ !! @param l is the degree
536+ !! @param m is the order
537+ !! @return P is the associated legendre polynomial evaluated at x
527538 recursive function associated_legendre(x, l, m) result(P)
539+
528540 integer, intent(in) :: l, m
529541 real(kind(0d0)), intent(in) :: x
530542 real(kind(0d0)) :: P
531543
532544 if (m <= 0 .and. l <= 0) then
533- P = 1;
545+ P = 1;
534546 elseif (l == 1 .and. m <= 0) then
535- P = x;
547+ P = x;
536548 elseif (l == 1 .and. m == 1) then
537- P = -(1 - x**2)**(1/2);
549+ P = -(1 - x**2)**(1/2);
538550 elseif (m == l) then
539- P = (-1)**l*double_factorial(2*l - 1)*(1 - x**2)**(l/2);
551+ P = (-1)**l*double_factorial(2*l - 1)*(1 - x**2)**(l/2);
540552 elseif (m == l - 1) then
541- P = x*(2*l - 1)*associated_legendre(x, l - 1, l - 1);
553+ P = x*(2*l - 1)*associated_legendre(x, l - 1, l - 1);
542554 else
543- P = ((2*l - 1)*x*associated_legendre(x, l - 1, m) - (l + m - 1)*associated_legendre(x, l - 2, m))/(l - m);
555+ P = ((2*l - 1)*x*associated_legendre(x, l - 1, m) - (l + m - 1)*associated_legendre(x, l - 2, m))/(l - m);
544556 end if
545557
546558 end function associated_legendre
547559
548- !! This function calculates the double factorial value of an integer
549-
560+ !> This function calculates the double factorial value of an integer
561+ !! @param n is the input integer
562+ !! @return R is the double factorial value of n
550563 recursive function double_factorial(n) result(R)
564+
551565 integer, intent(in) :: n
552566 integer, parameter :: int64_kind = selected_int_kind(18) ! 18 bytes for 64-bit integer
553567 integer(kind=int64_kind) :: R
@@ -562,9 +576,11 @@ contains
562576
563577 end function double_factorial
564578
565- !! The following function calculates the factorial value of an integer
566-
579+ !> The following function calculates the factorial value of an integer
580+ !! @paaram n is the input integer
581+ !! @return R is the factorial value of n
567582 recursive function factorial(n) result(R)
583+
568584 integer, intent(in) :: n
569585 integer, parameter :: int64_kind = selected_int_kind(18) ! 18 bytes for 64-bit integer
570586 integer(kind=int64_kind) :: R
0 commit comments