/* Author: Glen Cowan Date: 4-OCT-1997 C++ version: 23-Aug-1999 Simon George Test program for random number generator and histogram software. Must be linked with RANDOM and with the HBOOK routines (part of PACKLIB in the CERN program library). */ #include #include #include "cfortran/cfortran.h" #include "cfortran/hbook.h" #include "random.h" // prototype for random function used below // define array used for hbook memory #define PAWC_SIZE 50000 float pawc_[PAWC_SIZE]; int main(){ // Initialize HBOOK HLIMIT(PAWC_SIZE); // Open histogram file int lun = 20; int istat = 0; int lrec = 1024; char* outfile = "test_random.his"; HROPEN (lun, "histog", outfile, "N", lrec, istat); if (istat != 0){ std::cout << "HROPEN error, istat = " << istat << std::endl; exit(istat); } // Book histogram HBOOK1 (1, "uniform", 100, 0., 1., 0.); // Generate 10000 random values and enter into histogram int seed = 12345; for (int i = 1; i<1000000; i++){ float x = random(seed); HF1( 1, x, 1.); } // Store histogram and close int icycle=0; HROUT (0, icycle, " "); HREND ("histog"); return 0; }