#!/bin/sh # The purpose of this script is to process your DDL file with the program # MAD = "Manipulate ADAMO Dictionary". MAD creates source code files from # your DDL definitions which your program will use to interact with your # data structures. #=============================================================== # Make large DDL file containing all subfiles of interest #=============================================================== # Which DDL files do we have to deal with? If there is more than one, just # separate them with spaces in the DDLS string. DDLS="toyMC.ddl" # Concatenate all the DDL files together into one temporary uber-DDL # called mad.ddl. cat $DDLS > mad.ddl #=============================================================== # Make mad startup file to process DDL's #=============================================================== # We will create a temporary KUIP script (macro) that MAD will execute. # This script will tell MAD to do these things: # # - Read in the big DDL file and process it. # - Create INCLUDE FILES for each table in the DDL. # These include files will contain one common block each, # and declare the variables needed to store the table information # - Create source code for the INITAP routine, needed to initialize # ADAMO in your program. # - Create source code for the CREOBJ routine, which your program # will need to create all your ADAMO tables and relationships in memory. # # The source codes for the include files and for the INITAP and CREOBJ # routines will be produced in both Fortran and C. # # A note about INITAP. This routine does three simple things: # # - It initializes ZEBRA, the memory manager for all CERNLIB packages. # - It initializes TAP, the main ADAMO library. As part of this # initialization, it reserves a certain number of words of memory # space for ADAMO. The default is 1000000 words. If this number # is too small, BAD things will happen: ZEBRA is perfectly capable # of overwriting addresses in memory used by other pieces of code. # - It calls CREOBJ, the routine which will declare your personal # data structures to ADAMO. # # You do not really need to have MAD create a special INITAP routine for # you, since the TAP library to which you will link you code already # contains a version of this routine. About the only reason to create # your own is to change the default number of words with which the TAP # is initialized. # Anyway, let's get going with the rest of this script ... # Open the script file. All following lines will be sent directly to # the script, until the line 'stop' is found. Until then, my comments # will be prefixed with '*' instead of '*' since that is the comment # indiciator for a KUIP macro. cat > mad.kumac << stop * The next two commands increase the maximum number of characters allowed * for ESet and Attribute NAMES from the default (16) to 32. ddl/set ESetlength 32 ddl/set AttributeLength 32 * Now read in your big DDL file. mess Reading DDL ... ddl/read mad.ddl * The compiled, or processed, form of a DDL is known as a 'dictionary'. * The following command both compiles the DDL to create this dictionary * (in memory), and checks the sanity of your DDL definitions. dic/check * Option: create a file and store the dictionary in it. * Your program will only need the dictionary file if you plan to use * ADAMO's run-time validation routines (e.g. checking all data to see * if it falls within the ranges you declared in your ddl file). * Note: the dic/file/close command is not really necessary since the * dictionary file will be closed automatically when you exit MAD. dic/file/create mad.dic dic/file/insert dic/file/close * Next, we ask MAD to write the Fortran source code your program will need. mess Writing FORTRAN code ... fortran/write mad.adamo * All the source code has just been written into one big file called mad.adamo. * An old CERNLIB format called HISTORIAN has been used to identify the * different pieces of code within this file. We would now like to * split the code up into individual include files, and individual * INITAP.f and CREOBJ.f files. First, we specify certain formatting options * for this conversion. * ... Request that INITAP code be created, that the filename base be INITAP, * ... and that 2 million words of memory be reserved. fortran/set initap INITAP:2000000 * ... Request that CREOBJ code be created (with the default filename * ... base CREOBJ). This is the default behaviour, you don't need this line. fortran/set creobj CREOBJ * ... Set the maximum length for your include filename bases. * ... Your include files will be named after your tables. Your table * ... names will be truncated to this length before being used in * ... any filenames. fortran/set length 12 * ... Set the metacharacter that will be used to mean 'insert appropriate * ... filename base' in each of the subsequent commands. fortran/set metachar @ * ... Set the filename pattern for the INITAP and CREOBJ routines. * ... PLEASE use the suffix '.F', instead of '.f' (reason: some Linux * ... compilers only run the preprocessor on .F files). fortran/set dkfile @.F * ... Set the filename pattern for your include files. fortran/set cdfile @.inc * ... Set the pattern for include STATEMENTS. Please use the following * ... format, which asks the preprocessor to do the work, rather than the * ... fortran compiler itself. fortran/set capattern '#include "@.inc"' fortran/set adpattern '#include "@.inc"' * ... Finally, do the conversion. fortran/conv mad.adamo * We're done, close the mad.kumac macro file. stop #=============================================================== # Startup MAD, execute the mad.kumac macro, and exit immediately #=============================================================== # These simple lines start mad, and send it the one command 'exit'. # MAD automatically looks for a script called 'mad.kumac', and will # execute it immediately, before your 'exit' command tells it you're done. mad << stop exit stop #=============================================================== # Clean up #=============================================================== # You have created several temporary files that you will not need again. # Normally, you would delete them here, for neatness. I will comment out # the usual 'rm' command, so that you can look at the files which # makeddl has produced. # rm -f mad.kumac mad.adamo # I will, however, remove the concatenated mad.ddl file, and all the # irritating *INQ files that MAD creates. I still have no idea what # they're good for ... rm -f mad.ddl *INQ last.*