User Guide 024

From CIRPwiki
Revision as of 21:16, 8 May 2015 by Rdchldlj (talk | contribs)
Jump to navigation Jump to search

13 Appendix C: Matlab Scripting

Scipting refers to the automation of running multiple CMS runs with dif-ferent parameters, without manually having to create and edit each alternative. The scripting process can include the following steps:

1. Setting up alternatives
2. Creating batch file
3. Plotting and analyzing results

Scripting can be done using a variety of software programs. The examples shown here were written in Matlab because it is widely used, easy to read and convenient for plotting and analyzing results.

Setting Up Alternatives

‎In this example, 4 cases or alternatives (Figure 5.11.1) are set up using the Matlab script below. The script copies the base setup files into subfolders and then modifies specific CMS-Flow cards in the *.cmcards file. The set-tings for each case are setup using a structure variable with field names corresponding to each CMS-Flow card (e.g. TIME_SERIES_INCREMENT). Separating each case into its own subfolder keeps the input and output separate and also allows for the different cases to be run at the same time.

File:Fig d-1.png

Figure D-1. Example of scripting showing the files used.


matlab example

The script above requires the subroutine below.

matlab script

Creating a Batch File

Although it is possible to launch CMS from Matlab a batch file is prefera-ble to use a batch file because it allows running all of the cases without opening Matlab.

matlab script

The following text shows what the resulting batch file (*.bat) looks like

example

To run the batch file, simply double click on the file and each case will launch separately in its own MS-DOS window.

Plotting

The following example reads the Observation Point time series output file (*_eta.txt) and plots the 3rd column corresponding to the second observation point.

example