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 ... The following names [identifier_name] are predefined (be careful they are case sensitive): - Pipipi: pi (3.1415...) - Minute: minute (60 s) - Hour : hour (3600 s) - Day : day (86400 s) - Week : week (604800 s) - Month : month, 1/12 of a mean tropical year (365.242374/12 x Day s) - Year : mean tropical year (365.242374 x Day s) #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 Parametric expressions ----------------------- The PARAMETRIC EXPRESSIONS allow to use symbolic algebra in the definition of input parameters. They are an extension of the DEFINITION DIRECTIVES where instead of defining a numeric or character value, the user can define a complex arithmetical expression which can make use of various mathematical operators and functions and/or of previously defined values. #define [identifier_name] [expression] defines [identifier_name] giving it the value corresponding to the evaluation of the mathematical expression [expression]. The definition of [expression] can be up to 60 characters in length and cannot contain any blank character. [expression] can make use of previously defined [identifier_name]s, of the mathematical operators "+", "-", "*", "/" and "^" (power), and of the following standard (fortran) mathematical functions (please note that they are case sensitive): - Sin([argument]) - Cos([argument]) - Tan([argument]) - Exp([argument]) - Log([argument]) - Abs([argument]) - Sind([argument]) - Cosd([argument]) - Tand([argument]) - Asin([argument]) - Acos([argument]) - Atan([argument]) - Sqrt([argument]) - Sinh([argument]) - Cosh([argument]) - Asind([argument]) - Acosd([argument]) - Atand([argument]) - Asinh([argument]) - Acosh([argument]) The function argument [argument] must be enclosed in parentheses as shown above, and can be a simple numerical factor, or an [identifier_name]!, or another mathematical expression. The expression [expression] can contain several levels of nested parentheses, and it is evaluated according to the rules of symbolic algebra. The value eventually assigned to an [identifier_name] defined by means of an expression [expression] is echoed on the output file, and on a special copy of the input file ([input name]-echo.inp) which is automatically generated in the directory from where Fluka has been launched and which contains only the active parts of the input. The creation or not of the echo input file can be controlled by means of the environmental variable FLUKAECHO. If FLUKAECHO is set to y/Y/Yes/yes/1 the echo input file is always created and retained, if FLUKAECHO is set to n/N/No/no/0 the echo input file is never created. The default action (FLUKAECHO undefined or with an invalid value) is to create a temporary echo input file and retain it if there is at least one parametric expression in the input, deleting it otherwise. Examples: #define Pbeam 7000.0 #define Zbeam 1.0 ...
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
BEAM $Pbeam PROTON ... #define Km 100000.0 #define RadCurv 27.0*Km/2.0/Pipipi ... #define RadInner RadCurv-100.0 #define RadOuter RadCurv+100.0 ... ZCC LHCinner 0.0 0.0 $RadInner ZCC LHCouter 0.0 0.0 $RadOuter ... #define MagnNumb 1000.0 #define MagChord 2.0*RadCurv*Sind(360.0/MagnNumb/2.0) ... RCC Magnet 0.0 0.0 0.0 $MagChord 0.0 0.0 50.0 ... #define AvBField Pbeam/RadCurv/Zbeam/2.99792458E-03 ...
*...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
MGNFIELD 30.0 0.1 0.75 0.0 0.0 $AvBField ...

Previous Index Next