Implementation of "degree" (sind, cosd ...) intrinsic functions

Steve Kargl sgk@troutmask.apl.washington.edu
Mon Dec 18 22:20:00 GMT 2006


On Mon, Dec 18, 2006 at 10:57:13PM +0100, Schamil Wackenhut wrote:
> are there any patches for gfortran where the "degree" intrinsic
> functions, i.e. sind, cosd, tand, dtand etc, implemented?

I know of no one who plans to implement these intrinsics.

> I couldn't find anything except:
> "This intrinsic is not yet implemented. The name is, however, reserved as
> an intrinsic ..."

The gfortran documentation does not contain that phrase with respect
to the intrinsics that you list above.


Note it is straight forward to implement these via module procedures.
This is untested and hastily written.

module degrees

  implicit none

  private

  integer, parameter :: sp = kind(1.e0), dp = kind(1.d0)
  real(sp), parameter :: pio180_sp = 4 * atan(1.e0_sp) / 180.e0_sp
  real(dp), parameter :: pio180_dp = 4 * atan(1.e0_dp) / 180.e0_dp

  public sind, dsind

  interface sind
    module procedure  sind ! Single precision 
    module procedure dsind ! Double precision
  end interface
  
  contains

    function sind(x)
      implicit none
      real(sp) sind
      sind = sin(pi_sp * x)
    end function sind

    function dsind(x)
      implicit none
      real(dp) dsind
      dsind = sin(pi_dp * x)
    end function sind

end module degrees

-- 
Steve



More information about the Fortran mailing list