View source for DYNARE From CRC Wiki ← DYNARE PageDiscussionView sourceHistory More... What links here Related changes Special pages Page information You do not have permission to edit this page, for the following reason: The action you have requested is limited to users in the group: Users. You can view and copy the source of this page. ==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 front-end 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.''''' <ol> <li> Open '''MATLAB''' <br /><br /> <li> Click on the MATLAB '''File''' menu. <br /><br /> <li> Click on the '''Set Path''' menu entry <br /><br /> <li> Click on the '''Add Folder...''' button. This will open a file dialog. <br /><br /> <li> 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/dynare-4.1.1/matlab/'''''. <br /><br /> <li> Click '''Ok''' to close the file dialog. <br /><br /> <li> Apply the setting by clicking '''Save''' button. <br /><br /> <li> 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'''. <br /><br /> <li> 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'''. <br /><br /> <li> Click '''Close''' on the next window. </ol> ===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'''. <ol> <li> Open '''MATLAB''' <br /><br /> <li> Click in the '''Commmand Window'''. <br /><br /> <li> Type the following: '''addpath /opt/crc/dynare/dynare-4.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. <br /><br /> Now '''MATLAB''' should be able to find '''dynare'''. </ol> ''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/dynare-4.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=== <ol> <li> Go to the directory where the '''dynare model''' file you are tyring to run is located. <br /><br /> <li> Load the '''MATLAB''' module. <br /><br /> <li> Run '''MATLAB'''. <br /><br /> <li> Tell '''MATLAB''' where to find '''dynare''' using '''Method 2''' listed above. <br /><br /> <li> Type '''dynare dynarefile''' which in this case is '''dynare example1'''. Note that the '''.mod''' extension is not necessary. </ol> ===Scenario 2: Using MATLAB and dynare Interactively WITH the GUI=== <ol> <li> Run '''MATLAB'''. <br /><br /> <li> Tell '''MATLAB''' where to find '''dynare''' using '''ANY''' of the methods listed above. <br /><br /> <li> 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'''. <br /><br /> Type '''dynare dynarefile''' which in this case is '''dynare example1'''. Note that the '''.mod''' extension is not necessary. </ol> ===Scenario 3: Using MATLAB and dynare With the Scheduler=== <ol> <li> 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'''. <br /><br /> <li> 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'''. <br /><br /> <li> Make sure that the '''MATLAB module''' is going to be loaded by having '''module load matlab''' in the submission script. <br /><br /> <li> 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. <br /><br /> <li> Save the submission script, and submit your job by typing in the terminal '''qsub submissionscript''' which is '''qsub submit.sh''' in this example. <br /><br /> <li> Congratulations! '''MATLAB''' should now be running the '''dynare model''' through the scheduler. </ol> <br /> The following is the file that was created on '''Step 2'''. <br /><br /> <pre> addpath /opt/crc/dynare/dynare-4.1.1/matlab dynare example1 </pre> <br /> The following is a sample submission script on running '''MATLAB''' with '''dynare''' through the scheduler. <br /><br /> <pre> #!/bin/csh #$ -M firstname.lastname@example.org #$ -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 </pre> ==Useful Options== <pre> </pre> ==Further Information== See the official website: [http://http://www.dynare.org/ Dynare] Return to DYNARE. Retrieved from "https://wiki.crc.nd.edu/w/index.php/DYNARE"