!> \~japanese
!! \brief 基本的な数値演算を行う手続きを提供するモジュール
!! \~english
!! \brief This module provides some subroutines for performing basic numeric operations.
!! \~
!!
!! <br><br>
!! \b Copyright (C) GFD Dennou Club, 2011-2012. All rights reserved. <br>
!! \b license ?? <br>
!! \author Yuta Kawai
!!
module igmcore_math
  
  ! モジュール引用 ; Use statements
  !
  
  ! 種類型パラメタ
  ! Kind type parameter
  !
  use dc_types, only: DP   ! 倍精度実数型. Double precision. 
  
  ! 宣言文 ; Declaration statements
  !
  implicit none
  private

  ! 公開変数
  ! public variables
  !

  !> \~japanese 円周率.
  !! \~english Ratio of circle's circumference to its diameter.
  real(DP), parameter, public :: PI = 3.1415926535897932d0
  !real(DP), parameter, public :: PI = acos(-1.0d0)
 
  ! 公開手続き
  ! Public procedures
  !
  public :: toRadians, toDegrees

contains

! 
!> \~japanese
!! \brief 度で測った角度を, 対応するラジアンに変換する.
!!
!! @param[in] angdeg 度で測った角度.
!! @return    rad    ラジアンで測った angdeg の角度.
!!
!! \~english
!! \brief Converts an angle measured in degrees to an angle measured in radisns.
!!
!! @param[in] angdeg An angle, in degrees.
!! @return    rad    The measurement of the angle angdeg in radians.
!!
function toRadians(angdeg) result(rad)

  ! 宣言文 ; Declartion statement
  !
  real(DP), intent(in) :: angdeg
  real(DP) rad

  ! 実行文 ; Executable statement
  !
  rad = PI * angdeg / 180d0 
  
end function toRadians

! 
!> \~japanese
!! \brief ラジアンで測った角度を, 対応する度に変換する.
!!
!! @param[in] angrad ラジアンで測った角度.
!!
!! \~english
!! \brief Converts an angle measured in radians to an angle measured in degrees.
!!
!! @param[in] angrad An angle, in radians.
!! @return    deg    The measurement of the angle angdeg in degrees.
!!
function toDegrees(angrad) result(deg)

  ! 宣言文 ; Declaration statement
  !
  real(DP), intent(in) :: angrad
  real(DP) deg

  ! 実行文 ; Executable statment
  !
  deg = 180d0 * angrad / PI
  
end function toDegrees
 
end module igmcore_math
