subroutine COTH90 (x,cotan)

implicit none

INTEGER, PARAMETER :: iknd=SELECTED_INT_KIND(8)  ! nobody does this
INTEGER, PARAMETER :: DP=SELECTED_REAL_KIND(14)  ! this is double precision
INTEGER, PARAMETER :: SP=SELECTED_REAL_KIND(6)  ! this is single precision

real(DP) :: x,cotan,ex,emx

IF (x > 40.0) THEN
  cotan =  1.0
ELSE IF (x < (-40.0)) THEN
  cotan = -1.0
ELSE
  Ex   = EXP(x)
  Emx  = EXP(-x)
  cotan = (Ex + Emx) / (Ex - Emx)
ENDIF

RETURN
END subroutine coth90