The use of subdirectories, both in memory and on disk, is shown in the following examples.
Example of using subdirectories
PROGRAM TEST
INTEGER NWPAWC
PARAMETER (NWPAWC=15000)
COMMON/PAWC/PAW(NWPAWC)
CHARACTER*8 CHTAGS(5)
DIMENSION EVENT(5)
EQUIVALENCE (EVENT(1),X),(EVENT(2),Y),(EVENT(3),Z)
EQUIVALENCE (EVENT(4),ENERGY),(EVENT(5),ELOSS)
DATA CHTAGS/'X','Y','Z','Energy','Eloss'/
*-- Tell HBOOK how many words are in PAWC.
CALL HLIMIT(NWPAWC)
CALL HROPEN(1,'EXAMPLE','EXAMPLE.DAT','N',1024,ISTAT)
IF(ISTAT.NE.0)GO TO 99
*-- Make sub-directory on disk (as HROUT does not do this for us).
CALL HMDIR ('US','S')
CALL HCDIR('//PAWC',' ')
*-- Make sub-directory in memory.
CALL HMDIR ('US','S')
CALL HCDIR('//PAWC/US',' ')
*-- Book Ntuple + 1d histogram
CALL HBOOKN(10,'A simple Ntuple',5,'EXAMPLE',5000,CHTAGS)
CALL HBOOK1(100,'Energy distribution',100,0.,100.,0.)
*-- Fill the Ntuple and histogram
DO 10 I=1,1000
CALL RANNOR(X,Y)
Z=SQRT(X*X+Y*Y)
ENERGY=50. + 10.*X
ELOSS=10.*ABS(Y)
CALL HFN(10,EVENT)
CALL HFILL(100,ENERGY,0.,1.)
10 CONTINUE
*-- Juggle top directories (order of these calls is important!!).
CALL HCDIR('//PAWC',' ')
CALL HCDIR('//EXAMPLE',' ')
*-- Write out everything to disk
CALL HROUT(0,ICYCLE,'T')
*-- Flush remaining buffers to disk.
CALL HREND('EXAMPLE')
99 CONTINUE
END