CERN homepage INFN homepage
FLUKA: 6.1} The input preprocessor Previous Index Next

6.1} The input preprocessor

 ---------------------------

 FLUKA, since 2005, comes bundled with an internal preprocessor, a simplified
 version of a C-like preprocessor. The preprocessor can modify the input file
 before it is executed with the use of conditions. Presently the functionality
 is limited to 3 types of directives, DEFINITION, CONDITIONAL and INCLUDE.
 The preprocessor is a particularly useful way to include or remove blocks of
 input cards, allowing a more flexible and easy organisation of an input file,
 and to parameterize input parameters allowing for an easy an safe way of
 varying them just modifying a #define statement. One can write the input file
 around a few directives to allow easier debugging, changingthresholds, 
 biasing and scoring cards for the final production.

                                Syntax
                                ------
 All preprocessor directives are single lines starting with the # character in
 the first column and can appear anywhere in the input file, either between
 normal input cards or inside the geometry definition (inline or externally
 defined). Each identifier can be up to 40 characters in length.

                         Definition of Constants
                         -----------------------
 With the DEFINITION DIRECTIVES one can define identifiers to be used later for
 inclusion or removal parts of the input file:

 #define [identifier_name]

 defines [identifier_name] without giving it a value. This can be used in
 conjunction with another set of directives that allow conditional execution.

 #define [identifier_name] [value]

 defines [identifier_name] giving it a value [value]. [value] can be a
 numeric or character value and its definition can be up to 40 characters in
 length. This can be used in conjunction with another set of directives that
 allow conditional execution, or to assign the value [value] anywhere in the
 input cards, geometry included, by referencing to it as $[identifier_name].

 Examples:

 #define Ekbeam   100.0 
 #define Beampart PROTON
 ...
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
BEAM -$Ekbeam $BeamPart ... #define Zbeam -100.0 ... BEAMPOS 0.0 0.0 $Zbeam ... #define Xbox +10.0 #define Ybox +20.0 #define Zbox +50.0 ... RPP TargBox -$Xbox $Xbox -$Ybox $Ybox -$Zbox $Zbox ... #define Targmat IRON ... ASSIGNMAt $Targmat 1.0 @LASTREG ... #undef [identifier_name] deletes any previously defined [identifier_name]. Conditional directives ---------------------- With the CONDITIONAL DIRECTIVES one can include or remove parts of the input file before execution. The #if, #elif, #else blocks must be terminated with a closing #endif. There is a maximum of 10 nesting levels that can be used. #if [identifier_name] ... #elif [identifier_name] ... #else ... #endif The #if and #elif (else-if) directive is followed by an identifier. If the identifier is defined then the statement evaluates to true, otherwise to false.
Example:
#define DEBUG #define PLOT1 ... #if DEBUG
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
GEOEND 100.0 100.0 100.0 -100.0 -100.0 -100.0 DEBUG GEOEND 50.0 50.0 50.0 & #else GEOEND #endif ... #if PLOT1
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
PLOTGEOM 1.0 -2000.0 MBWD6L1 -100.0 0.0 -21620.0 100.0 0.0 -21250.0 1.0 0.0 0.0 0.0 0.0 1.0 -100.0 0.0 -21200.0 100.0 0.0 -20800.0 STOP #endif Include directive ----------------- The INCLUDE DIRECTIVE switches the input stream from the original input file to a different file, and back to the original file after the end-of-file is met. It can be applied also to geometry input. Include directives can be nested at multiple levels. #include [path/filename] where "path" can be an absolute path, or a relative path (relative to the "launching" directory).
Example:
#include /home/geometries/target2.geom #include frontplanes.geom

Previous Index Next