MODULE constants_module

!
!HEADER
!
!Purpose:
!   To define named constants
!

IMPLICIT NONE

!Global constants:

 !------------------------------------------------------------------------------!
 ! Parameters to specify variable types
  INTEGER, PARAMETER :: int_8  = SELECTED_INT_KIND(2)  ! 8  bit signed integer
  INTEGER, PARAMETER :: uint_8 = SELECTED_INT_KIND(3)  ! 8  bit unsigned integer
  INTEGER, PARAMETER :: int16  = SELECTED_INT_KIND(4)  ! 16 bit signed integer
  INTEGER, PARAMETER :: int32  = SELECTED_INT_KIND(9)  ! 32 bit signed integer
  INTEGER, PARAMETER :: int64  = SELECTED_INT_KIND(10) ! 64 bit signed integer
  INTEGER, PARAMETER :: flt32  = SELECTED_REAL_KIND(r=37)  ! 32 bit signed float
  INTEGER, PARAMETER :: flt64  = SELECTED_REAL_KIND(r=200) ! 64 bit signed float

 !------------------------------------------------------------------------------!
 ! Parameters to specify fill values for variable types

  INTEGER(int_8),  PARAMETER :: FILL_INT8  = -127
  INTEGER(int_8),  PARAMETER :: FILL_UINT8  = 255
  INTEGER(int16), PARAMETER :: FILL_INT16 = -32767
  INTEGER(int32), PARAMETER :: FILL_INT32 = -32767
  INTEGER(int16), PARAMETER :: FILL_UINT16 = 65535
  REAL(flt32),    PARAMETER :: FILL_FLT32 = -2.**100
  REAL(flt64),    PARAMETER :: FILL_FLT64 = -2.**100

  REAL,           PARAMETER :: UNDEF      = -999.99

  !------------------------------------------------------------------------------!
  !Character lengths
  INTEGER, PARAMETER ::  STD_STRING       = 200
  INTEGER, PARAMETER ::  SWATHNAME_LENGTH = 64
  INTEGER, PARAMETER ::  NCORNERPOINTS    = 4
  !------------------------------------------------------------------------------!
  !
  LOGICAL, PARAMETER ::  DEBUG_MESSAGES = .true.
  LOGICAL, PARAMETER ::  TRUE = .true.
  LOGICAL, PARAMETER ::  FALSE = .false.
  
  ! smallest double precision value
  REAL(FLT64) :: TinyArgument
  REAL(FLT64), PARAMETER  :: TinyValue =  TINY( TinyArgument ) 

  ! largest double precision value
  REAL(FLT64) :: HugeArgument
  REAL(FLT64), PARAMETER  :: HugeValue =  HUGE( HugeArgument ) 

  !Code value for invalid data: 
  real(flt64)	:: ZeroReal
  REAL(FLT64), PARAMETER :: Code   = - HUGE( ZeroReal )

  !Mathematical constants
  REAL(FLT32), PARAMETER :: Pi_flt32  = 3.141592653589793_flt32
  REAL(FLT64), PARAMETER :: Pi_flt64  = 3.141592653589793_flt64

  REAL(FLT32), PARAMETER :: DegreesToRadians_flt32  = Pi_flt32/180_flt32
  REAL(FLT64), PARAMETER :: DegreesToRadians_flt64  = Pi_flt64/180_flt64

  REAL(FLT32), PARAMETER :: RadiansToDegrees_flt32  = 180_flt32/Pi_flt32
  REAL(FLT64), PARAMETER :: RadiansToDegrees_flt64  = 180_flt64/Pi_flt64

  real(flt64), parameter :: TAI_20040101UTC = 347068809.892542

! kind type necessary for hdf interfacing on 32/64 bits machine RuudDirksen 16november 2006
  INTEGER, PARAMETER :: hdf_kind_type= int32
!  INTEGER, PARAMETER :: hdf_kind_type= int64
    
END MODULE constants_module
