| 1 | = Run Ecosim via Console Application = |
| 2 | |
| 3 | This tutorial will guide you through how to make an console application that would run Ecosim and Ecospace. You can extend these to make applications such as monte carlos routines, or create/modify multiple databases. |
| 4 | |
| 5 | This tutorial will extend the EweConsoleAppExample tutorial. |
| 6 | |
| 7 | 1. Follow EweConsoleAppExample and ensure it runs. |
| 8 | |
| 9 | 2. After step (5) (Line 21 = 'Console.!WriteLine...'), add the following code to Load an Ecosim Scenario and run Ecosim with a delegate (name of a function that should be called at the end of every timestep). |
| 10 | |
| 11 | {{{ |
| 12 | |
| 13 | core.LoadEcosimScenario(1) ' (6) Loads an ecosim scenario |
| 14 | core.RunEcoSim(AddressOf EcosimResultsHandler) ' (7) Runs Ecosim with delegate |
| 15 | }}} |
| 16 | |
| 17 | 3. Add the following code after the sub routine {{{ End Sub }}} which is the function that you defined in step (7). The following sub routine will print the biomass of group 1 at every timestep. |
| 18 | |
| 19 | {{{ |
| 20 | |
| 21 | ' Ecosim delegate - a sub function/subroutine that is |
| 22 | ' called at the end of every timestep. |
| 23 | ' One would obtain the results from the results object. |
| 24 | Private Sub EcosimResultsHandler(ByVal iTime As Long, ByVal EcoSimResults As cEcoSimResults) |
| 25 | System.Console.WriteLine("Time Step = " & iTime.ToString & _ |
| 26 | "; Biomass of group 1 = " & EcoSimResults.Biomass(1).ToString & vbCrLf) |
| 27 | End Sub |
| 28 | }}} |
| 29 | |
| 30 | 4. Hit F5 or in the menu, Debug>Start Debugging. You should get the following output. |
| 31 | |
| 32 | {{{ |
| 33 | Time Step = 320; Biomass of group 1 = 0.993543 |
| 34 | Time Step = 321; Biomass of group 1 = 0.9935352 |
| 35 | Time Step = 322; Biomass of group 1 = 0.9935276 |
| 36 | Time Step = 323; Biomass of group 1 = 0.99352 |
| 37 | Time Step = 324; Biomass of group 1 = 0.9935125 |
| 38 | Press a key to exit |
| 39 | }}} |
| 40 | |
| 41 | The .vb file can be found at the bottom of this page. Simply replace this file with the EwE7.vb found in the EweConsoleAppExample tutorial. |