Issue with Dynare Preprocessor (4.6.1)

Dear Dynare team,

I recently updated to 4.6.1 and adapted my files to the new structure. However, I sometimes get the following error message:

Computing static model derivatives (order 1).
Computing dynamic model derivatives (order 2).
terminate called after throwing an instance of ‘std::filesystem::__cxx11::filesystem_error’
what(): filesystem error: cannot remove all [YjLu0asVxy]
Error using dynare (line 282)
Dynare: preprocessing failed

This error appears randomly in about every second to third run but disappears upon restarting.

As most of my routines use several calls of dynare, this issue is quite disturbing. Is there a way to solve it?

Thank you for your time!

Best
Jonathan

2 Likes
  1. Is there a particular reason you are calling all of Dynare repeatedly? That is not recommended.
  2. It sees that you are calling Dynare faster than the hard-disk and file system can process your calls. You may have to add a pause before running Dynare again.
  1. I wrote a little toolbox that directly generates nice looking graphs that can be directly integrated in LateX (or other programs). Basically it runs dynare for a specific model, collects the results, and then runs dynare for the next model.
  2. I integrated some pause commands and for now it seems to work. Thank you very much! I think the problem might have been related to a connected Dropbox folder that updated the folders just the moment the dynare preprocessor wanted to delete them.

Dear @jpfeifer

I encounter the problem below when I run the model. I attached my mod file.

Thanks in advance…

Using 64-bit preprocessor
Starting Dynare (version 4.6.4).
Calling Dynare with arguments: none
“/Applications/Dynare/4.6.4/matlab/preprocessor64/dynare_m” model3.mod mexext=mexmaci64 “matlabroot=/Applications/MATLAB_R2018a.app”: Aborted
Starting preprocessing of the model file …
Found 35 equation(s).
Evaluating expressions…done
Computing static model derivatives (order 1).
Computing dynamic model derivatives (order 1).
terminate called after throwing an instance of ‘std::filesystem::__cxx11::filesystem_error’
what(): filesystem error: cannot create directory: File exists [model3]

model3.mod (1.9 KB)

As detailed above, this is not an issue with a particular mod-file but with file access of the program to your hard drive.

I solved it thnks

Hello Prof. Pfeifer,

Unfortunately, bother you again and again. I just met this problem. Could you please give me a sample code of adding a pause? I’m looping parameters in OSR.

Spring

OK, I searched in the forum and will try immediately

1 Like

That is strange. Are you looping over Dynare as a whole? That is strongly discouraged.

Hello Professor, thank you for your support!

I downloaded some sample codes from the forum, and I found looping inside Dynare doesn’t work. So unfortunately, I have to loop Dynare as a whole…

My looping codes are similar to the following fractions:

for the m file,

%welfare loss metric
welfare_loss_arr=zeros(length(epsilon_arr),length(phi_arr));

var_inflation = zeros(length(epsilon_arr),length(phi_arr));
var_outputgap=zeros(length(epsilon_arr),length(phi_arr));

%running the mode file and save the desired results
for ii=1:length(epsilon_arr)
    for jj=1:length(phi_arr)
        epsilon = epsilon_arr(ii);
        phi = phi_arr(jj);
        save parameterfile_welfare epsilon phi;
        dynare welfare_loss noclearall
        var_outputgap(ii,jj) = oo_.var(1,1);
        var_inflation(ii,jj) = oo_.var(2,2);
        welfare_loss_arr(ii,jj) = epsilon/lambda*var_inflation(ii,jj)+...
            (1+phi)*var_outputgap(ii,jj);
    end
end

For the mod file,

%mechansim on recursively running
load parameterfile_welfare;
set_param_value('epsilon',epsilon);
set_param_value('phi',phi);

and

shocks;
var eps_a; stderr 0.01; 
var eps_y_star; stderr 0; 
var eps_a_star; stderr 0;
end;

stoch_simul(irf=16,nograph,noprint) ygap pi_h R pi;

I read some topics discussing ‘‘looping over parameters’’, but they are too long. Would you please just modify these segments of codes to make MATLAB-Dynare accelerate?

Sincerely,

Spring

1 Like
  1. In such cases, always provide the full codes and the full error message.
  2. is not a good argument. Why should other people spend time on your problems if you are not willing to invest time?

Ran into this problem myself as well. The issue was simply that I had at one point saved my code as a file without any file extension i.e. as “model_name” instead of “model_name.mod”. This meant that my code could not create a folder named “model_name” as this was already taken.

Simply deleting the file without the file extension solved the problem.

1 Like

In my case, I suppose this issue was related to having saved the “*.mod” file without the “.mod” extension.

1 Like