cartesian_to_spherical Subroutine

private subroutine cartesian_to_spherical(x, y, z, lon, lat, r)

Arguments

Type IntentOptional Attributes Name
real(kind=ESMF_KIND_R8), intent(in) :: x
real(kind=ESMF_KIND_R8), intent(in) :: y
real(kind=ESMF_KIND_R8), intent(in) :: z
real(kind=ESMF_KIND_R8), intent(out) :: lon
real(kind=ESMF_KIND_R8), intent(out) :: lat
real(kind=ESMF_KIND_R8), intent(out) :: r

Called by

proc~~cartesian_to_spherical~~CalledByGraph proc~cartesian_to_spherical cartesian_to_spherical proc~rot_3d rot_3d proc~rot_3d->proc~cartesian_to_spherical proc~rot_3d_new rot_3d_new proc~rot_3d_new->proc~cartesian_to_spherical proc~mirror_grid mirror_grid proc~mirror_grid->proc~rot_3d proc~mirror_grid_local mirror_grid_local proc~mirror_grid_local->proc~rot_3d proc~mirror_grid_local_new mirror_grid_local_new proc~mirror_grid_local_new->proc~rot_3d_new proc~esmf_utilcreatecscoords ESMF_UtilCreateCSCoords proc~esmf_utilcreatecscoords->proc~mirror_grid proc~esmf_utilcreatecscoordspar ESMF_UtilCreateCSCoordsPar proc~esmf_utilcreatecscoordspar->proc~mirror_grid_local proc~esmf_utilcreatecscoordspar->proc~mirror_grid_local_new proc~esmf_gridcreatecubedsphereireg ESMF_GridCreateCubedSphereIReg proc~esmf_gridcreatecubedsphereireg->proc~esmf_utilcreatecscoordspar proc~esmf_gridcreatecubedspherereg ESMF_GridCreateCubedSphereReg proc~esmf_gridcreatecubedspherereg->proc~esmf_utilcreatecscoordspar proc~esmf_meshcreatecubedsphere ESMF_MeshCreateCubedSphere proc~esmf_meshcreatecubedsphere->proc~esmf_utilcreatecscoords

Source Code

      subroutine cartesian_to_spherical(x, y, z, lon, lat, r) 
      real(ESMF_KIND_R8) , intent(IN)  :: x, y, z
      real(ESMF_KIND_R8) , intent(OUT) :: lon, lat, r

      r = SQRT(x*x + y*y + z*z)
      if ( (abs(x) + abs(y)) < 1.E-10 ) then       ! poles:
           lon = 0.
      else
           lon = ATAN2(y,x)    ! range: [-pi,pi]
      endif 

#ifdef RIGHT_HAND
      lat = asin(z/r)
#else
      lat = ACOS(z/r) - pi/2.
#endif

      end subroutine cartesian_to_spherical