!@sum This file contains architecture specific code for SGI, IBM, Linux, DEC

      MODULE RANDOM 5
!@sum   RANDOM generates random numbers: 0<RANDom_nUmber<1
!@auth  Reto Ruedy
!@ver   1.0 (SGI,IBM,Linux,DEC)
!@cont  RANDU, RINIT, RFINAL
      IMPLICIT NONE
      INTEGER, SAVE :: IX            !@var IX     random number seed

      CONTAINS



      FUNCTION RANDU (X) 5
!@sum   RANDU calculates a random number based on the seed IX
!@calls RAN
      REAL*8 X                       !@var X      dummy variable
      REAL*4 RAN                     !@fun RAN    SGI intrinsic func.
      REAL*8 :: RANDU                !@var RANDU  random number
      RANDU=RAN(IX)
      RETURN
      END FUNCTION RANDU



      SUBROUTINE RINIT (INIT) 4
!@sum   RINIT sets the initial seed IX
      INTEGER, INTENT(IN)  :: INIT   !@var INIT   first random no. seed
      IX=INIT
      RETURN
      END SUBROUTINE RINIT


      SUBROUTINE RFINAL (IFINAL) 4
!@sum   RFINAL retrieves final seed value
      INTEGER, INTENT(OUT) :: IFINAL !@var IFINAL last random no. seed
      IFINAL=IX
      RETURN
      END SUBROUTINE RFINAL

      END MODULE RANDOM



      SUBROUTINE GETTIME (MNOW) 7
!@sum  GETTIME returns current CPU time
!@auth Gary Russell
!@ver  1.0 (Absoft version)
      IMPLICIT NONE
      INTEGER, INTENT(OUT) :: MNOW !@var MNOW current CPU time (.01 s)
      REAL*4 :: ETIME, TARR(2)       !@var ETIME intrinsic function
      MNOW = NINT(ETIME(TARR)*100.)
      RETURN
      END SUBROUTINE GETTIME



      SUBROUTINE exit_rc (code) 2
!@sum  exit_rc stops the run and sets a return code
!@auth Reto A Ruedy
!@ver  1.0 (SGI,IBM,Linux,DEC)
      IMPLICIT NONE
      INTEGER, INTENT(IN) :: code !@var code return code set by user

      call exit(code) !!! should check if it works for Absoft and DEC

      RETURN
      END SUBROUTINE exit_rc


      SUBROUTINE sys_flush (unit) 5
!@sum system call to flush corresponding I/O unit
!@auth I. Aleinov
!@ver  1.0 (SGI,IBM,Linux,DEC)
      IMPLICIT NONE
      INTEGER, INTENT(IN) :: unit !@var unit 

      call flush(unit) !!! should check if it works for Absoft and DEC

      RETURN
      END SUBROUTINE sys_flush


      SUBROUTINE sys_signal (sig, prog) 1
!@sum system call to "signal"
!@auth I. Aleinov
!@ver  1.0 (SGI,IBM,Linux,Dec) !! should check if works with DEC !!
      IMPLICIT NONE
!@var unit signal number to catch
      INTEGER, INTENT(IN) :: sig
!@var prog handler subroutine for given signal
      EXTERNAL prog

      call signal( sig, prog, -1 ) 

      RETURN
      END SUBROUTINE sys_signal