* A fast histogram booking, filling and manipulation package
* based on look
*
*
* Layout of data area
*
* RF(1) = 'LHIS'
* RF(2) = IDIM dimension of RF array
* RF(3) = NUSED actual size booked
* IF(4) = index of last data block
* IF(5) = semaphore for blocking access to whole array
* IF(6) = print flag >0 => print errors
* RF(7)+RF(8) 8 character area name
* IF(9) = IVERS version number
* IF(10) = #characters in overall title
* RF(11.. 30) = 80 character overall title
* IF(31..40) = user extension words
* 41...data blocks
* A5I2AI20A11I header format
* data block structure
*----------------------
*
* 1 length of data block
* 2 data type TEXT=0 HS=1 HSW=2 HD=3 HDW=4 XY=5 XYZ=6 VEC=7
* 3 attribute 1
* 4 attribute 2
* 5 attribute 3
*
* 6 semaphore word
* 7 index of next data block or zero if last
* 8 ifg
* 9 inr ( or ipos for TEXT )
* 10
*
* for text only ( data type = 0 )
* 11 #characters
* 12...the text
*
* statistical information
* 11 total weight = sum of all weights
* 12 total number of entries
* 13 xw bin width reciprocal
* 14 yw bin width reciprocal
* 15
* 16
* 17
* 18
* 19 sum of squares of all weights
*
* for histograms only
* 20 =1 histogram storage mode
*
* 21 NX bin definition for x
* 22 XA
* 23 XB
* 24 xmin
* 25 xmax
* 26 x mean
* 27 x sigma
* 28 xref
* 29 sum x
* 30 sum x**2
*
* 31 NY bin definition for y 2-D histogram
* 32 YA
* 33 YB
* 34 ymin
* 35 ymax
* 36 y mean
* 37 y sigma
* 38 yref
* 39 sum y
* 40 sum y**2
*
* 31 x low entries 1-D histogram
* 32 x inside entries
* 33 x high entries
*
* 41.... data part 1-D histogram
*
* 41 x low y low entries 2-D histogram
* 42 x inside y low
* 43 x high y low
* 44 x low y inside
* 45 x inside y inside
* 46 x high y inside
* 47 x low y high
* 48 x inside y high
* 49 x high y high
* 50
* 51.. data part 2-D histogram
*
*
* Initialise
*
* CALL NHINIT(NWORD) N for COMMON/CLHIST/RF(NWORD)
* CALL MHINIT(RF,NWORD) M for alternate arrays
* chinit(rf,nword) C call
*
* Define overall title
*
* CALL NTITLE(TITLE)
* CALL MTITLE(RF,TITLE)
* ctitle(title)
*
* Define area name and version number
*
* CALL NAREA(ARNAME,IVERS) CHARACTER*8 ARNAME
* CALL MAREA(RF,ARNAME,IVERS)
* carea(arname,ivers)
*
* Book NOTE user must keep return INDex for filling calls
* don't forget SAVE statements in fortran
*
* IND= NBHS(IFG,INR,NX,XA,XB) 1-D
* IND= MBHS(RF,IFG,INR,NX,XA,XB)
* IND= cbhs(rf,ifg,inr,nx,xa,xb)
*
* IND= NBHD(IFG,INR,NX,XA,XB,NY,YA,YB) 2-D
* IND= MBHD(RF,IFG,INR,NX,XA,XB,NY,YA,YB)
* IND= cbhd(rf,ifg,inr,nx,xa,xy,ny,ya,yb)
*
* Fill
*
* CALL NFHS(IND,X)
* CALL NFHSW(IND,X,W)
* CALL MFHS(RF,IND,X)
* cfhs(rf,ind,x)
* CALL NFHD(IND,X,Y)
* CALL NFHDW(IND,X,Y,W)
* CALL MFHD(RF,IND,X,Y)
* cfhd(rf,ind,x,y)
*
* Copy to LOOK
*
* CALL NTLK(IFG) all figures
* CALL MTLK(RF,IFG) IFG=0 all figures
* CALL ctlk(RF,IFG)
*
* Define Text
*
* CALL NTEXT(IFG,IPOS,TEXT)
* CALL MTEXT(RF,IFG,IPOS,TEXT)
* ctext(rf,ifg,ipos,text)
*
* Define Attributes
*
* CALL NATTR(IND,ATTRIB)
* CALL MATTR(RF,IND,ATTRIB)
* cattr(rf,ind,attrib)
*
*
* Find Index ( routine should not be needed by user )
*
* IND= NINDEX(ITYPE,IFG,INR)
* IND= MINDEX(RF,ITYPE,IFG,INR)
* ind= cindex(rf,itype,ifg,inr)
*
*
* Stepping through existing datasets
* IND= NNEXTD(LAST,ITYPE,IFG,INR)
* IND= MNEXTD(RF,LAST,ITYPE,IFG,INR)
* ind= cnextd(rf,last,itype,ifg,inr)
* nb start with LAST=0 to get first dataset, returns IND,ITYPE,IFG,INR
*
* Purging ( clearing of contents )
*
* CALL NPURG(IFG) ifg=0 all figures
* CALL MPURG(RF,IFG)
* cpurg(rf,ifg)
*
* purge single data set
*
* CALL NPURGF(IND)
* CALL MPURGF(RF,IND)
* cpurgf(rf,ind)
*
* Printing
* CALL PRNTR(LUNP,MPR)
* MPR>0 full print-out MPR lines per page
* MPR=0 reduced
* MPR<0 terminal 72 columns, 20 lines max
* LUNP unit number
* cprntr(mpr)
*
* CALL NPRNTF(IFGA,IFGB) range of figures 0,0 means ALL
* CALL MPRNTF(IRF,IFGA,IFGB)
* cprntf(irf,ifga,ifgb)
*
* CALL NPRDEX print index
* CALL MPRDEX(IRF)
* cprdec(irf)
*
* Get current area
* CALL NQAREA(ARNAME,IVERS)
* CALL MQAREA(IRF,ARNAME,IVERS)
* cqarea(irf,arname,ivers)
*
* Access to the data
*
* CALL NGPARM(IND,NVEC,NENT,NWORDS)
* CALL MGPARM(IRF,IND,NVEC,NENT,NWORDS)
* cgparm(IRF,IND,NVEC,NENT,NWORDS)
* returns NVEC=dimension parameter NENT=#entries NWORDS=#data words
*
* CALL NGBINS(IND,NX,XA,XB,NY,YA,YB)
* CALL MGBINS(IRF,IND,NX,XA,XB,NY,YA,YB)
* cgbins(IRF,IND,NX,XA,XB,NY,YA,YB)
* returns bins data for IND
*
* CALL NGSTAT(IND,NENT,SUMW,RNEFF,XSTAT,YSTAT)
* CALL MGSTAT(IRF,IND,NENT,SUMW,RNEFF,XSTAT,YSTAT)
* cgstat(IRF,IND,NENT,SUMW,RNEFF,XSTAT,YSTAT)
* obtain statistics where
* NENT= # entries
* SUMW= sum of weight of all entries
* XSTAT(1)=minimum x value
* XSTAT(2)=maximum x value
* XSTAT(3)=mean x
* XSTAT(4)=standard deviation of x
* YSTAT(1)=minimum y value
* YSTAT(2)=maximum y value
* YSTAT(3)=mean y
* YSTAT(4)=standard deviation of y
*
* CALL NFDATA(IND,IDAT,NR,ARRAY,NDIM)
* CALL MFDATA(IRF,IND,IDAT,NR,ARRAY,NDIM)
* CALL cfdata(IRF,IND,IDAT,NR,ARRAY,NDIM)
* access to data words IDAT+1 to IDAT+NDIM
* returns NR = number of words copied to usr array
* if NR = NDIM there may be more words, and they may be
* obtained by another call with IDAT=IDAT+NR
*
* get attibutes
* CALL NGATTR(IND,NCH,ATTRIB)
* CALL MGATTR(IRF,IND,NCH,ATTRIB)
* cgattr(irf,ind,nch,attrib)
* ATTRIB character array returned with NCH characters of text
*
* get text
* CALL NGTEXT(IFG,IPOS,NCH,TEXT)
* CALL MGTEXT(IRF,IFG,IPOS,NCH,TEXT)
* data words are then IRF(INDDAT).,IRF(INDDAT+1),...
* INDDAT=NFDIND(IND)
* character string TEXT, NCH characters returned
*
* get overall title
* CALL NGTITL(NCH,TEXT)
* CALL MGTITL(IRF,NCH,TEXT)
* cgtitl(irf,nch,text)
* character string TEXT, NCH characters returned
*
* get index of first data word
* data words are then IRF(INDDAT).,IRF(INDDAT+1),...
* INDDAT=NFDIND(IND)
* INDDAT=MFDIND(IRF,IND)
* INDDAT=cfdind(irf,ind)
*
*
* Sum histograms from array2 into array1
* CALL MSUM(array2,array1) all histos
* CALL MSUM1(array2,ind2,array1,ind1) single histogram
*
* CALL NTLK(IFG) all figures
* CALL MTLK(RF,IFG) IFG=0 all figures
* CALL ctlk(RF,IFG)
* .. and more to come
* Internal subroutines
* IND= NCRBNK(ITYP,IFG,INR,NWORD) create bank
* IND= MCRBNK(IRF,ITYP,IFG,INR,NWORD)
* IND= ccrbnk(IRF,ITYP,IFG,INR,NWORD)
*
* CHARACTER*4 FUNCTION CHTYP(ITYPE)
* translate integer type ITYPE to character*4 string
* IMPLEMENTATION: