Setting macroprocessor options externally

I have a core model with a number of alternative versions. I use the macro-processing language to tell Dynare which version to use.

To be concrete, if I want to run a version of the model with anticipated monetary policy shocks in the preamble i will set:

// Tun on anticipated shocks (1 = yes, 0 = no)
@# define anticipated_shocks = 1

and so on. This works fine, but it is inconvenient (and prone to mistake) to have to go into the mod file and change the settings individually each time I run a simulation.

Is there any way that I can set all of these switches in first in matlab and then impose them when I call the Dynare file? My thought was to create a structure in matlab that contained all the settings (e.g. SET.anticipated_shocks = 1) and then use if / else statements in Dynare, like:

if SET.anticipated_shocks == 0
@# define anticipated_shocks = 0
else
@# define anticipated_shocks = 1
end

But that doesn’t work because the macro-processing language reads both @# define lines so it always sets anticipated shocks equal to 1.

Any thoughts would be really useful. (Even if the answer is no because then I can stop wasting my time trying to work this out).

You can use the -D command line switch to directly pass preprocessor variables. See
[Loop over certain antizipation horizons) for an example

Works perfectly. Many thanks!