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
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
double precision, | intent(in) | :: | alpha | |||
double precision, | intent(in) | :: | beta | |||
double precision, | intent(inout), | DIMENSION(:) | :: | colatitudes |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | private | :: | i | ||||
integer, | private | :: | n | ||||
integer, | private | :: | size_col |
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