LANDIS-II-Foundation / Extension-Biomass-Succession

Biomass-based succession extension for LANDIS-II
https://sites.google.com/site/landismodel/extensions/biomass-succession
Apache License 2.0
4 stars 9 forks source link

Object reference not set to an instance of an object #31

Closed glaroc closed 4 years ago

glaroc commented 4 years ago

Hi, I'm not sure if this is a bug or a problem with my setup, but I am trying to run LANDIS on Linux and after running through the first time step after the Cohort reproduction is completed, I get the following error:

Internal error occurred within the program:
  Object reference not set to an instance of an object.

Stack trace:
   at Landis.Extension.Succession.Biomass.ClimateRegionData.SetAllEcoregions_FutureAnnualClimate(Int32 year)
   at Landis.Extension.Succession.Biomass.PlugIn.Run()
   at Landis.Model.Run(String scenarioPath, IUserInterface ui)
   at Landis.App.Main(String[] args) in /home/ubuntu/data/Core-Model-v7-LINUX/Tool-Console/src/App.cs:line 98

I'm not sure how to go about solving this.

rmscheller commented 4 years ago

Guillaume, I haven't seen this one before. I would guess there's a missing ecoregion in your climate input.

glaroc commented 4 years ago

@rmscheller I just tried it on a Windows computer with the same script and it's running without issues. So this seems to be a bug specific to Linux.

glaroc commented 4 years ago

The problem seems to be with this commit: https://github.com/LANDIS-II-Foundation/Extension-Biomass-Succession/commit/88f4f6f5dfbe45827dcf322044d19adef138110e

If I checkout the version before this commit, the model runs fine on Linux. I suspect the problem has nothing to do with Linux, but with this commit, which I assume was made after the latest version compiled for Windows.

Klemet commented 4 years ago

Hello, Mr Scheller.

I think that I identified the problem. The problem seem to comes from the addition of the following line :

        if (Timestep > 0)
            ClimateRegionData.SetAllEcoregions_FutureAnnualClimate(ModelCore.CurrentTime);

...in the "Run" function of the extension. It forces the extension to use data from the ClimateConfigFile. However, if the user haven't provided this parameter (because he/she doesn't have a ClimateConfigFile), the objects used by this function are not initialized beforehand, resulting in the error.

I used the examples files of the extension to try; if I nullify the ClimateConfigFile parameter, the bug happen. If I restore it, the bug is gone. I imagine that Guillaume is having this problem because of this issue, and that it has indeed nothing to do with Linux.

I recommand that a condition is put that this function is used only if a ClimateConfigFile parameter has been given by the user. It should solve the issue, I believe.

rmscheller commented 4 years ago

Clement, Please test the latest version. Thanks, Rob

Klemet commented 4 years ago

Just tested at the instant, it seems to be fixed ! Thank you : ) !