source: Sophya/trunk/SophyaExt/CodeMinuit/cfortran/Examples/chplot-example.c@ 4045

Last change on this file since 4045 was 2414, checked in by cmv, 22 years ago

Exemple pour interface cfortan (CERN) cmv 21/07/2003

File size: 1.1 KB
RevLine 
[2414]1/*
2 * This example demonstrate how to call HPLOT from C.
3 *
4 * For question/problems contact: Heplib.Support@cern.ch
5 *
6 */
7
8#include <stdlib.h>
9#include <cfortran.h>
10#include <graflib.h>
11#include <packlib.h>
12#include <kernlib.h>
13
14#if defined(__hpux) || defined(_IBMR2)
15# define extname
16#endif
17
18#define PAWC_SIZE 50000
19
20typedef struct { float PAW[PAWC_SIZE]; } PAWC_DEF;
21#define PAWC COMMON_BLOCK(PAWC,pawc)
22COMMON_BLOCK_DEF(PAWC_DEF,PAWC);
23
24main()
25{
26 int istat;
27 char c;
28
29 HLIMIT(PAWC_SIZE);
30 HPLINT(4);
31/*
32 * Histograms booking and filling
33 */
34 HBOOK1(1,"x",100,-4.,4.,0.);
35 HBOOK1(2,"y",100,-4.,4.,0.);
36 HBOOK1(3,"(x-y)/(x+y)",100,-6.,6.,0.);
37 fill();
38/*
39 * Histograms plotting
40 */
41 KUOPEN(77,"chplot-example.ps","NEW",istat);
42 IGMETA(77,-111);
43 HPLZON(2,2,1," ");
44 HPLOT(1," "," ",0);
45 HPLOT(2," "," ",0);
46 HPLZON(1,2,2,"S");
47 HPLOT(3," "," ",0);
48 IGMETA(999,0);
49 KUCLOS(77," ",1);
50 c = getchar();
51 HPLEND();
52}
53
54fill()
55{
56 float x,y;
57 int i;
58
59 for ( i=1; i<1001; i++) {
60 RANNOR(x,y);
61 HF1(1,x,1.);
62 HF1(2,y,1.);
63 HF1(3,(x-y)/(x+y),1.);
64 }
65}
Note: See TracBrowser for help on using the repository browser.