Creating a directory structure

Currently, directories can only be made using the Fortran interface. This is to retain full flexibility in the specification of the various directory parameters such as the key types and tags.

The following code adds to the initial directory structure to create a directory CALIBRATION containing the required directories for our example case.

                FORTRAN code to create directories
                                  

      PROGRAM GEDIRS
c|    ================
c|
c|    To Create a directory structure in a database
c|
      PARAMETER    (NWPAW=100000)
      COMMON/PAWC/ PAW(NWPAW)
      PARAMETER    (NKEYS=2)
      PARAMETER    (MAXOBJ=1000)
      PARAMETER    (NODIRS=6)
      CHARACTER*40 DITAG(NODIRS)
      CHARACTER*8  CHTAG(NKEYS)
      CHARACTER*10 CHFOR
      CHARACTER*4  CHTOP
      CHARACTER*80 CHFILE
      CHARACTER*40 DNAME
c|
c|    Initialise directory names
c|
      DATA DITAG/'PC','DC','ST','PID','CAL_WIRE','CAL_STRI'/
      CALL CDPAW(NWPAW,NHBOOK,IDIV,'USR-DIV',5000,50000,'ZPHU',IRC)
      LUNCD  = 1
      LUNFZ  = 2
      CALL CDPREF(10,'GE',CHTOP,CHFILE,IRC)
      IF(IRC.GT.4) THEN
         PRINT *,'EGOPEN. STOPPING DUE TO FATAL ERROR FROM CDPREF'
         STOP 16
      ENDIF
      LRECL  = 0
      CALL CDOPEN(LUNCD,LUNFZ,CHTOP,CHFILE,LRECL,IDIV,' ',IRC)
c|
c|    Define key types and tags
c|
      CHFOR = 'HH'
      CHTAG(1) = 'DETECTOR'
      CHTAG(2) = 'POINTER '
      IPREC=0
      DELTA=0.0
c|
c|    Loop to create directories
c|
      DO 99 IDX=1,NODIRS
         DNAME='//CDGE/GEOMETRY/'//DITAG(IDX)
         PRINT *,'CREATING DIRECTORY ',DNAME,' ...'
         CALL CDMDIR(DNAME,NKEYS,CHFOR,CHTAG,MAXOBJ,IPREC,DELTA
     +               ,'CP',IRC)
         PRINT *,'IRC AFTER CDMDIR =',IRC
99    CONTINUE
c|
c|    Terminate
c|
      CALL CDEND(' ','A',IRC)
      END
c|

This simple program simply loops over the directory names required which are held in the character array DITAG and performs a call to routine CDMDIR which creates the directory. Note that the keys that each directory will contain are also set at this point via the CHTAG array which holds the keys HOLLERITH tags and the CHFOR character array which defines the keys type (in this case the two user keys are HOLLERITHs so we use HH).

We can now examine the directory structure via the interactive interfaces' TREE command. An example transcript follows:

              Examining directory structure with TREE
                                  

 HEPDB>tree
       ----
 CDTREK. directory tree structure below //CDGE down          99  levels
 //CDGE
       /HELP
       /DICTIONARY
       /GEOMETRY
                /PC
                    /1
                /DC
                    /1
                /ST
                    /1
                /PID
                    /1
                /CAL_WIRE
                         /1
                /CAL_STRI
                         /1
          16  subdirectories found
HEPDB>