X-13ARIMA-SEATS routines can crash depending on the current directory

While working on building our dataset (in our case, for seasonal adjustment), we observed that X-13ARIMA-SEATS routines can crash when the current directory is different from the path of the Matlab script where we call the X13 routines. This behavior seems to be eratic: it occurs while we loop over a loop of variables and it does not always crash on the same variable.

In the attached example, I replicate this crash with random data on which I want to do seasonal adjustment. I loop over an arbitrary number of variables (N=30). To trigger the crash, one needs to change the current directory of Matlab to any subfolder.

%% Create a subfodler
mkdir SomeFolder
addpath('./SomeFolder')

%% To trigger the bug set bug = true
bug = true ;
if bug 
    cd('./SomeFolder') 
else
    cd(cwd)
end

In this case, the loop will eventually stop. Sometimes, it can stop for the first variable, sometimes it can iterate until a higher number of variable, for a reason we cannot explain.

Variable 7 
 
ans is a dseries object:
 
       | d11    
1999Q1 | 0.39353
1999Q2 | 0.91905
1999Q3 | 0.6416 
1999Q4 | 0.721  
2000Q1 | 0.92627
2000Q2 | 0.42445
2000Q3 | 0.51803
2000Q4 | 0.3232 
2001Q1 | 0.32554
2001Q2 | 0.3497 
       |        
2021Q2 | 1.1398 
2021Q3 | 0.5587 
2021Q4 | 0.23827
2022Q1 | 0.53768
2022Q2 | 0.46911
2022Q3 | 0.77198
2022Q4 | 0.35521
2023Q1 | 0.4205 
2023Q2 | 0.61482
2023Q3 | 0.21813
2023Q4 | 1.1208 
 
Variable 8 
Reference to non-existent field 'd11'.

Error in x13/subsref (line 88)
                o = builtin('subsref', o.(S(1).subs), S(2));

Error in BugX13 (line 50)
    o.results.d11

BugX13.7z

Edited by Pierre Aldama