ABI_XY_2_lonlat Subroutine

public subroutine ABI_XY_2_lonlat(x, y, lambda0, lon, lat, mask)

Arguments

Type IntentOptional Attributes Name
real(kind=REAL64), intent(in) :: x
real(kind=REAL64), intent(in) :: y
real(kind=REAL64), intent(in) :: lambda0
real(kind=REAL64), intent(out) :: lon
real(kind=REAL64), intent(out) :: lat
integer, intent(out), optional :: mask

Called by

proc~~abi_xy_2_lonlat~~CalledByGraph proc~abi_xy_2_lonlat ABI_XY_2_lonlat proc~test_conversion test_conversion proc~test_conversion->proc~abi_xy_2_lonlat

Source Code

  subroutine ABI_XY_2_lonlat (x, y, lambda0, lon, lat, mask)
    implicit none
    real(REAL64), intent(in) :: x, y
    real(REAL64), intent(in) :: lambda0
    real(REAL64), intent(out):: lon, lat
    integer, optional, intent(out):: mask
    real(REAL64) :: a0, b0, c0, rs, Sx, Sy, Sz, t
    real(REAL64) :: a, b, H
    real(REAL64) :: delta

    a=r_eq; b=r_pol; H=H_sat

    if (present(mask)) mask=0
    a0 =  sin(x)*sin(x) + cos(x)*cos(x)*( cos(y)*cos(y) + (a/b)*(a/b)*sin(y)*sin(y) )
    b0 = -2.d0 * H * cos(x) * cos(y)
    c0 =  H*H - a*a
    delta = b0*b0 - 4.d0*a0*c0
    if (delta < 0.d0) then
       lon = MAPL_UNDEF
       lat = MAPL_UNDEF
       if (present(mask)) mask=0
       return
    end if
    rs =  ( -b0 - sqrt(b0*b0 - 4.d0*a0*c0) ) / (2.d0*a0)
    Sx =  rs * cos(x) * cos(y)
    Sy = -rs * sin(x)
    Sz =  rs * cos(x) * sin(y)
    lon = lambda0 - atan (Sy/(H - Sx))
    lat = atan ( (a/b)**2.d0 * Sz / sqrt ((H -Sx)**2.d0 + Sy*Sy) )

    t = H*(H-Sx) - ( Sy*Sy + (a/b)**2.d0 *Sz*Sz )
    if (t < 0) then
       lon = MAPL_UNDEF
       lat = MAPL_UNDEF
       if (present(mask)) mask=0
    else
       if (present(mask)) mask=1
    end if

  end subroutine ABI_XY_2_lonlat