Differences

This shows you the differences between two versions of the page.

Link to this comparison view

optional_sections [2019/11/17 15:16] (current)
johnsoevans created
Line 1: Line 1:
 +====== #define and #prm ======
  
 +It's often useful to have optional sections in an INP file to test different models. ​ You can do this by commenting in/out sections of the INP file using ' or /*...*/.
 +
 +Often it's easier to use the #define command:
 +
 +<code topas>
 +#define fit_xray
 +#define fit_neutron
 +
 +#ifdef fit_xray
 +  ..xray stuff
 +#endif
 +
 +#ifdef fit_neutron
 +  ..neutron stuff
 +#endif
 +</​code>​
 +
 +You can get more flexibility with #prm.  For example the code below does the same as #define:
 +
 +<code topas>
 +#prm x_ray = 1;   '​or set to 0 to not include
 +#prm neutron = 1; 'or set to 0 to not include
 +
 +#if (x_ray)
 +  ..xray stuff
 +#endif
 +#if (neutron)
 +  ..neutron stuff
 +#endif
 +</​code>​
 +
 +But you can also do a lot more and combine conditions. For example:
 +
 +<code topas>
 +#if (x_ray == 0)
 +  ..xray stuff
 +#​elseif ​ (And(neutron == 1,  x_ray == 3)
 +  ...
 +#elseif (Or (Run_Number == 18, x_ray))
 +#else
 +#endif
 +</​code>​

Personal Tools