subroutine init_vectors_spherical() integer :: j double precision :: LOS_psi double precision :: vec_car(1:3),vec_z(1:3),vec_temp1(1:3),& vec_temp2(1:3) double precision :: vec_LOS_sph(1:3),vec_xI1_sph(1:3),vec_xI2_sph(1:3) ! antiparallel to LOS in spherical vec_LOS(1)=1.d0 vec_LOS(2)=dpi*LOS_theta/180.d0 vec_LOS(3)=dpi*LOS_phi/180.d0 ! LOS in cartesian call spherical_to_cartesian(vec_LOS,vec_car) vec_LOS=-vec_car ! theta=0 in cartesian vec_z(:)=zero vec_z(3)=1.d0 ! x direction for image if (LOS_theta==zero) then vec_temp1(1)=1.d0 vec_temp1(2)=dpi/2.d0 vec_temp1(3)=dpi*LOS_phi/180.d0 call spherical_to_cartesian(vec_temp1,vec_car) vec_temp1=-vec_car call cross_product_loc(vec_temp1,vec_z,vec_xI1) else call cross_product_loc(vec_LOS,vec_z,vec_xI1) endif ! y direction for image call cross_product_loc(vec_xI1,vec_LOS,vec_xI2) ! rotate the image vec_temp1=vec_xI1/sqrt(vec_xI1(1)**2+vec_xI1(2)**2+vec_xI1(3)**2) vec_temp2=vec_xI2/sqrt(vec_xI2(1)**2+vec_xI2(2)**2+vec_xI2(3)**2) LOS_psi=dpi*image_rotate/180.d0 vec_xI1=vec_temp1*cos(LOS_psi)-vec_temp2*sin(LOS_psi) vec_xI2=vec_temp2*cos(LOS_psi)+vec_temp1*sin(LOS_psi) do j=1,3 if (abs(vec_LOS(j))<smalldouble) vec_LOS(j)=zero if (abs(vec_xI1(j))<smalldouble) vec_xI1(j)=zero if (abs(vec_xI2(j))<smalldouble) vec_xI2(j)=zero enddo call cartesian_to_spherical(vec_LOS,vec_LOS_sph) call cartesian_to_spherical(vec_xI1,vec_xI1_sph) call cartesian_to_spherical(vec_xI2,vec_xI2_sph) vec_LOS_sph(2:3)=vec_LOS_sph(2:3)*180.d0/dpi vec_xI1_sph(2:3)=vec_xI1_sph(2:3)*180.d0/dpi vec_xI2_sph(2:3)=vec_xI2_sph(2:3)*180.d0/dpi if (mype==0) write(*,'(a,f3.1,f6.1,f6.1,a)') ' LOS vector (spherial): [',& vec_LOS_sph(1),vec_LOS_sph(2),vec_LOS_sph(3),']' if (mype==0) write(*,'(a,f3.1,f6.1,f6.1,a)') ' xI1 vector (spherial): [',& vec_xI1_sph(1),vec_xI1_sph(2),vec_xI1_sph(3),']' if (mype==0) write(*,'(a,f3.1,f6.1,f6.1,a)') ' xI2 vector (spherial): [',& vec_xI2_sph(1),vec_xI2_sph(2),vec_xI2_sph(3),']' end subroutine init_vectors_spherical