AF2A Subroutine

public subroutine AF2A(s, ideg, iamin, asec, rad, j)

Convert degrees, arcminutes, arcseconds to radians.

Status: support routine.

Notes

  1. If the s argument is a string, only the leftmost character is used and no warning status is provided.

  2. The result is computed even if any of the range checks fail.

  3. Negative IDEG, IAMIN and/or ASEC produce a warning status, but the absolute value is used in the conversion.

  4. If there are multiple errors, the status value reflects only the first, the smallest taking precedence.

History

  • IAU SOFA revision: 2013 December 2

Arguments

TypeIntentOptionalAttributesName
character(len=1), intent(in) :: s

sign: '-' = negative, otherwise positive

integer, intent(in) :: ideg

degrees

integer, intent(in) :: iamin

arcminutes

real(kind=wp), intent(in) :: asec

arcseconds

real(kind=wp), intent(out) :: rad

angle in radians

integer, intent(out) :: j

0 = OK 1 = IDEG outside range 0-359 2 = IAMIN outside range 0-59 3 = ASEC outside range 0-59.999...


Contents

Source Code


Source Code

    subroutine AF2A ( s, ideg, iamin, asec, rad, j )

    implicit none

    character(len=1),intent(in) :: s !! sign:  '-' = negative, otherwise positive
    integer,intent(in) :: ideg !! degrees
    integer,intent(in) :: iamin !! arcminutes
    real(wp),intent(in) :: asec !! arcseconds
    real(wp),intent(out) :: rad !! angle in radians
    integer,intent(out) :: j !! status:
                             !! 0 = OK
                             !! 1 = IDEG outside range 0-359
                             !! 2 = IAMIN outside range 0-59
                             !! 3 = ASEC outside range 0-59.999...

    real(wp) :: w

    !  Preset the status.
    j = 0

    !  Validate arcseconds, arcminutes, degrees.
    if ( asec<0.0_wp .or. asec>=60.0_wp ) j=3
    if ( iamin<0 .or. iamin>59 ) j=2
    if ( ideg<0 .or. ideg>359 ) j=1

    !  Compute the angle.
    w = ( 60.0_wp * ( 60.0_wp * real( abs(ideg), wp ) + &
                          real( abs(iamin), wp ) ) + &
                          abs(asec) ) * das2r

    !  Apply the sign.
    if ( s == '-' ) w = -w

    !  Return the result.
    rad = w

    end subroutine AF2A