Version 4 (modified by jeroens, 9 years ago) (diff)

--

Run Ecosim via Console Application

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.

This tutorial will extend the EweConsoleAppExample tutorial.

  1. Load the EweConsoleAppExample project and ensure it runs.
  1. Before the line where the model is closed, insert the following code to load and run the first available Ecosim Scenario:

        core.LoadEcosimScenario(1)
        core.RunEcoSim(AddressOf EcosimResultsHandler)


  1. You have just told Ecosim to run, calling to a subroutine EcosimResultsHandler for every time step. This subroutine does not exist yet, and you will need to create it for Ecosim to be able to execute. Add the following subroutine to the module EwE7:

 
    Private Sub EcosimResultsHandler(ByVal iTime As Long, ByVal EcoSimResults As cEcoSimResults)
        System.Console.WriteLine("Time Step = " & iTime.ToString & _
                                 "; Biomass of group 1 = " & EcoSimResults.Biomass(1).ToString & vbCrLf)
    End Sub


  1. Hit F5 or in the menu, Debug>Start Debugging. You should get the following output.
  Time Step = 320; Biomass of group 1 = 0.993543
  Time Step = 321; Biomass of group 1 = 0.9935352
  Time Step = 322; Biomass of group 1 = 0.9935276
  Time Step = 323; Biomass of group 1 = 0.99352
  Time Step = 324; Biomass of group 1 = 0.9935125
  Press a key to exit

You can run the code by loading the EweConsoleAppExample tutorial, and overwrite its file EwE7.vb with the code file found at the bottom of this page.

Attachments