Expression in option_periods


I am trying to simulate data from a DSGE model, which is instantenousely hitted by several shocks. Indeed, shocks arrive form period 1 to n. When giving an integer number to n (n=500), my program runs well. However, the program shows error when n is an expression:

periods 1:expression ;

instead of

periods 1:n ;

My question: Is there a way to introduce expression into n instead of an integer number?

To see more my problem, you find attached my codes.
MSSF_steadystate.m (3.62 KB)
MSSF.mod (12.2 KB)

Use the macro-processor:

[code]@#define n=500

var a_shk ;
periods 1:@{n};
values (test1);

var x_shk ;
periods 1:@{n};
values (test2);

var up_shk ;
periods 1:@{n};
values (test3);

var uw_shk ;
periods 1:@{n};
values (test4);

var r_shk ;
periods 1:@{n};
values (test5);

var g_shk ;
periods 1:@{n};
values (test6);


Thanks a lot for your help.

A second question:

Can we use usual functions like sqrt or floor within macro-expression?

For example:

@# define k=1/2
@# define m=39
@# define n=floor(k*m)

To see my exact problem, you find attached the following files: Go to line 388 in model file.

Thanks a lot.
MSSF_VAR_forecast_2_steps_steadystate.m (3.64 KB)
MSSF_VAR_forecast_2_steps.mod (18.2 KB)