Last change
on this file since 3056 was 2414, checked in by cmv, 22 years ago |
Exemple pour interface cfortan (CERN) cmv 21/07/2003
|
File size:
1017 bytes
|
Line | |
---|
1 | /*
|
---|
2 | * This example demonstrate how to call HBOOK from C (histogram part).
|
---|
3 | *
|
---|
4 | * For question/problems contact: Heplib.Support@cern.ch
|
---|
5 | *
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include <stdlib.h>
|
---|
9 | #include <cfortran.h>
|
---|
10 | #include <hbook.h>
|
---|
11 |
|
---|
12 | #if defined(__hpux) || defined(_IBMR2)
|
---|
13 | # define extname
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | #define PAWC_SIZE 50000
|
---|
17 |
|
---|
18 | typedef struct { float PAW[PAWC_SIZE]; } PAWC_DEF;
|
---|
19 | #define PAWC COMMON_BLOCK(PAWC,pawc)
|
---|
20 | COMMON_BLOCK_DEF(PAWC_DEF,PAWC);
|
---|
21 |
|
---|
22 | #if defined(__vms) || defined(vms)
|
---|
23 | /* On VMS rand has a range of 2**31 */
|
---|
24 | # define RAND_RANGE 2146483648.
|
---|
25 | #else
|
---|
26 | # define RAND_RANGE 32768.
|
---|
27 | #endif
|
---|
28 |
|
---|
29 | main()
|
---|
30 | {
|
---|
31 | int hid=1;
|
---|
32 | int i,j;
|
---|
33 | float r;
|
---|
34 | /*
|
---|
35 | * Some C++ compiler generates a memset error when a character string
|
---|
36 | * is passed directly as argument to a F77 function. Using an intermediate
|
---|
37 | * variable make it work.
|
---|
38 | */
|
---|
39 |
|
---|
40 | HLIMIT(PAWC_SIZE);
|
---|
41 | HBOOK1(hid,"Some random distribution",20000,-4.,4.,0.);
|
---|
42 |
|
---|
43 | for (i=0;i<100000;i++){
|
---|
44 | for (j=0,r=0.;j<10;r += rand()/RAND_RANGE -0.5 ,j++);
|
---|
45 | HFILL(hid,r,0.,1.);
|
---|
46 | }
|
---|
47 | HPRINT(hid);
|
---|
48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.