next up previous contents
Next: MADLIB: A library of Up: DASH: A Data Analysis Previous: Linking: Examples using Unix

Disk-based ntuples: example code

  This is example code for handling the bookkeeping of the RZ filename and top level directory. The DASH command would be TALK MYMODULE RZFILE myfilename.rz N, where the final argument specifies a new RZ file. See the HBOOK manual for more detail. As coded here, this would open the file, but booking would not occur until the command BOOK MYMODULE is given. The final call to HREND would occur on program exit or could be specified interactively with CALL FINI MYMODULE.

      CHARACTER*80 RZFILENAME
      DATA RZFILENAME/'MYMODULE.RZ'/	! Default filename
...
      ENTRY MYMODULE_TALK
c
c     Get first word after TALK in command line and act based on it:
c     ==============================================================
      CALL KUGETC(VERB,LEN)
      IF (VERB(1:3) .EQ. 'RZF') THEN
c
c        Get the filename and CHOPT options from the command line:
c        ---------------------------------------------------------
         CALL KUGETC(RZFILENAME,LEN)
         CALL KUGETC(CHOPT,LEN)
         CALL HROPEN(1,'MYNTUPL',RZFILENAME,CHOPT,LRECL,ISTAT)
         RZOPEN = .TRUE.
      ELSE
         IF (VERB(1:4) .NE. 'HELP') THEN
            WRITE(*,*) 'Unrecognized MYMODULE command', VERB
         END IF
         WRITE(*,*) 'Valid MYMODULE commands: '
         WRITE(*,*) 'RZFILE <filename>'
         WRITE(*,*) 'HELP'
      END IF
      RETURN

      ENTRY MYMODULE_BOOK
c
c     Book NTUPLE- but only if file is open!:
c     =======================================
      IF (RZOPEN) THEN
         CALL HBOOKN(30,'MYNTUPL',3,'//MYANA',1000,CHTAGS)
      ELSE
         WRITE(*,*) 'RZ file not open! Try TALK MYMODULE HELP'
      END IF
      RETURN

      ENTRY MYMODULE_FINI
      IF (RZOPEN)
         CALL HCDIR('//MYANA')
         CALL HREND('MYANA')
         RZOPEN = .FALSE.
      ELSE
         WRITE(*,*) 'No RZ file to close'
      END IF
      RETURN



ETK