summaryrefslogtreecommitdiffstats
path: root/sources/fabrice/pacemaker/genrand.ml
blob: 718762f0c5b7eb2d094de2917bf8c012d7067587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
open BigEndian

let _ =
  Printf.printf "genrand <filename> <nrandom>\n%!"

let filename = Sys.argv.(1)
let n = Int64.of_string Sys.argv.(2)

let block = 4096
let blockL = Int64.of_int block
  
let _ =
  let bound = 1 lsl 29 in
  let oc = open_out filename in
  let s = String.create (4 * block) in
  let nblocks = Int64.to_int (Int64.div n blockL) + 1 in
  for i = 1 to nblocks do
    for x = 0 to block - 1 do
      
      str_int s (x*4) (Random.int bound)
      
    done;
    output_string oc s    
    
  done;
  close_out oc