APSIMInitiative / APSIM710

APSIM
https://www.apsim.info
30 stars 47 forks source link

Cannot report variables in Structure.cs #1478

Closed ApsimBot closed 5 years ago

ApsimBot commented 5 years ago

Legacy Bug ID: 2049 Author: Bangyou Bangyou Zheng Date: 2015-03-20 12:10:01 +0000 UTC

I am testing WheatPMFtest.apsimx under Tests\WheatPMFPrototype. Some variables cannot report in Sturcture.cs, e.g. MainStemNodeAppearanceRate. It seems to relate with deep copy variables in Structure.cs

 

 

The error message is:

 

n exception of type 'System.Exception' occurred in Model.exe but was not handled in user code

 

Additional information: ERROR in file: C:\Users\zhe00a\Documents\Working\04-Software\032-ApsimX\Tests\WheatPMFPrototype\WheatPMFtest.apsimx

 

Simulation name: PMFWheatTestBase

 

Unable to find assembly 'bamk2cod, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

 

  at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()

 

  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)

 

  at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)

 

  at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)

 

  at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)

 

  at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()

 

  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)

 

  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)

 

  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)

 

  at Utility.Reflection.BinaryDeserialise(Stream stream) in c:\Users\zhe00a\Documents\Working\04-Software\032-ApsimX\Utility\Reflection.cs:line 389

 

  at Utility.Reflection.Clone(Object sourceObj) in c:\Users\zhe00a\Documents\Working\04-Software\032-ApsimX\Utility\Reflection.cs:line 462

 

  at Models.Report.ReportColumn.StoreValue() in c:\Users\zhe00a\Documents\Working\04-Software\032-ApsimX\Models\Report\ReportColumn.cs:line 381

 

  at Models.Report.ReportColumn.OnReportFrequency(Object sender, EventArgs e) in c:\Users\zhe00a\Documents\Working\04-Software\032-ApsimX\Models\Report\ReportColumn.cs:line 366

 

  at System.EventHandler.Invoke(Object sender, EventArgs e)

 

  at Models.Clock.OnDoCommence(Object sender, EventArgs e) in c:\Users\zhe00a\Documents\Working\04-Software\032-ApsimX\Models\Clock.cs:line 212

 

  at Models.Core.Simulation.DoRun(Object sender) in c:\Users\zhe00a\Documents\Working\04-Software\032-ApsimX\Models\Core\Simulation.cs:line 170

 

  at Models.Core.Simulation.Run(Object sender, DoWorkEventArgs e) in c:\Users\zhe00a\Documents\Working\04-Software\032-ApsimX\Models\Core\Simulation.cs:line 95

 

If there is a handler for this exception, the program may be safely continued.
ApsimBot commented 5 years ago

Author: zhe00a Date: 2015-03-20 13:40:00 +0000 UTC

This error is caused by both MainStemPrimordiaNo and MaximumNodeNumber equal to zero for WheatPMFPrototype (May be not real problem for this error). However, I believe there is a logic error in MainStemFinalNodeNumberFunction.

MainStemFinalNodeNumberFunction sets the MaximumMainStemNodeNumber to 0 if FinalLeafNumber is null and Structure.MainStemPrimordiaNo equals to 0. 

MainStemFinalNodeNumberFunction is called before sowing when MainStemPrimordiaNo equals to 0 and don't call again. So the MaximumMainStemNodeNumber always equals to 0 if MainStemFinalNodeNumber is used in model. Then, MainStemPrimordiaNo is the minimum of daily increase of MainStemPrimordiaNo and MaximumNodeNumber. As the MaximumNodeNumber always equals to 0, there is no increase of MainStemPrimordiaNo (=0).

May change the default values of MaximumMainStemNodeNumber to a big value to fix it (L25 in MainStemFinalNodeNumberFunction.cs), but need to daily update the MaximumMainStemNodeNumber.
ApsimBot commented 5 years ago

Author: hol353 Date: 2015-04-10 14:55:00 +0000 UTC

Transferred to GitHub