module s2_vect_mod ! Uses use s2_types_mod use s2_error_mod ! Types public type s2_vect ! Variables integer, public, parameter :: S2_VECT_TYPE_CART = 0 integer, public, parameter :: S2_VECT_TYPE_S2 = 1 integer, private, parameter :: S2_VECT_CART_DIM = 3 ! Interfaces public interface s2_vect_init ! Subroutines and functions private function s2_vect_init_cart (x) result (vect) private function s2_vect_init_sph (r, theta, phi) result (vect) private function s2_vect_init_copy (orig) result (copy) public subroutine s2_vect_free (vect) public subroutine s2_vect_convert (vect, type) private subroutine s2_vect_compute_sph (vect) private subroutine s2_vect_compute_cart (vect) public function s2_vect_rad_to_arcmin (theta_rad) result (theta_arcmin) public function s2_vect_arcmin_to_rad (theta_arcmin) result (theta_rad) public function s2_vect_dot (a, b) result (dot) public subroutine s2_vect_rotate (vect, alpha, beta, gamma) private subroutine s2_vect_rotmat_direct (R, alpha, beta, gamma) private subroutine s2_vect_rotmat_point (R, alpha, beta, gamma) private subroutine s2_vect_rotmat_x_point (R, ang) private subroutine s2_vect_rotmat_y_point (R, ang) private subroutine s2_vect_rotmat_z_point (R, ang) private subroutine s2_vect_rotmat_axis (R, alpha, beta, gamma) private subroutine s2_vect_rotmat_x_axis (R, ang) private subroutine s2_vect_rotmat_y_axis (R, ang) private subroutine s2_vect_rotmat_z_axis (R, ang) public subroutine s2_vect_set_unit (vect) public function s2_vect_get_init (vect) result (init) public function s2_vect_get_x (vect) result (x) public function s2_vect_get_r (vect) result (r) public function s2_vect_get_theta (vect) result (theta) public function s2_vect_get_phi (vect) result (phi) public function s2_vect_get_type (vect) result (type) end module s2_vect_modProvide functionality to support and rotate vectors in R^3, represented in either cartesian or spherical coordinates.
Author: J. D. McEwen (mcewen@mrao.cam.ac.uk)
Version: 0.1 September 2004
public type s2_vect private logical :: init = .false. real (kind=s2_sp), dimension (S2_VECT_CART_DIM) :: x = 0.0e0 real (kind=s2_sp) :: r = 0.0e0 real (kind=s2_sp) :: theta = 0.0e0 real (kind=s2_sp) :: phi = 0.e0 integer :: type = S2_VECT_TYPE_CART end type s2_vect
integer, public, parameter :: S2_VECT_TYPE_CART = 0Cartesian coordinate status type.
integer, public, parameter :: S2_VECT_TYPE_S2 = 1Spherical coordinate status type.
integer, private, parameter :: S2_VECT_CART_DIM = 3Dimension of 3d cartesian vector.
public interface s2_vect_init module procedure s2_vect_init_cart module procedure s2_vect_init_sph module procedure s2_vect_init_copy end interface s2_vect_init
private function s2_vect_init_cart (x) result (vect) real (kind=s2_sp), intent(in), dimension (:) :: x type (s2_vect) :: vect ! Calls: s2_error end function s2_vect_init_cartInitialise a vector in cartesian coordinates.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_init_sph
private function s2_vect_init_sph (r, theta, phi) result (vect) real (kind=s2_sp), intent(in) :: r real (kind=s2_sp), intent(in) :: theta real (kind=s2_sp), intent(in) :: phi type (s2_vect) :: vect ! Calls: s2_error end function s2_vect_init_sphInitialise a vector in spherical coordinates.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_init_copy
private function s2_vect_init_copy (orig) result (copy) type (s2_vect), intent(in) :: orig type (s2_vect) :: copy ! Calls: s2_error end function s2_vect_init_copyInitialise a vector by making a copy of another vector.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_free
public subroutine s2_vect_free (vect) type (s2_vect), intent(inout) :: vect ! Calls: s2_error end subroutine s2_vect_freeReset vector values. (No memory to be freed.)
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_convert
public subroutine s2_vect_convert (vect, type) type (s2_vect), intent(inout) :: vect integer, intent(in) :: type ! Calls: s2_error, s2_vect_compute_cart, s2_vect_compute_sph end subroutine s2_vect_convertConvert a vector to the coordinates system specified by type. If the vector is already in the soordinate system then do nothing.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_compute_sph
private subroutine s2_vect_compute_sph (vect) type (s2_vect), intent(inout) :: vect ! Calls: s2_error end subroutine s2_vect_compute_sphCompute spherical coordinates of a vector from cartesian coordinates.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_compute_cart
private subroutine s2_vect_compute_cart (vect) type (s2_vect), intent(inout) :: vect ! Calls: s2_error end subroutine s2_vect_compute_cartCompute cartesian coordinates of a vector from spherical coordinates.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_rad_to_arcmin
public function s2_vect_rad_to_arcmin (theta_rad) result (theta_arcmin) real (kind=s2_sp), intent(in) :: theta_rad real (kind=s2_sp) :: theta_arcmin end function s2_vect_rad_to_arcminConvert an angle from radians to arcmins.
Variables:
Author: J. D. McEwen
Version: 0.1 November 2004
s2_vect_arcmin_to_rad
public function s2_vect_arcmin_to_rad (theta_arcmin) result (theta_rad) real (kind=s2_sp), intent(in) :: theta_arcmin real (kind=s2_sp) :: theta_rad end function s2_vect_arcmin_to_radConvert an angle from arcmins to radians.
Variables:
Author: J. D. McEwen
Version: 0.1 November 2004
s2_vect_dot
public function s2_vect_dot (a, b) result (dot) type (s2_vect), intent(inout) :: a type (s2_vect), intent(inout) :: b real (kind=s2_sp) :: dot ! Calls: s2_error end function s2_vect_dotCompute the dot product of two vectors.
Variables:
Author: J. D. McEwen
Version: 0.1 April 2006
s2_vect_rotate
public subroutine s2_vect_rotate (vect, alpha, beta, gamma) type (s2_vect), intent(inout) :: vect real (kind=s2_sp), intent(in) :: alpha real (kind=s2_sp), intent(in) :: beta real (kind=s2_sp), intent(in) :: gamma ! Calls: s2_error, s2_vect_convert, s2_vect_rotmat_point end subroutine s2_vect_rotateRotate a vector by the specified Euler angles.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_rotmat_direct
private subroutine s2_vect_rotmat_direct (R, alpha, beta, gamma) real (kind=s2_sp), intent(out), dimension (S2_VECT_CART_DIM, S2_VECT_CART_DIM) :: R real (kind=s2_sp), intent(in) :: alpha real (kind=s2_sp), intent(in) :: beta real (kind=s2_sp), intent(in) :: gamma end subroutine s2_vect_rotmat_directGenerate a rotation matrix to rotate a vector (in cartesian coordinates) by the speficied Euler angles. The rotation matrix is coded directly rather than multiplying rotation matrices that rotate about various axis.
Variables:
Author: D. J. Mortlock
Version: 0.1 September 2004
s2_vect_rotmat_point
private subroutine s2_vect_rotmat_point (R, alpha, beta, gamma) real (kind=s2_sp), intent(out), dimension (S2_VECT_CART_DIM, S2_VECT_CART_DIM) :: R real (kind=s2_sp), intent(in) :: alpha real (kind=s2_sp), intent(in) :: beta real (kind=s2_sp), intent(in) :: gamma ! Calls: s2_vect_rotmat_y_point, s2_vect_rotmat_z_point end subroutine s2_vect_rotmat_pointGenerate a rotation matrix to rotate a vector (in cartesian coordinates) by the specified Euler angles. The point is rotated in the right hand sense (axis rotated in left hand sense).
Notes:
Author: J. D. McEwen
Version: 0.1 April 2005
s2_vect_rotmat_x_point
private subroutine s2_vect_rotmat_x_point (R, ang) real (kind=s2_sp), intent(out), dimension (S2_VECT_CART_DIM, S2_VECT_CART_DIM) :: R real (kind=s2_sp), intent(in) :: ang end subroutine s2_vect_rotmat_x_pointGenerate a rotation matrix to rotate about the x axis by the specified angle. The point is rotated in the right hand sense (axis rotated in left hand sense).
Variables:
Author: J. D. McEwen
Version: 0.1 April 2005
s2_vect_rotmat_y_point
private subroutine s2_vect_rotmat_y_point (R, ang) real (kind=s2_sp), intent(out), dimension (S2_VECT_CART_DIM, S2_VECT_CART_DIM) :: R real (kind=s2_sp), intent(in) :: ang end subroutine s2_vect_rotmat_y_pointGenerate a rotation matrix to rotate about the y axis by the specified angle. The point is rotated in the right hand sense (axis rotated in left hand sense).
Variables:
Author: J. D. McEwen
Version: 0.1 April 2005
s2_vect_rotmat_z_point
private subroutine s2_vect_rotmat_z_point (R, ang) real (kind=s2_sp), intent(out), dimension (S2_VECT_CART_DIM, S2_VECT_CART_DIM) :: R real (kind=s2_sp), intent(in) :: ang end subroutine s2_vect_rotmat_z_pointGenerate a rotation matrix to rotate about the z axis by the specified angle. The point is rotated in the right hand sense (axis rotated in left hand sense).
Variables:
Author: J. D. McEwen
Version: 0.1 April 2005
s2_vect_rotmat_axis
private subroutine s2_vect_rotmat_axis (R, alpha, beta, gamma) real (kind=s2_sp), intent(out), dimension (S2_VECT_CART_DIM, S2_VECT_CART_DIM) :: R real (kind=s2_sp), intent(in) :: alpha real (kind=s2_sp), intent(in) :: beta real (kind=s2_sp), intent(in) :: gamma ! Calls: s2_vect_rotmat_y_axis, s2_vect_rotmat_z_axis end subroutine s2_vect_rotmat_axisGenerate a rotation matrix to rotate a vector (in cartesian coordinates) by the specified Euler angles. The axis is rotated in the right hand sense (point rotated in left hand sense).
Notes:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_rotmat_x_axis
private subroutine s2_vect_rotmat_x_axis (R, ang) real (kind=s2_sp), intent(out), dimension (S2_VECT_CART_DIM, S2_VECT_CART_DIM) :: R real (kind=s2_sp), intent(in) :: ang end subroutine s2_vect_rotmat_x_axisGenerate a rotation matrix to rotate about the x axis by the specified angle. The axis is rotated in the right hand sense (point rotated in left hand sense).
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_rotmat_y_axis
private subroutine s2_vect_rotmat_y_axis (R, ang) real (kind=s2_sp), intent(out), dimension (S2_VECT_CART_DIM, S2_VECT_CART_DIM) :: R real (kind=s2_sp), intent(in) :: ang end subroutine s2_vect_rotmat_y_axisGenerate a rotation matrix to rotate about the y axis by the specified angle. The axis is rotated in the right hand sense (point rotated in left hand sense).
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_rotmat_z_axis
private subroutine s2_vect_rotmat_z_axis (R, ang) real (kind=s2_sp), intent(out), dimension (S2_VECT_CART_DIM, S2_VECT_CART_DIM) :: R real (kind=s2_sp), intent(in) :: ang end subroutine s2_vect_rotmat_z_axisGenerate a rotation matrix to rotate about the z axis by the specified angle. The axis is rotated in the right hand sense (point rotated in left hand sense).
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_set_unit
public subroutine s2_vect_set_unit (vect) type (s2_vect), intent(inout) :: vect ! Calls: s2_vect_convert end subroutine s2_vect_set_unitScale the vector magnitude so it has unit length (orientation maintained).
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_get_init
public function s2_vect_get_init (vect) result (init) type (s2_vect), intent(in) :: vect logical :: init end function s2_vect_get_initGet init variable from the passed vect.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_get_x
public function s2_vect_get_x (vect) result (x) type (s2_vect), intent(inout) :: vect real (kind=s2_sp), dimension (S2_VECT_CART_DIM) :: x ! Calls: s2_error, s2_vect_convert end function s2_vect_get_xGet x variable from the passed vect.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_get_r
public function s2_vect_get_r (vect) result (r) type (s2_vect), intent(inout) :: vect real (kind=s2_sp) :: r ! Calls: s2_error, s2_vect_convert end function s2_vect_get_rGet r variable from the passed vect.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_get_theta
public function s2_vect_get_theta (vect) result (theta) type (s2_vect), intent(inout) :: vect real (kind=s2_sp) :: theta ! Calls: s2_error, s2_vect_convert end function s2_vect_get_thetaGet theta variable from the passed vect.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_get_phi
public function s2_vect_get_phi (vect) result (phi) type (s2_vect), intent(inout) :: vect real (kind=s2_sp) :: phi ! Calls: s2_error, s2_vect_convert end function s2_vect_get_phiGet phi variable from the passed vect.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004
s2_vect_get_type
public function s2_vect_get_type (vect) result (type) type (s2_vect), intent(in) :: vect integer :: type ! Calls: s2_error end function s2_vect_get_typeGet type variable from the passed vect.
Variables:
Author: J. D. McEwen
Version: 0.1 September 2004