LCOV - code coverage report
Current view: top level - vgen - pol_angle.f (source / functions) Hit Total Coverage
Test: combined.info Lines: 14 18 77.8 %
Date: 2019-09-08 04:53:50 Functions: 1 1 100.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------
       2             : ! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
       3             : ! This file is part of FLEUR and available as free software under the conditions
       4             : ! of the MIT license as expressed in the LICENSE file in more detail.
       5             : !--------------------------------------------------------------------------------
       6             : 
       7             :       MODULE m_polangle
       8             : c***********************************************************************
       9             : c calculates the polar angle theta and phi of a vector with components
      10             : c vx, vy and vz.
      11             : c Philipp Kurz 2000-02-08
      12             : c***********************************************************************
      13             :       CONTAINS
      14       66092 :       SUBROUTINE pol_angle(
      15             :      >                     vx,vy,vz,
      16             :      <                     theta,phi)
      17             : 
      18             :       USE m_constants, ONLY : pimach
      19             :       IMPLICIT NONE
      20             : 
      21             : C     .. Scalar Arguments ..
      22             :       REAL, INTENT    (IN) :: vx,vy,vz
      23             :       REAL, INTENT   (OUT) :: theta,phi
      24             : C     ..
      25             : C     .. Local Scalars ..
      26             :       REAL eps,vxyz,vxy,pi
      27             : C     ..
      28             : 
      29       66092 :       pi = pimach()
      30       66092 :       eps = 1.0e-8
      31             : 
      32       66092 :       vxy  = sqrt(vx**2 + vy**2)
      33       66092 :       vxyz = sqrt(vx**2 + vy**2 + vz**2)
      34             : 
      35       66092 :       IF ( (vxyz.LT.eps) .OR. (vxy.LT.eps) ) THEN
      36           0 :          theta = 0.0
      37           0 :          phi   = 0.0
      38             :       ELSE
      39             : c--->    due to rounding errors vxy/vxyz can become >1, if vz is very
      40             : c--->    small. therefore, make sure that vz is not to small.
      41       66092 :          IF (abs(vz).LT.eps) THEN
      42           0 :             theta = pi/2
      43             :          ELSE
      44       66092 :             theta = asin(vxy/vxyz)
      45             :          ENDIF
      46       66092 :          IF ( vz.LT.0 ) theta = pi - theta
      47             : 
      48             : c--->    due to rounding errors vy/vxy can become >1, if vx is very
      49             : c--->    small. therefore, make sure that vx is not to small.
      50       66092 :          IF (abs(vx).LT.eps) THEN
      51           0 :             phi = pi/2
      52             :          ELSE
      53       66092 :             phi   = asin(abs(vy)/vxy)
      54             :          ENDIF
      55       66092 :          IF ( vx.LT.0 ) phi = pi - phi
      56       66092 :          IF ( vy.LT.0 ) phi = -phi
      57             :       ENDIF
      58             : 
      59       66092 :       END SUBROUTINE pol_angle
      60             :       END MODULE m_polangle

Generated by: LCOV version 1.13