DYNARE
Contents
General Description
Configuring MATLAB for dynare
To use dynare with MATLAB, one needs to configure MATLAB so that it can find where dynare is located. There are two ways of doing this. One of the methods, can only be used if one is planning on using MATLAB interactively. The other method can be used both interactively and through the scheduler.
Method 1: Configuring MATLAB Using Menu Entries
Note: One needs to use the X flag when connecting to the frontend nodes because this method requires MATLAB's GUI. This explains why this method can only be used interactively. Also, one is required to save the path settings using this method, but normal users do not have access to modify this file. Therefore, save this file to the location where your dynare files are located. This way, if you run MATLAB through this directory, MATLAB will know where to find dynare. If the path file you create from this method is saved at a different location, MATLAB will not know where to find dynare.

Open MATLAB

Click on the MATLAB File menu.

Click on the Set Path menu entry

Click on the Add Folder... button. This will open a file dialog.

Select the matlab subdirectory of your Dynare installation. As of the the writing of this page, there is only one dynare installation. The path is /opt/crc/dynare/dynare4.1.1/matlab/.

Click Ok to close the file dialog.

Apply the setting by clicking Save button.

If you are not allowed to modify the path file, a window will appear informing you that it cannot save the changes to the original file and if you want to save the file in a different location. Select yes.

Navigate to the directory you normally use to start MATLAB. This allows MATLAB to use the path settings in that file whenever it is started. Note that if MATLAB is started from a different directory, you will need to set dynare's path again. Click Save.
 Click Close on the next window.
Method 2: Configuring MATLAB Using the Command Window
Note: Unlike the first method, setting the path the following way will need to be done everytime MATLAB is run. The settings of where dynare is located will not be saved.

Open MATLAB

Click in the Commmand Window.

Type the following: addpath /opt/crc/dynare/dynare4.1.1/matlab/. Note, as mentioned earlier, this is currently the only dynare version available. To check if there are any more versions use the module avail dynare command.
Now MATLAB should be able to find dynare.
Note: For future reference, if there are multiple dynare installations in the future. One is able to locate the path of the installation by using the following command: module show dynare/ver# where ver# is the version listed in the module list. The command just mentioned shows the different environment variables that get set when the module is loaded and one of them is the PATH of the module.
Basic Usage
After telling MATLAB where to find dynare, running the dynare model is simple when done interactively, but needs a slight modification when running through the scheduler. In the following examples, were are using a standard file called example1.mod which is located under /opt/crc/dynare/dynare4.1.1/tests. The following sections show how to use MATLAB with dynare in different scenarios.
Scenario 1: Using MATLAB and dynare Interactively WITHOUT the GUI

Go to the directory where the dynare model file you are tyring to run is located.

Load the MATLAB module.

Run MATLAB.

Tell MATLAB where to find dynare using Method 2 listed above.
 Type dynare dynarefile which in this case is dynare example1. Note that the .mod extension is not necessary.
Scenario 2: Using MATLAB and dynare Interactively WITH the GUI

Run MATLAB.

Tell MATLAB where to find dynare using ANY of the methods listed above.

If MATLAB is not run where the dynare file is located, use MATLAB's Current Folder panel or Current Folder bar to navigate to the location of your dynare file.
Type dynare dynarefile which in this case is dynare example1. Note that the .mod extension is not necessary.
Scenario 3: Using MATLAB and dynare With the Scheduler

Create a submission script with the same headings as any other MATLAB job. Make sure that the submission script is located in the SAME location as your dynare model file. For this example, we will call the submission script submit.sh.

Create a MATLAB file that invokes the command that tell MATLAB where to find dynare and the command runs dynare with the dynare model file. Make sure this file is also located in the SAME location as your dynare model file. For this example, we will call this file rundynare.m.

Make sure that the MATLAB module is going to be loaded by having module load matlab in the submission script.

After the line in the submission script that loads the module for MATLAB, add the following line: matlab < Step2File, which runs MATLAB with the file created on Step 2' when the job is sumbitted. In this example, it should be matlab < rundynare.m. Make sure that this file has the .m extension, otherwise, MATLAB might complain.

Save the submission script, and submit your job by typing in the terminal qsub submissionscript which is qsub submit.sh in this example.
 Congratulations! MATLAB should now be running the dynare model through the scheduler.
The following is the file that was created on Step 2.
addpath /opt/crc/dynare/dynare4.1.1/matlab dynare example1
The following is a sample submission script on running MATLAB with dynare through the scheduler.
#!/bin/csh #$ M afs_id@nd.edu #$ m ae #$ r y #$ q *@@d6copt #$ pe smp 8 # The MATLABPATH variable is set in the Matlab script to add additional # directories to the internal search paths. setenv MATLABPATH directory_path_to_your_files.m:other_user_contrib_directory_path module load matlab matlab < rundynare.m
Useful Options
Further Information
See the official website: Dynare