Data Sharing within Julia and Dynare

I have done some computations using Julia for example a vector of countries. In what form should I save this data to be accessible to the mod files. For example I have a vector:
ctry=[“SOM”; “FDG”] and generated using Julia.
When I go to the dynare mod file I do this:
@#define country = ctry;

The mod file cannot see the variable generated in Julia.

What is best way of sharing Julia data with mod files??

Can you please post your .mod file?

… And the Julia file

Attached is the zipped folder with files.

file Calib: The file calib is where I do a lot of data manipulations but all in Julia. Ultimately I end up with a dictionary called calib and a vector string called countries. I save these dictionaries using the JLD2 package.
file: Under modeldriver i load my data into the Julia workspace for example Countries. I have included the data for Countries as well in this zip package

I then finally try to load the mod file through dynare. I would like this mod file to access the loaded vector of countries in the workspace but it can’t work. Thats where am stuck. My understanding is that with MATLAB MOD files can access the “MAT” data files through the set_param_data() command. Am not sure how to do this in Julia and with which data formats.

Thank you again.
files.zip (3.0 KB)

Your files were missing dependencies so I couldn’t run them. I made a simpler version

In your code, country is a Dynare macro variable. Such a variable is passed to Dynare by the driver with the -D option. Watch for the " that need to be escaped

For the parameter values, I added a new function set_parameters!(). For now it is in a separate file, but I will add it soon to DynareJulia

I send an example using both syntaxes
forum_mj.zip (1 KB)

It is simpler to use Serialization that is in Julia Base rather than JLD2 that should be added to Dynare.jl project

Thanks so much Michel for the quick and dedicated support.

Greetings Michel–I have now attempted to extend the example to a multi-country model. My biggest challenge is to access the deserialized dictionaries in the MOD file and set the parameters to values in the dictionaries. This is what I have attempted to do–but with some challenges. Attached are the modified files with a dictionary.
temp1.zip (2.0 KB)

You can’t use a vector of strings for the key of the dictionary. It creates problems in the *.mod file. You need to use the parameter name as the key

I transform data.jls in modifieddict.jl

set_parameters() doesn´t work as in Dynare Matlab. It tries to use all the items in the dictionary at once
temp1_mj.zip (957 Bytes)

Thanks Michel—this works very fine. The trick is to create dictionaries that can be understood by MOD files.

Thank you—John

Exactly