rot_3d_new Subroutine

private subroutine rot_3d_new(axis, x1in, y1in, z1in, sa, ca, x2out, y2out, z2out, convert)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: axis
real(kind=ESMF_KIND_R8), intent(in) :: x1in
real(kind=ESMF_KIND_R8), intent(in) :: y1in
real(kind=ESMF_KIND_R8), intent(in) :: z1in
real(kind=ESMF_KIND_R8), intent(in) :: sa
real(kind=ESMF_KIND_R8), intent(in) :: ca
real(kind=ESMF_KIND_R8), intent(out) :: x2out
real(kind=ESMF_KIND_R8), intent(out) :: y2out
real(kind=ESMF_KIND_R8), intent(out) :: z2out
integer, intent(in), optional :: convert

Calls

proc~~rot_3d_new~~CallsGraph proc~rot_3d_new rot_3d_new proc~cartesian_to_spherical cartesian_to_spherical proc~rot_3d_new->proc~cartesian_to_spherical proc~spherical_to_cartesian spherical_to_cartesian proc~rot_3d_new->proc~spherical_to_cartesian

Called by

proc~~rot_3d_new~~CalledByGraph proc~rot_3d_new rot_3d_new proc~mirror_grid_local_new mirror_grid_local_new proc~mirror_grid_local_new->proc~rot_3d_new proc~esmf_utilcreatecscoordspar ESMF_UtilCreateCSCoordsPar 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 interface~esmf_gridcreatecubedsphere ESMF_GridCreateCubedSphere interface~esmf_gridcreatecubedsphere->proc~esmf_gridcreatecubedsphereireg interface~esmf_gridcreatecubedsphere->proc~esmf_gridcreatecubedspherereg

Source Code

  subroutine rot_3d_new(axis, x1in, y1in, z1in, sa, ca, x2out, y2out, z2out, convert)

     integer, intent(IN) :: axis         ! axis of rotation 1=x, 2=y, 3=z
     real(ESMF_KIND_R8) , intent(IN)    :: x1in, y1in, z1in
     real(ESMF_KIND_R8) , intent(IN)    :: sa, ca   ! sin and cos of angle to rotate in radians
     real(ESMF_KIND_R8) , intent(OUT)   :: x2out, y2out, z2out
     integer, intent(IN), optional :: convert ! if present convert input point
     ! from spherical to cartesian, rotate, 
     ! and convert back

     real(ESMF_KIND_R8)  :: x1,y1,z1, x2,y2,z2

     if ( present(convert) ) then
        call spherical_to_cartesian(x1in, y1in, z1in, x1, y1, z1)
     else
        x1=x1in
        y1=y1in
        z1=z1in
     endif


     SELECT CASE(axis)

     CASE(1)
        x2 =  x1
        y2 =  ca*y1 + sa*z1
        z2 = -sa*y1 + ca*z1
     CASE(2)
        x2 = ca*x1 - sa*z1
        y2 = y1
        z2 = sa*x1 + ca*z1
     CASE(3)
        x2 =  ca*x1 + sa*y1
        y2 = -sa*x1 + ca*y1
        z2 = z1
     CASE DEFAULT
        write(*,*) "Invalid axis: must be 1 for X, 2 for Y, 3 for Z."

     END SELECT

     if ( present(convert) ) then
        call cartesian_to_spherical(x2, y2, z2, x2out, y2out, z2out)
     else
        x2out=x2
        y2out=y2
        z2out=z2
     endif

  end subroutine rot_3d_new