      program pmar ! Bernd Berg, Aug 25 2007.
C
C IMPLEMENTATION OF MARSAGLIA'S RANDOM NUMBER GENERATOR.
C (MARSAGLIA, ZAMAN AND TSANG, STAT.& PROB. LETTERS 8 (1990) 35.)
C - The seed parameters have to be  integers, -1801 <= iseed1 <= 29527,
C   -9373 <= iseed2 <= 20708. Distinct seeds give independent sequences.
C - When ranmar.d does not exist, iseed1 and iseed2 are used.
C - When ranmar.d exists: Continuation using the seeds saved by rmasave. 
C   Compare the additional number of the  previous run with the first 
C   of the continuation!
C
      include '../../ForLib/implicit.sta'
      parameter(iuo=6,iud=10,iseed1=1,iseed2=0,ndat=004)
c
      inquire(file="ranmar.d",exist=lexist)
      if(.not.lexist) write(iuo,'(/," pmar: iseed1,iseed2 =",2I9)') 
     &                                      iseed1,iseed2
      call rmaset(iuo,iud,iseed1,iseed2,"ranmar.d")
      do idat=1,ndat
        call ranmar(xr)
        write(iuo,*) 'idat, xr =',idat,xr
      end do
c
      call rmasave(iud,'ranmar.d')
      call ranmar(xr)
      write(iuo,*) 'extra xr =  ',xr
c
      stop
      end

      include '../../ForLib/rmaset.f'
      include '../../ForLib/ranmar.f'
      include '../../ForLib/rmasave.f'
