public float probRepro(int index_in) { if (index_in <= speciesAttrs.Number() && index_in > 0) { return((float)probReproduction[index_in - 1]); } //return Establishment_probability_Attributes.get_probability(speciesAttrs[index_in].name, name, PlugIn.ModelCore.TimeSinceStart); throw new Exception("LANDUNIT::probRepro(int)-> Array bounds error."); // return 0.0f; }
static void Main(string[] args) { /* * Variable declaration */ StreamReader infile = new StreamReader("parameterbasic.dat"); gDLLMode = 0; int BDANo = 0; freq = new int[6]; int reclYear = 0; /* * Get DLL mode and read from parameters.dat */ DateTime now = DateTime.Now; gDLLMode = parameters.Read(infile); time_step.gettimestep(parameters.timestep); sites.stocking_x_value = parameters.stocking_x_value; sites.stocking_y_value = parameters.stocking_y_value; sites.stocking_z_value = parameters.stocking_z_value; sites.TimeStep = parameters.timestep; sites.TimeStep_Harvest = parameters.timestep_Harvest; sites.CellSize = parameters.cellSize; for (int x = 0; x < 5; x++) { freq[x] = 1; } if ((gDLLMode & Defines.G_HARVEST) != 0) { freq[5] = 1; } if ((gDLLMode & Defines.G_HARVEST) != 0) { Console.WriteLine("Harvest "); } Console.WriteLine("------------------------------------------------------------"); /* * read in parameters and init PDP */ double[] wAdfGeoTransform = new double[6]; IO.getInput(infile, freq, reMethods, ageMaps, ref pPDP, BDANo, wAdfGeoTransform); /* * End read in parameters & init PDP */ if ((gDLLMode & Defines.G_HARVEST) != 0) { Console.WriteLine("Harvest Dll loaded in..."); Harvest.GlobalFunctions.HarvestPass(sites, speciesAttrs); sites.Harvest70outputdim(); } Console.WriteLine("Finish getting input"); IO.OutputScenario(); IO.initiateOutput_landis70Pro(); snr = sites.numRows(); snc = sites.numColumns(); numSitesActive = sites.numActive(); specAtNum = speciesAttrs.Number(); numbOfIter = parameters.numberOfIterations; sites.GetSeedDispersalProbability(parameters.SeedRainFile, parameters.SeedRainFlag); sites.GetSpeciesGrowthRates(parameters.GrowthFlagFile, parameters.GrowthFlag); sites.GetSpeciesMortalityRates(parameters.MortalityFile, parameters.MortalityFlag); sites.GetVolumeRead(parameters.VolumeFile, parameters.VolumeFlag); initiateRDofSite_Landis70(); if (reclYear != 0) { int local_num = reclYear / sites.TimeStep; reclass3.reclassify(reclYear, ageMaps); IO.putOutput(local_num, local_num, freq); IO.putOutput_Landis70Pro(local_num, local_num, freq); IO.putOutput_AgeDistStat(local_num); Console.Write("Ending Landispro Succession.\n"); } else { IO.putOutput(0, 0, freq); IO.putOutput_Landis70Pro(0, 0, freq); IO.putOutput_AgeDistStat(0); } if (parameters.randSeed == 0) //random { DateTime startTime = new DateTime(1970, 1, 1); parameters.randSeed = (int)Convert.ToUInt32(Math.Abs((DateTime.Now - startTime).TotalSeconds)); } system1.fseed(parameters.randSeed); Console.WriteLine("parameters.randSeed = {0}", parameters.randSeed); fpforTimeBU_name = parameters.outputDir + "/Running_Time_Stat.txt"; fpLogFileSEC_name = parameters.outputDir + "/SECLog.txt"; var now2 = DateTime.Now; Console.WriteLine("\nFinish the initilization at {0}", now2); var ltimeDiff = now2 - now; Console.Write("it took {0} seconds\n", ltimeDiff); landUnits.initiateVariableVector(parameters.numberOfIterations, parameters.timestep, (uint)specAtNum, parameters.flagforSECFile); using (fpforTimeBU = new StreamWriter(fpforTimeBU_name)) { fpforTimeBU.Write("Initilization took: {0} seconds\n", ltimeDiff); } //Simulation loops//////////////////////////////////////////////// for (int i = 1; i <= numbOfIter * sites.TimeStep; i++) { if (i % sites.TimeStep == 0) { if (parameters.flagforSECFile == 3) { int index = i / sites.TimeStep - 1; if (index == 0) { SEC_landtypefiles.Clear(); SEC_gisfiles.Clear(); if (index < gl_land_attrs.year_arr.Count) { Console.Write("\nEnvironment parameter Updated.\n"); string SECfileMapGIS = gl_land_attrs.Get_new_landtype_map(index); parameters.landImgMapFile = SECfileMapGIS; Console.WriteLine("\nEnvironment map Updated."); Landunit SECLog_use = landUnits.first(); int ii_count = 0; using (StreamWriter fpLogFileSEC = new StreamWriter(fpLogFileSEC_name)) { fpLogFileSEC.Write("Year: {0}\n", i); for (; ii_count < landUnits.Number(); ii_count++) { fpLogFileSEC.Write("Landtype{0}:\n", ii_count); for (int jj_count = 1; jj_count <= specAtNum; jj_count++) { fpLogFileSEC.Write("spec{0}: {1:N6}, ", jj_count, SECLog_use.probRepro(jj_count)); } SECLog_use = landUnits.next(); fpLogFileSEC.Write("\n"); } } } } if (index > 0) { if (index < SEC_landtypefiles.Count) { parameters.landImgMapFile = gl_land_attrs.Get_new_landtype_map(index); Console.WriteLine("\nEnvironment parameter Updated."); Console.WriteLine("\nEnvironment map Updated."); Landunit SECLog_use = landUnits.first(); using (StreamWriter fpLogFileSEC = new StreamWriter(fpLogFileSEC_name)) { fpLogFileSEC.Write("Year: {0}\n", i); int ii_count = 0; for (; ii_count < landUnits.Number(); ii_count++) { fpLogFileSEC.Write("Landtype{0}:\n", ii_count); for (int jj_count = 1; jj_count <= specAtNum; jj_count++) { fpLogFileSEC.Write("spec{0}: {1:N6}, ", jj_count, SECLog_use.probRepro(jj_count)); } SECLog_use = landUnits.next(); fpLogFileSEC.Write("\n"); } } } } } }//end if if ((gDLLMode & Defines.G_HARVEST) != 0 && i % sites.TimeStep_Harvest == 0) { Harvest.GlobalFunctions.HarvestPassCurrentDecade(i); //Global Function for (int r = 1; r <= snr; r++) { for (int c = 1; c <= snc; c++) { Harvest.GlobalFunctions.setUpdateFlags(r, c); //Global Function } } } Console.WriteLine("Processing succession at Year {0}", i); singularLandisIteration(i, pPDP, wAdfGeoTransform); int i_d_timestep = i / sites.TimeStep; if (i % sites.TimeStep == 0 || i == numbOfIter * sites.TimeStep) { int[] frequency = new int[6] { 1, 1, 1, 1, 1, 1 }; if (i % (sites.TimeStep * freq[0]) == 0 && i_d_timestep <= numbOfIter) { IO.putOutput_Landis70Pro(0, i_d_timestep, freq); } if (i == sites.TimeStep * numbOfIter) { IO.putOutput_Landis70Pro(0, numbOfIter, frequency); } if (i % (sites.TimeStep * freq[4]) == 0 && i_d_timestep <= numbOfIter) { IO.putOutput(0, i_d_timestep, freq); } if (i == sites.TimeStep * numbOfIter) { IO.putOutput(0, numbOfIter, frequency); } IO.putOutput_AgeDistStat(i_d_timestep); } } //Simulation loops end///////////////////////////////////////////////// Console.WriteLine("\n\nDebug finish!"); Console.ReadLine(); }