compute_colatitudes_uniformly_in Subroutine

subroutine compute_colatitudes_uniformly_in(alpha, beta, colatitudes)

Uses

  • proc~~compute_colatitudes_uniformly_in~~UsesGraph proc~compute_colatitudes_uniformly_in compute_colatitudes_uniformly_in constants constants proc~compute_colatitudes_uniformly_in->constants module~utility utility proc~compute_colatitudes_uniformly_in->module~utility module~utility->constants matrix matrix module~utility->matrix

Compute the colatitudes according to a uniform distribution over a surface, between alpha and beta, with pi/2 < alpha < beta < pi. The values are stored in the array colatitudes See https://mathworld.wolfram.com/SpherePointPicking.html

FT 6.10.2021


Arguments

Type IntentOptional Attributes Name
double precision, intent(in) :: alpha
double precision, intent(in) :: beta
double precision, intent(inout), DIMENSION(:) :: colatitudes

Calls

proc~~compute_colatitudes_uniformly_in~~CallsGraph proc~compute_colatitudes_uniformly_in compute_colatitudes_uniformly_in proc~is_finite_number is_finite_number proc~compute_colatitudes_uniformly_in->proc~is_finite_number

Called by

proc~~compute_colatitudes_uniformly_in~~CalledByGraph proc~compute_colatitudes_uniformly_in compute_colatitudes_uniformly_in proc~place_particles_ellipsoidal_surfaces place_particles_ellipsoidal_surfaces proc~place_particles_ellipsoidal_surfaces->proc~compute_colatitudes_uniformly_in interface~place_particles_ellipsoidal_surfaces place_particles_ellipsoidal_surfaces interface~place_particles_ellipsoidal_surfaces->proc~place_particles_ellipsoidal_surfaces

Contents


Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: n
integer, private :: size_col

Source Code

  SUBROUTINE compute_colatitudes_uniformly_in( alpha, beta, colatitudes )

    !**************************************************
    !
    !# Compute the colatitudes according to a
    !  uniform distribution over a
    !  surface, between alpha and beta, with
    !  pi/2 < alpha < beta < pi.
    !  The values are stored in the array colatitudes
    !  See https://mathworld.wolfram.com/SpherePointPicking.html
    !
    !  FT 6.10.2021
    !
    !**************************************************

    USE constants,  ONLY: pi
    USE utility,    ONLY: one, two, four

    IMPLICIT NONE

    DOUBLE PRECISION, INTENT(IN):: alpha, beta
    DOUBLE PRECISION, DIMENSION(:), INTENT(INOUT):: colatitudes

    INTEGER:: n, size_col, i

    IF( alpha < pi/two .OR. alpha > pi )THEN
      PRINT *, "ERROR in SUBROUTINE compute_colatitudes_uniformly_in!", &
               " Argument alpha should lie in [pi/2,pi]. Stopping..."
      PRINT *
      STOP
    ENDIF
    IF( beta < pi/two .OR. beta > pi )THEN
      PRINT *, "** ERROR in SUBROUTINE compute_colatitudes_uniformly_in!", &
               " Argument beta should lie in [pi/2,pi]. Stopping..."
      PRINT *
      STOP
    ENDIF
    IF( alpha > beta )THEN
      PRINT *, "** ERROR in SUBROUTINE compute_colatitudes_uniformly_in!", &
               " Argument alpha should be less than argument beta. Stopping..."
      PRINT *
      STOP
    ENDIF

    size_col= SIZE(colatitudes)
    n= 4*size_col

    DO i= 1, size_col, 1

      colatitudes(i)= ACOS( two*( DBLE( i + 1 )*( COS(alpha) + one )/two &
            + ( ( COS(beta) + one )/two &
              - (DBLE(n + 1)/four + one)*( COS(alpha) + one )/two ) &
                      *four*DBLE(i)/DBLE(n + 1) ) - one )

      !PRINT *, "colatitudes(", i, ")", colatitudes(i)/pi, "pi"

      IF( .NOT.is_finite_number( colatitudes(i) ) )THEN
        PRINT *, "** ERROR in SUBROUTINE compute_colatitudes_uniformly_in! ", &
                 "colatitudes(", i, ") is a NaN! Stopping.."
        PRINT *, DBLE( i + 1 )*( COS(alpha) + one )/two
        PRINT *, ( COS(beta) + one )/two
        PRINT *, DBLE(size_col) + one
        PRINT *, DBLE(i)/DBLE(size_col)
        PRINT *
        STOP
      ENDIF

    ENDDO

  END SUBROUTINE compute_colatitudes_uniformly_in