      function rmafun() !  bernd berg dec 12 2001. 
c function version of ranmar pseudo random number generator.
c marsaglia, zaman and tsang, stat. prob. 8 (1990) 35.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      common/raset1/u(97),c,cd,cm,i,j
c
      uni=u(i)-u(j)
      if(uni.lt.zero) uni=uni+one
      u(i)=uni           
      i=i-1              
      if(i.eq.0) i=97    
      j=j-1              
      if(j.eq.0) j=97   
      c=c-cd            
      if(c.lt.zero) c=c+cm
      uni=uni-c
      if(uni.lt.zero) uni=uni+one
      rmafun=uni
c
      return
      end
