nXYtoVec Subroutine

public subroutine nXYtoVec(xVec, yVec, isCS, isPC, isDE, RC)

The routine nXYtoVec estimate the X/Y mid-point vectors based on as little data as possible.

History

  • 09 Jan 2016 - S. D. Eastham - Initial version

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(inout) :: xVec(:)
real(kind=sp), intent(inout) :: yVec(:)
logical, intent(in) :: isCS
logical, intent(in) :: isPC
logical, intent(in) :: isDE
integer, optional :: RC

Source Code

      Subroutine nXYtoVec(xVec,yVec,isCS,isPC,isDE,RC)
!
! !USES:
!
!      Use Precision_Mod, Only: f4

!
! !INPUT PARAMETERS:
!
! !OUTPUT PARAMETERS:
!
      Real(sp),Intent(InOut)               :: xVec(:), yVec(:)
      Logical,Intent(In)                   :: isCS, isPC, isDE
      Integer, Optional                    :: RC
!
!-----------------------------------------------------------------------
!
! !LOCAL VARIABLES:
!
      Integer     :: nX, nY
      Integer     :: I, RC_
      Real(sp)    :: fMin, fStride

      !=================================================================
      ! nXYtoVec starts here!
      !=================================================================

      ! Get sizes
      nX = Size(xVec)
      nY = Size(yVec)

      ! Assume success
      RC_ = 0

      ! Cubed sphere?
      If (isCS) Then
         If ((nX*6).ne.nY) Then
            RC_ = -1
         Else
            ! Simple system
            Do I = 1, nX
               xVec(I) = real(I)
            End Do
            Do I = 1, nY
               yVec(I) = real(I)
            End Do
         End If
      Else
         ! Longitude first
         fStride = 360.0/real(nX)
         If (isDE) Then
            fMin = (-180.0) - (fStride/2.0)
         Else
            fMin = (-180.0) - fStride
         End If
         Do I = 1, nX
            xVec(I) = fMin + (fStride * real(I))
         End Do
         ! Now latitude
         If (isPC) Then
            fStride = (180.0 / real(nY - 1))
            fMin = (-90.0) - fStride
         Else
            fStride = (180.0 / real(nY))
            fMin = (-90.0) - (fStride/2.0)
         End If
         Do I = 1, nY
            yVec(I) = fMin + (fStride * real(I))
         End Do
         If (isPC) Then
            yVec(1)  = (-90.0) + (fStride/4.0)
            yVec(nY) = ( 90.0) - (fStride/4.0)
         End If
      End If
      If (Present(RC)) RC = RC_

      End Subroutine nXYToVec