File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ALMaSS_CmdLine.cpp File Reference
#include "assert.h"
#include <cstdlib>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <iostream>
#include <fstream>
#include <time.h>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include "../BatchALMaSS/ALMaSS_Setup.h"
#include "../ALMaSSDefines.h"
#include "../Landscape/ls.h"
#include "../BatchALMaSS/MovementMap.h"
#include "../BatchALMaSS/BinaryMapBase.h"
#include "../BatchALMaSS/PopulationManager.h"
#include "../Beetles/Beetle_BaseClasses.h"
#include "../Beetles/PoecilusCupreus_All.h"
#include "../Beetles/Ladybird_All.h"
#include "../Beetles/Bembidion_All.h"
#include "../Vole/GeneticMaterial.h"
#include "../Skylark/skylarks_all.h"
#include "../Partridge/Partridge_All.h"
#include "../Partridge/Partridge_Population_Manager.h"
#include "../Vole/vole_all.h"
#include "../Vole/VolePopulationManager.h"
#include "../Vole/Predators.h"
#include "../Hare/Hare_All.h"
#include "../Spiders/Spider_BaseClasses.h"
#include "../Spiders/Erigone.h"
#include "../Spiders/Erigone_Population_Manager.h"
#include "../Spiders/Oedothorax.h"
#include "../Spiders/Oedothorax_Population_Manager.h"
#include "../GooseManagement/GooseMemoryMap.h"
#include "../GooseManagement/Goose_Base.h"
#include "../BatchALMaSS/CurveClasses.h"
#include "../People/Hunters/Hunters_all.h"
#include "../GooseManagement/Goose_Population_Manager.h"
#include "../RoeDeer/Roe_all.h"
#include "../RoeDeer/Roe_pop_manager.h"
#include "../Rabbit/Rabbit.h"
#include "../Rabbit/Rabbit_Population_Manager.h"
#include "../Newt/Newt.h"
#include "../Newt/Newt_Population_Manager.h"
#include "../Osmia/Osmia.h"
#include "../Osmia/Osmia_Population_Manager.h"
#include "../HoneyBee/HoneyBee.h"
#include "../HoneyBee/HoneyBee_Colony.h"
#include "../SubPopulation/SubPopulation.h"
#include "../SubPopulation/SubPopulation_Population_Manager.h"
#include "../OliveMoth/OliveMoth.h"
#include "../OliveMoth/OliveMoth_Population_Manager.h"
#include "../Lacewing/Lacewing.h"
#include "../Lacewing/Lacewing_Population_Manager.h"
#include "../Aphid/Aphid.h"
#include "../Aphid/Aphid_Population_Manager.h"
#include "../Bombus/Bombus.h"
#include "../Bombus/Bombus_Population_Manager.h"
#include "../People/Hunters/Disturbers_All.h"
#include "../Common/shared.h"

Macros

#define _CRT_SECURE_NO_DEPRECATE
 

Functions

void RunTheSim ()
 
void CloseDownSim ()
 
bool ReadBatchINI (const char *filename)
 
void SetOutputFiles ()
 
void GetProbeInput_ini (std::shared_ptr< Population_Manager_Base >, std::string filename)
 
bool CreatePopulationManager ()
 
LandscapeCreateLandscape ()
 
void delay (int secs)
 
int main (int argc, char *argv[])
 

Variables

const double g_randmaxp = RAND_MAX + 1.0
 
static CfgInt cfg_DayInMonth ("PRB_DAYINMONTH", CFG_CUSTOM, 1)
 
static CfgInt cfg_DisturbersNo ("DISTURBERS_NO", CFG_CUSTOM, 1, 0, 1000)
 
static CfgBool cfg_UseEasyPop ("VOLE_USEEASYPOP", CFG_CUSTOM, false)
 
static CfgBool cfg_VoleCatastrophe_on ("VOLE_CATASTROPHE_ON", CFG_CUSTOM, false)
 
static CfgInt cfg_VoleCatastrophe_interval ("VOLE_CATASTROPHE_I", CFG_CUSTOM, 365 *5)
 
static CfgInt cfg_VoleCatastrophe_mortality ("VOLE_CATASTROPHE_M", CFG_CUSTOM, 90)
 
CfgStr cfg_IniFileName ("INI_FILE", CFG_CUSTOM, "BatchALMaSS.ini")
 
CfgStr cfg_AORProbeName ("AOR_PROBE_NAME", CFG_CUSTOM, "AOR_Probe.txt")
 
CfgStr cfg_ProbeName ("PROBE_NAME", CFG_CUSTOM, "Probe.res")
 
CfgBool cfg_OldProbeNames ("OLDSTYLEPROBENAMES", CFG_CUSTOM, true)
 
CfgBool cfg_dumpvegjan
 
CfgStr cfg_dumpvegjanfile
 
CfgBool cfg_dumpvegjune
 
CfgStr cfg_dumpvegjunefile
 
static CfgInt cfg_tracelevel ("G_TRACELEVEL", CFG_CUSTOM, 4)
 
CfgBool cfg_AorOutput_used
 
PopulationManagerList g_PopulationManagerList
 
CfgInt cfg_LadybirdAphidPreySpecies
 The number of aphid species in the simulation. More...
 
CfgStr cfg_AphidSpeciesName
 This variable decides which aphid species to run. The default one is the English grain aphid. More...
 
CfgInt cfg_LadybirdAphidPreyIndex
 The aphid species name. More...
 
Landscapeg_ALandscape
 
std::shared_ptr< Population_Manager_Baseg_AManager
 
std::shared_ptr< Hunter_Population_Manager > g_Hunter_Population_Manager
 
std::shared_ptr< Disturber_Population_Manager > g_Disturber_Population_Manager
 
std::shared_ptr< TPredator_Population_Managerg_PredatorManager
 
int g_torun
 
char * g_files [100]
 
char * g_Predfiles [100]
 
char g_ResultsDir [255]
 
char g_PredResultsDir [255]
 
int g_time
 
int g_Year
 
int g_Steps
 
int g_NoProbes
 
unsigned g_NoOfPredProbes
 
ALMaSS_MathFuncs g_AlmassMathFuncs
 
TTypesOfPopulation g_Species
 

Macro Definition Documentation

◆ _CRT_SECURE_NO_DEPRECATE

#define _CRT_SECURE_NO_DEPRECATE

Function Documentation

◆ CloseDownSim()

void CloseDownSim ( )
695  {
696  if (g_AManager)
697  {
699  // Close the probe file
700  if (g_AManager->TheProbe[0] != NULL) g_AManager->TheProbe[0]->CloseFile();
701  // delete all probes
702  for (int i = 0; i < g_NoProbes; i++) delete g_AManager->TheProbe[i];
703  }
704  /*
705  * the following delete statements will all be removed once we move to smart pointers entirely
706  * For now, we can remove the tests, since removing a null pointer has no effect
707  * */
708 
709  delete g_ALandscape;
710  delete g_msg;
711  delete g_crops;
712  delete g_letype;
713  delete g_weather;
714  delete g_date;
715  delete g_pest;
716  delete g_nectarpollen;
717 
718  for ( int NProbes = 0; NProbes < g_NoProbes; NProbes++ ) {
719  delete [] g_files[NProbes];
720  }
721  for ( int NProbes = 0; NProbes < ( int )g_NoOfPredProbes; NProbes++ ) {
722  delete [] g_Predfiles[NProbes];
723  }
724 }

References g_ALandscape, g_AManager, g_crops, g_date, g_files, g_letype, g_msg, g_nectarpollen, g_NoOfPredProbes, g_NoProbes, g_pest, g_Predfiles, g_weather, and Landscape::SimulationClosingActions().

Referenced by main().

◆ CreateLandscape()

Landscape * CreateLandscape ( )
791  {
792  g_ALandscape = new Landscape();
793  return g_ALandscape;
794 }

References g_ALandscape.

◆ CreatePopulationManager()

bool CreatePopulationManager ( )
328  {
329  // SET UP THE ANIMAL POPULATION
330  // THE LANDSCAPE MUST BE SETUP BEFORE THE CALL HERE
331 
332  if ( g_Species == TOP_NoSpecies ) {
333  g_AManager = std::make_shared<None_Population_Manager>(g_ALandscape);
334  // Do not set in g_PopulationManagerList
335  }
336  else if ( g_Species == TOP_Skylark ) {
337  omp_set_num_threads(1);
338  g_AManager = std::make_shared<Skylark_Population_Manager>(g_ALandscape);
340  std::static_pointer_cast<Skylark_Population_Manager>(g_AManager)->OpenTheBreedingPairsProbe();
341  std::static_pointer_cast<Skylark_Population_Manager>(g_AManager)->OpenTheBreedingSuccessProbe();
342  std::static_pointer_cast<Skylark_Population_Manager>(g_AManager)->OpenTheFledgelingProbe();
343  }
344  else if ( g_Species == TOP_Vole ) {
345  omp_set_num_threads(1);
346  g_AManager = std::make_shared<Vole_Population_Manager>(g_ALandscape);
348  g_PredatorManager = std::make_shared<TPredator_Population_Manager> ( g_ALandscape, static_cast<Vole_Population_Manager*>(g_AManager.get()) );
349  g_PredatorManager->SetNoProbesAndSpeciesSpecificFunctions( g_NoOfPredProbes);
351  }
352  else if ( g_Species == TOP_Erigone ) {
353  g_AManager = std::make_shared<Erigone_Population_Manager>(g_ALandscape);
355 
356  }
357  else if (g_Species == TOP_Oedothorax) {
358  g_AManager = std::make_shared<Oedothorax_Population_Manager>(g_ALandscape);
360  }
361  else if ( g_Species == TOP_Bembidion ) {
362  g_AManager = std::make_shared<Bembidion_Population_Manager>(g_ALandscape);
364 
365  }
366  else if (g_Species == TOP_PoecilusCupreus) {
367  omp_set_num_threads(1);
368  //std::shared_ptr<AphidsD_Population_Manager> apMan ( new AphidsD_Population_Manager(g_ALandscape));
369  //g_PopulationManagerList.SetPopulation(apMan, TOP_AphidsD);
370  g_AManager = std::make_shared<PoecilusCupreus_Population_Manager>(g_ALandscape);
371  //std::shared_ptr<PoecilusCupreus_Population_Manager> lbMan(new PoecilusCupreus_Population_Manager(g_ALandscape)) ;
372  //lbMan->Init();
373  //g_AManager = lbMan;
375 
376  }
377 else if ( g_Species == TOP_Hare ) { // Hare
378  omp_set_num_threads(1);
379  g_AManager = std::make_shared<THare_Population_Manager>(g_ALandscape);
381 
382  }
383  else if ( g_Species == TOP_Partridge ) {
384  omp_set_num_threads(1);
385  g_AManager = std::make_shared<Partridge_Population_Manager>(g_ALandscape);
387  }
388  else if ( g_Species == TOP_Goose ) {
389  omp_set_num_threads(1);
390  g_AManager = std::make_shared<Goose_Population_Manager>(g_ALandscape);
392  g_Hunter_Population_Manager = std::make_shared<Hunter_Population_Manager>(g_ALandscape);
394  CfgInt cfg_DisturbersSetNo( "DISTURBERS_SETS_NO", CFG_CUSTOM, 1 );
395  if (cfg_DisturbersSetNo.value()>0) {
396  cout << "Disturbers are ON. Initiating." << endl;
397  g_Disturber_Population_Manager = std::make_shared<Disturber_Population_Manager>(cfg_DisturbersNo.value(), g_ALandscape, TOP_Goose);
400  }
401  }
402  else if (g_Species == TOP_RoeDeer)
403  {
404  omp_set_num_threads(1);
405  g_AManager =std::make_shared<RoeDeer_Population_Manager>(g_ALandscape);
407  }
408  else if (g_Species == TOP_Rabbit)
409  {
410  omp_set_num_threads(1);
411  g_AManager = std::make_shared<Rabbit_Population_Manager>(g_ALandscape);
413  }
414  else if (g_Species == TOP_Newt)
415  {
416  omp_set_num_threads(1);
417  g_AManager = std::make_shared<Newt_Population_Manager>(g_ALandscape);
419  }
420  else if (g_Species == TOP_Osmia)
421  {
422  g_AManager = std::make_shared<Osmia_Population_Manager>(g_ALandscape);
424  }
425  else if (g_Species == TOP_ApisRAM)
426  {
427  omp_set_num_threads(1);
428  g_AManager = std::make_shared<HoneyBee_Colony>(g_ALandscape);
430  }
431  else if (g_Species == TOP_OliveMoth)
432  {
433  g_AManager = std::make_shared<OliveMoth_Population_Manager>(g_ALandscape);
435  }
436 
437  else if (g_Species == TOP_Lacewing)
438  {
439  g_AManager = std::make_shared<Lacewing_Population_Manager>(g_ALandscape);
441  }
442 
443  else if (g_Species == TOP_Aphid)
444  {
445  g_AManager = std::make_shared<Aphid_Population_Manager>(g_ALandscape, cfg_AphidSpeciesName.value());
447  }
448 
449  else if (g_Species == TOP_Ladybird)
450  {
451  Aphid_Population_Manager** aphid_manager_ptr;
453  string aphid_species_name_list[4] = {"English grain aphid", "Pea aphid", "Aphis fabae", "Peach potato aphid"};
454  aphid_manager_ptr = new Aphid_Population_Manager*[cfg_LadybirdAphidPreySpecies.value()];
455  for(int i = 0; i < cfg_LadybirdAphidPreySpecies.value(); i++){
456  int aphid_index = 0;
458  aphid_index = cfg_LadybirdAphidPreyIndex.value();
459  }
460  else{
461  aphid_index = i;
462  }
463  cfg_AphidSpeciesName.set(aphid_species_name_list[aphid_index]);
464  std::shared_ptr<Aphid_Population_Manager> apMan ( new Aphid_Population_Manager(g_ALandscape, aphid_species_name_list[aphid_index]));
466  aphid_manager_ptr[i] = apMan.get();
467  }
468  }
469  std::shared_ptr<Ladybird_Population_Manager> lbMan(new Ladybird_Population_Manager(g_ALandscape, 7)) ;
470  g_AManager = lbMan;
473  for(int i = 0; i < cfg_LadybirdAphidPreySpecies.value(); i++){
474  lbMan->SetAphidPopulationManager(aphid_manager_ptr[i]);
475  }
476  delete[] aphid_manager_ptr;
477  }
478  }
479 
480  else if (g_Species == TOP_Bombus)
481  {
482  omp_set_num_threads(1);
483  g_AManager = std::make_shared<Bombus_Population_Manager>(g_ALandscape);
485  }
486 
487  else {
488  g_msg->Warn("Population_Manager::CreatePopulationManager() Unknown species number> ", int(g_Species));
489  exit(0);
490  }
491 
492  g_AManager->SetNoProbesAndSpeciesSpecificFunctions(g_NoProbes);
493  #ifdef __FLOWERTESTING
495  #endif
496  return true;
497 }

References cfg_AphidSpeciesName, CFG_CUSTOM, cfg_DisturbersNo, cfg_LadybirdAphidPreyIndex, cfg_LadybirdAphidPreySpecies, g_ALandscape, g_AManager, g_Disturber_Population_Manager, g_Hunter_Population_Manager, g_msg, g_NoOfPredProbes, g_NoProbes, g_PopulationManagerList, g_PredatorManager, g_Species, CfgStr::set(), PopulationManagerList::SetPopulation(), Landscape::SetSpeciesFunctions(), TOP_Aphid, TOP_ApisRAM, TOP_Bembidion, TOP_Bombus, TOP_Disturbers, TOP_Erigone, TOP_Goose, TOP_Hare, TOP_Hunters, TOP_Lacewing, TOP_Ladybird, TOP_Newt, TOP_NoSpecies, TOP_Oedothorax, TOP_OliveMoth, TOP_Osmia, TOP_Partridge, TOP_PoecilusCupreus, TOP_Predators, TOP_Rabbit, TOP_RoeDeer, TOP_Skylark, TOP_Vole, CfgInt::value(), CfgStr::value(), and MapErrorMsg::Warn().

Referenced by main().

◆ delay()

void delay ( int  secs)
179  {
180  time_t start_time, cur_time;
181  time(&start_time);
182  do
183  {
184  time(&cur_time);
185  } while((cur_time - start_time) < secs);
186 }

◆ GetProbeInput_ini()

void GetProbeInput_ini ( std::shared_ptr< Population_Manager_Base p_PM,
std::string  filename 
)
528  {
529  ofstream * AFile=NULL;
530 
531  string NoProbes_String;
532 
533 
534  NoProbes_String.append(g_ResultsDir);
535 
536  for ( int NProbes = 0; NProbes < g_NoProbes; NProbes++ ) {
537  // Must read the probe from a file
538  p_PM->TheProbe[ NProbes ] = new Probe_Data;
539  p_PM->ProbeFileInput( ( char * ) g_files[ NProbes ], NProbes );
540 
541 
542  NoProbes_String.append(ProbeName);
543  if ( NProbes == 0 ) {
544  AFile = p_PM->TheProbe[ NProbes ]->OpenFile( NoProbes_String );
545  if ( !AFile ) {
546  g_msg->Warn( "BatchALMSS - cannot open Probe File", "" );
547  exit( 1 );
548  }
549  } else
550  p_PM->TheProbe[ NProbes ]->SetFile( AFile );
551  }
552  if ( p_PM->SupplySimulationName() == "Vole Predator" ) {
553  for ( int NProbes = 0; NProbes < ( int )g_NoOfPredProbes; NProbes++ ) {
554  g_PredatorManager->TheProbe[ NProbes ] = new Probe_Data;
555  g_PredatorManager->ProbeFileInput( ( char * ) g_Predfiles[ NProbes ], NProbes );
556  string nme = g_ResultsDir;
557  nme.append("PredProbe");
558  nme.append(to_string(NProbes + 1));
559  nme.append(".res");
560  // strcpy( Nme, g_PredResultsDir );
561  if ( NProbes == 0 ) {
562  AFile = g_PredatorManager->TheProbe[ NProbes ]->OpenFile( nme );
563  if ( !AFile ) {
564  g_ALandscape->Warn( "BatchALMSS - cannot open Probe File", nme );
565  exit( 1 );
566  }
567  } else
568  g_PredatorManager->TheProbe[ NProbes ]->SetFile( AFile );
569  }
570  }
571 
572 }

References g_ALandscape, g_files, g_msg, g_NoOfPredProbes, g_NoProbes, g_PredatorManager, g_Predfiles, g_ResultsDir, Probe_Data::OpenFile(), MapErrorMsg::Warn(), and Landscape::Warn().

Referenced by SetOutputFiles().

◆ main()

int main ( int  argc,
char *  argv[] 
)
210 {
211 #ifdef _DEBUG
212  // Get the current state of the flag
213  // and store it in a temporary variable
214  int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
215 
216  // Turn On (OR) - Keep freed memory blocks in the
217  // heap's linked list and mark them as freed
218  tmpFlag |= _CRTDBG_DELAY_FREE_MEM_DF;
219 
220  // Turn Off (AND) - prevent _CrtCheckMemory from
221  // being called at every allocation request
222  tmpFlag &= ~_CRTDBG_CHECK_ALWAYS_DF;
223  // Set the new state for the flag
224  _CrtSetDbgFlag( tmpFlag );
225 #endif
226 
227 #if defined(_PROFILE)
228  Profiler_Init();
229 #endif
230 
231  Sig_Init();
232 
233  const char* ConfigurationFile;
234  std::string ErrorFileName;
235  switch (argc)
236  {
237  case 3:
238  cout << "Running with config file: " << argv[1] << "\n";
239  ConfigurationFile = argv[1];
240  cout << "Error file: " << argv[2] << "\n";
241  ErrorFileName = argv[2];
242  break;
243  case 2:
244  cout << "Running with config file: " << argv[1] << "\n";
245  ConfigurationFile = argv[1];
246  ErrorFileName = "ErrorFile.txt";
247  break;
248  default:
249  ConfigurationFile = "TIALMaSSConfig.cfg";
250  ErrorFileName = "ErrorFile.txt";
251  break;
252 
253  }
254 
255  // Must come first. Used by the configurator below.
256  g_msg = CreateErrorMsg();
257  g_msg->SetFilename(ErrorFileName);
259  g_cfg->ReadSymbols(ConfigurationFile);
260  // Configurator instantiation is automatic.
262 
263  //g_cfg->DumpAllSymbolsAndExit( "allsymbols.cfg" );
264  // Read the BatchALMaSS.ini to be sure g_Species is set before its needed
266  char ch;
267  cout << "Problem with ini file";
268  cin >> ch;
269  }
270 
272 
274  cout << "Created Calendar Object" << endl;
275 
277  cout << "Created Weather Object " << endl;
278 
280  cout << "Created LE_TypeClass Object" << endl;
281 
283  cout << "Created PlantGrowthData Object " << endl;
284 
286  cout << "Created PollenNectarDevelopmentData Object" << endl;
287  cout << "Creating Landscape Object ..." << endl;
288 
289  g_ALandscape = new Landscape();
290  cout << "Landscape Object Done" << endl;
291 
292  /* Now latitude and longitude given, or using DK as default. Calculate daylength */
294 
296  cout << "Created Pesticide Object" << endl;
297 
298 
299 
302  return false;
303  else
304  if (g_Species != -1)
305  {
306  cout << "Population Manager Created" << endl; // Now got to get the probe files read in
307  }
308  /* Landscape module is still operating with raw pointers (therefore we give the reference to g_PopulationManagerList):
309  * this will be changed in the next stage of operation
310  * However the pointers inside the g_PopulationManagerList are smart, this is not a problem, since all reference operations on the
311  * smart pointers are the same as on the raw ones
312  * */
313 
315  SetOutputFiles();
316  // Ready to go
317  RunTheSim();
318  CloseDownSim();
319 
320 #if defined(_PROFILE)
321  Profiler_End();
322 #endif
323 
324  return 0;
325 }

References cfg_IniFileName, CloseDownSim(), CreateCalendar(), CreateConfigurator(), Calendar::CreateDaylength(), CreateErrorMsg(), CreateLETypeClass(), CreatePesticide(), CreatePlantGrowthData(), CreatePollenNectarDevelopmentData(), CreatePopulationManager(), CreateWeather(), g_ALandscape, g_cfg, g_crops, g_date, g_init_random_seed_fnc(), g_letype, g_msg, g_nectarpollen, g_pest, g_PopulationManagerList, g_Species, g_weather, ReadBatchINI(), Landscape::RunHiddenYear(), RunTheSim(), MapErrorMsg::SetFilename(), SetOutputFiles(), Landscape::SetThePopManagerList(), MapErrorMsg::SetWarnLevel(), Landscape::SupplyLatitude(), Landscape::SupplyLongitude(), Landscape::SupplyTimezone(), CfgStr::value(), and WARN_MSG.

◆ ReadBatchINI()

bool ReadBatchINI ( const char *  filename)
575  {
576  // Must read the TIBatch.INI
577  // Read the INI file
578  FILE * Fi = NULL;
579  char answer = 'X';
580  std::cout<<"Batch INI file: "<<filename<<endl;
581  Fi=fopen(filename, "r" );
582  while ( Fi==NULL ) {
583  // Issue and error warning
584  cout << "INI File Missing: ";
585  cout << filename << endl;
586  cout << "Try Again?";
587  cin >> answer;
588  if ( answer != 'Y' ) exit(0);
589  Fi = fopen(filename, "r" );
590  }
591  char Data[ 255 ];
592  fscanf( Fi, "%d\r", & g_NoProbes );
593  for ( int i = 0; i < g_NoProbes; i++ ) {
594  fscanf( Fi, "%s\r", Data);
595  g_files[ i ] = new char[ 255 ];
596  strcpy( g_files[ i ], Data );
597  }
598  fscanf( Fi, "%s\r", Data );
599  strcpy( g_ResultsDir, Data );
600  fscanf( Fi, "%d\r", & g_torun );
601  g_torun *= 365; // the number of years and multiplied by 365 to get days
602  fscanf( Fi, "%d\r", & g_Species );
603  fclose( Fi );
604  // Read the PredBatch.INI file
605  if ( g_Species == 1) {
606  FILE * Fi2 = NULL;
607  answer = 'X';
608  while ( !Fi2 ) {
609  Fi2=fopen("VoleToxPreds.ini", "r" );
610  if ( !Fi2 ) {
611  // Issue and error warning
612  cout << "Predator Batch File Missing: VoleToxPreds.INI";
613  cout << "Try Again (Y/N) ? ";
614  cin >> answer;
615  if ( answer != 'Y' ) return false;
616  }
617  }
618  char Data2[ 255 ];
619  fscanf( Fi2, "%d\r", & g_NoOfPredProbes );
620  for ( int i = 0; i < ( int )g_NoOfPredProbes; i++ ) {
621  fscanf( Fi2, "%s\r", Data2 );
622  g_Predfiles[ i ] = new char[ 255 ];
623  strcpy( g_Predfiles[ i ], Data2 );
624  }
625  fscanf( Fi2, "%s\r", Data2 );
626  strcpy( g_PredResultsDir, Data2 );
627  fclose( Fi2 );
628  }
629  switch (g_Species) {
630  case TOP_NoSpecies:
631  cout << "Running Landscape only, animal species not selected" << endl;
632  break;
633  case TOP_Skylark:
634  cout << "Running Skylarks" << endl;
635  break;
636  case TOP_Vole:
637  cout << "Running Voles" << endl;
638  break;
639  case TOP_Erigone:
640  cout << "Running Erigone" << endl;
641  break;
642  case TOP_Bembidion:
643  cout << "Running Bembidon" << endl;
644  break;
645  case TOP_PoecilusCupreus:
646  cout << "Running Poecilus" << endl;
647  break;
648  case TOP_Hare:
649  cout << "Running Hares" << endl;
650  break;
651  case TOP_Partridge:
652  cout << "Running Partridges" << endl;
653  break;
654  case TOP_Goose:
655  cout << "Running Goose Management" << endl;
656  break;
657  case TOP_RoeDeer:
658  cout << "Running Roe Deer" << endl;
659  break;
660  case TOP_Rabbit:
661  cout << "Running Rabbits" << endl;
662  break;
663  case TOP_Newt:
664  cout << "Running Newts" << endl;
665  break;
666  case TOP_Osmia:
667  cout << "Running Osmia" << endl;
668  break;
669  case TOP_ApisRAM:
670  cout <<"Running Honey Bee" <<endl;
671  break;
672  case TOP_Oedothorax:
673  cout << "Running Oedothorax" << endl;
674  break;
675  case TOP_OliveMoth:
676  cout << "Running Olive Moth" << endl;
677  break;
678  case TOP_Lacewing:
679  cout << "Running Lacewing" << endl;
680  break;
681  case TOP_Aphid:
682  cout << "Running Aphid" << endl;
683  break;
684  case TOP_Ladybird:
685  cout << "Running Ladybird" << endl;
686  break;
687  case TOP_Bombus:
688  cout << "Running Bombus" << endl;
689  break;
690  }
691  return true;
692 }

References g_files, g_NoOfPredProbes, g_NoProbes, g_Predfiles, g_PredResultsDir, g_ResultsDir, g_Species, g_torun, TOP_Aphid, TOP_ApisRAM, TOP_Bembidion, TOP_Bombus, TOP_Erigone, TOP_Goose, TOP_Hare, TOP_Lacewing, TOP_Ladybird, TOP_Newt, TOP_NoSpecies, TOP_Oedothorax, TOP_OliveMoth, TOP_Osmia, TOP_Partridge, TOP_PoecilusCupreus, TOP_Rabbit, TOP_RoeDeer, TOP_Skylark, and TOP_Vole.

Referenced by main().

◆ RunTheSim()

void RunTheSim ( )
729 {
730  for (int i = 0; i < g_torun; i++)
731  {
732  Sig_Update();
733 
735  // Update the Date
736  g_time++;
737  int day = g_ALandscape->SupplyDayInMonth();
738  int month = g_ALandscape->SupplyMonth();
739 
740  if ((day == 1) && (month == 1)){
741  g_Year++;
742  cout << "Year; " << g_Year << '\n';
743  }
744  cout << g_time << '\n';
745 
746  if (g_Species == TOP_Vole)
747  g_PredatorManager->Run(1);
748  // if (g_Species== TOP_Ladybird) g_PopulationManagerList.GetPopulation(TOP_AphidsD)->Run(1);
750  {
751  for (int tenmin = 0; tenmin < 144; tenmin++)
752  {
753  for (int p = 0; p < TOP_foobar; p++)
754  {
756  if (popu_num < 1) continue;
757  for (int i = 0; i < popu_num; i++){
758  if (g_PopulationManagerList.GetPopulation(p) != nullptr){
761  }
762  }
763  }
764 
765  if (g_date->TickMinute10())
766  g_date->TickHour();
767  }
768  }
769  else {
770  for (int p = 0; p < TOP_foobar; p++){
772  if (popu_num < 1) continue;
773  for (int i = 0; i < popu_num; i++){
774  if (g_PopulationManagerList.GetPopulation(p, i) != nullptr){
776  }
777  }
778  }
779  }
780  //for 1 day-time step, always 0
781  g_AManager->SetStepCounterInADay(0);
783  char str[255];
784  strcpy(str, g_AManager->SpeciesSpecificReporting(g_Species, g_time));
785  }
787  }
788 }

References Landscape::DumpVegAreaData(), g_ALandscape, g_AManager, g_date, g_PopulationManagerList, g_PredatorManager, g_Species, g_time, g_torun, g_Year, PopulationManagerList::GetPopulation(), PopulationManagerList::GetPopulationManagerNum(), Population_Manager_Base::Run(), Population_Manager_Base::SetStepCounterInADay(), Landscape::SupplyDayInMonth(), Landscape::SupplyMonth(), Calendar::TickHour(), Calendar::TickMinute10(), TOP_Aphid, TOP_ApisRAM, TOP_Bombus, TOP_foobar, TOP_Goose, TOP_OliveMoth, TOP_RoeDeer, TOP_Vole, and Landscape::TurnTheWorld().

Referenced by main().

◆ SetOutputFiles()

void SetOutputFiles ( )
499  {
500  if (cfg_OldProbeNames.value()){
501  // Use the regular naming of the Probe.res and AOR_Probe (from the config)
502  // If there is no PM set there is nothing to report so we only need to cover the case of the only PM
503  for (int i = 0; i<TOP_foobar; i++){
505  if (PM!= nullptr){
506  if (cfg_AorOutput_used.value()) {
507  PM->OpenTheAOROutputProbe(cfg_AORProbeName.value());
508  }
510  }
511  }
512  }
513  else{
514  // We create the probes with naming format of simulationname_Probe.res and simulationname_AOR_Probe.txt
515  for (int i = 0; i<TOP_foobar; i++){
517  if (PM!= nullptr){
518  if (cfg_AorOutput_used.value()) {
519  PM->OpenTheAOROutputProbe(PM->SupplySimulationName() + "_" + cfg_AORProbeName.value());
520  }
521  GetProbeInput_ini(PM, PM->SupplySimulationName()+"_"+cfg_ProbeName.value());
522  }
523 
524  }
525  }
526 }

References cfg_AorOutput_used, cfg_AORProbeName, cfg_OldProbeNames, cfg_ProbeName, g_PopulationManagerList, PopulationManagerList::GetPopulation_smart(), GetProbeInput_ini(), TOP_foobar, CfgBool::value(), and CfgStr::value().

Referenced by main().

Variable Documentation

◆ cfg_AorOutput_used

CfgBool cfg_AorOutput_used

Referenced by SetOutputFiles().

◆ cfg_AORProbeName

CfgStr cfg_AORProbeName("AOR_PROBE_NAME", CFG_CUSTOM, "AOR_Probe.txt")

Referenced by SetOutputFiles().

◆ cfg_AphidSpeciesName

CfgStr cfg_AphidSpeciesName

This variable decides which aphid species to run. The default one is the English grain aphid.

Referenced by CreatePopulationManager().

◆ cfg_DayInMonth

CfgInt cfg_DayInMonth("PRB_DAYINMONTH", CFG_CUSTOM, 1)
static

◆ cfg_DisturbersNo

CfgInt cfg_DisturbersNo("DISTURBERS_NO", CFG_CUSTOM, 1, 0, 1000)
static

Referenced by CreatePopulationManager().

◆ cfg_dumpvegjan

CfgBool cfg_dumpvegjan

◆ cfg_dumpvegjanfile

CfgStr cfg_dumpvegjanfile

◆ cfg_dumpvegjune

CfgBool cfg_dumpvegjune

◆ cfg_dumpvegjunefile

CfgStr cfg_dumpvegjunefile

◆ cfg_IniFileName

CfgStr cfg_IniFileName("INI_FILE", CFG_CUSTOM, "BatchALMaSS.ini")

Referenced by main().

◆ cfg_LadybirdAphidPreyIndex

CfgInt cfg_LadybirdAphidPreyIndex

The aphid species name.

Referenced by CreatePopulationManager().

◆ cfg_LadybirdAphidPreySpecies

CfgInt cfg_LadybirdAphidPreySpecies

The number of aphid species in the simulation.

Referenced by CreatePopulationManager().

◆ cfg_OldProbeNames

CfgBool cfg_OldProbeNames("OLDSTYLEPROBENAMES", CFG_CUSTOM, true)

Referenced by SetOutputFiles().

◆ cfg_ProbeName

CfgStr cfg_ProbeName("PROBE_NAME", CFG_CUSTOM, "Probe.res")

Referenced by SetOutputFiles().

◆ cfg_tracelevel

CfgInt cfg_tracelevel("G_TRACELEVEL", CFG_CUSTOM, 4)
static

◆ cfg_UseEasyPop

CfgBool cfg_UseEasyPop("VOLE_USEEASYPOP", CFG_CUSTOM, false)
static

◆ cfg_VoleCatastrophe_interval

CfgInt cfg_VoleCatastrophe_interval("VOLE_CATASTROPHE_I", CFG_CUSTOM, 365 *5)
static

◆ cfg_VoleCatastrophe_mortality

CfgInt cfg_VoleCatastrophe_mortality("VOLE_CATASTROPHE_M", CFG_CUSTOM, 90)
static

◆ cfg_VoleCatastrophe_on

CfgBool cfg_VoleCatastrophe_on("VOLE_CATASTROPHE_ON", CFG_CUSTOM, false)
static

◆ g_ALandscape

◆ g_AlmassMathFuncs

ALMaSS_MathFuncs g_AlmassMathFuncs

◆ g_AManager

◆ g_Disturber_Population_Manager

std::shared_ptr<Disturber_Population_Manager> g_Disturber_Population_Manager

Referenced by CreatePopulationManager().

◆ g_files

char* g_files[100]

◆ g_Hunter_Population_Manager

std::shared_ptr<Hunter_Population_Manager> g_Hunter_Population_Manager

Referenced by CreatePopulationManager().

◆ g_NoOfPredProbes

unsigned g_NoOfPredProbes

◆ g_NoProbes

◆ g_PopulationManagerList

◆ g_PredatorManager

std::shared_ptr<TPredator_Population_Manager> g_PredatorManager

◆ g_Predfiles

char* g_Predfiles[100]

◆ g_PredResultsDir

char g_PredResultsDir[255]

Referenced by ReadBatchINI().

◆ g_randmaxp

const double g_randmaxp = RAND_MAX + 1.0

◆ g_ResultsDir

char g_ResultsDir[255]

Referenced by GetProbeInput_ini(), and ReadBatchINI().

◆ g_Species

◆ g_Steps

int g_Steps

◆ g_time

int g_time

THESE MUST BE IN THE CONFIGURATION FILES TO OVERRIDE THE DEFAULT BEETLE VALUES

BEETLE_LARVALSTAGESNUM (int) = 4 BEETLE_MAXDAILYMOVEMENT (int) = 500 BEETLE_DEVELOPMENTTHRESHOLDS (array double) = 11.5 13.8 13.6 13.6 13.9 12.9 12.4 0 0 0 BEETLE_DEVELOPMENTCONSTANTS (array double) = 42 22.8 20.4 23.1 38 63.6 151.9 0 0 0

Referenced by RunTheSim().

◆ g_torun

int g_torun

Referenced by ReadBatchINI(), and RunTheSim().

◆ g_Year

int g_Year

Referenced by RunTheSim().

CreatePlantGrowthData
PlantGrowthData * CreatePlantGrowthData()
Definition: Plants.cpp:842
TOP_Skylark
Definition: PopulationManager.h:59
TOP_Newt
Definition: PopulationManager.h:68
CfgStr::set
void set(std::string a_newval)
Definition: Configurator.h:183
TOP_Hunters
Definition: PopulationManager.h:81
Probe_Data::OpenFile
ofstream * OpenFile(const string &Nme)
Definition: PopulationManager.cpp:1666
WARN_MSG
Definition: MapErrorMsg.h:38
cfg_LadybirdAphidPreyIndex
CfgInt cfg_LadybirdAphidPreyIndex
The aphid species name.
Calendar::TickHour
bool TickHour(void)
Definition: Calendar.cpp:178
PopulationManagerList::SetPopulation
void SetPopulation(std::shared_ptr< Population_Manager_Base > p_pm, int a_pt)
Definition: PopulationManager.h:949
g_Hunter_Population_Manager
std::shared_ptr< Hunter_Population_Manager > g_Hunter_Population_Manager
Definition: ALMaSS_CmdLine.cpp:149
TOP_Bombus
Definition: PopulationManager.h:73
CfgStr::value
char * value() const
Definition: Configurator.h:182
TOP_Osmia
Definition: PopulationManager.h:69
Calendar::CreateDaylength
void CreateDaylength(double latitude, double longitude, int timezone, int year=2021)
Definition: Calendar.cpp:66
Landscape::SupplyLongitude
double SupplyLongitude()
Returns m_longitude of the landscape location.
Definition: Landscape.h:607
TOP_ApisRAM
Definition: PopulationManager.h:70
g_date
class Calendar * g_date
Definition: Calendar.cpp:37
Landscape::SupplyLatitude
double SupplyLatitude()
Returns m_latitude of the landscape location.
Definition: Landscape.h:605
cfg_LadybirdAphidPreySpecies
CfgInt cfg_LadybirdAphidPreySpecies
The number of aphid species in the simulation.
TOP_PoecilusCupreus
Definition: PopulationManager.h:78
CreateConfigurator
std::shared_ptr< Configurator > CreateConfigurator()
Definition: Configurator.cpp:1413
Landscape::SupplyTimezone
int SupplyTimezone()
Definition: Landscape.h:583
g_PredatorManager
std::shared_ptr< TPredator_Population_Manager > g_PredatorManager
Definition: ALMaSS_CmdLine.cpp:151
CreateCalendar
Calendar * CreateCalendar()
Definition: Calendar.cpp:230
g_cfg
std::shared_ptr< Configurator > g_cfg
Definition: Configurator.cpp:56
Landscape::SupplyMonth
int SupplyMonth(void)
Passes a request on to the associated Calendar class function, returns m_month + 1 (the calendar mont...
Definition: Landscape.h:2272
MapErrorMsg::SetFilename
void SetFilename(std::string a_warnfile)
Definition: MapErrorMsg.cpp:48
TOP_Goose
Definition: PopulationManager.h:65
CreatePollenNectarDevelopmentData
PollenNectarDevelopmentData * CreatePollenNectarDevelopmentData()
Definition: PollenNectar.cpp:294
g_Species
TTypesOfPopulation g_Species
Definition: PopulationManager.cpp:101
cfg_AorOutput_used
CfgBool cfg_AorOutput_used
CreateErrorMsg
MapErrorMsg * CreateErrorMsg()
Definition: MapErrorMsg.cpp:202
CreateLETypeClass
LE_TypeClass * CreateLETypeClass()
Definition: Elements.cpp:3434
TOP_Bembidion
Definition: PopulationManager.h:62
g_nectarpollen
class PollenNectarDevelopmentData * g_nectarpollen
Definition: Plants.cpp:41
cfg_IniFileName
CfgStr cfg_IniFileName("INI_FILE", CFG_CUSTOM, "BatchALMaSS.ini")
g_ResultsDir
char g_ResultsDir[255]
Definition: ALMaSS_CmdLine.cpp:155
RunTheSim
void RunTheSim()
Definition: ALMaSS_CmdLine.cpp:728
CfgBool::value
bool value() const
Definition: Configurator.h:164
Landscape::TurnTheWorld
void TurnTheWorld(void)
Definition: Landscape.h:1498
Probe_Data
Data structure to hold & output probe data probe data is designed to be used to return the number of ...
Definition: PopulationManager.h:421
Aphid_Population_Manager
The class to handle all Aphid population related matters in the whole landscape.
Definition: Aphid_Population_Manager.h:98
cfg_AphidSpeciesName
CfgStr cfg_AphidSpeciesName
This variable decides which aphid species to run. The default one is the English grain aphid.
TOP_Rabbit
Definition: PopulationManager.h:67
TOP_Aphid
Definition: PopulationManager.h:75
Landscape
The landscape class containing all environmental and topographical data.
Definition: Landscape.h:142
TOP_Partridge
Definition: PopulationManager.h:64
Landscape::RunHiddenYear
void RunHiddenYear()
The function to generate the vector list of pixies for polygons with flower resource.
Definition: Landscape.cpp:2781
Landscape::SupplyDayInMonth
int SupplyDayInMonth(void)
Passes a request on to the associated Calendar class function, returns m_day_in_month
Definition: Landscape.h:2277
TOP_Disturbers
Definition: PopulationManager.h:84
Landscape::SetSpeciesFunctions
void SetSpeciesFunctions(TTypesOfPopulation a_species)
This is the jumping off point for any landscape related species setup, it creates function pointers t...
Definition: Landscape.cpp:7821
Ladybird_Population_Manager
Definition: Ladybird_All.h:386
g_init_random_seed_fnc
void g_init_random_seed_fnc()
Init_random_seed() randomizes the random generator based on the configuration (either fixed seed or r...
Definition: ALMaSS_Random.cpp:407
TOP_Hare
Definition: PopulationManager.h:63
SetOutputFiles
void SetOutputFiles()
Definition: ALMaSS_CmdLine.cpp:499
cfg_AORProbeName
CfgStr cfg_AORProbeName("AOR_PROBE_NAME", CFG_CUSTOM, "AOR_Probe.txt")
CloseDownSim
void CloseDownSim()
Definition: ALMaSS_CmdLine.cpp:695
g_PredResultsDir
char g_PredResultsDir[255]
Definition: ALMaSS_CmdLine.cpp:156
g_Disturber_Population_Manager
std::shared_ptr< Disturber_Population_Manager > g_Disturber_Population_Manager
Definition: ALMaSS_CmdLine.cpp:150
cfg_OldProbeNames
CfgBool cfg_OldProbeNames("OLDSTYLEPROBENAMES", CFG_CUSTOM, true)
CreateWeather
Weather * CreateWeather()
Definition: Weather.cpp:738
g_AManager
std::shared_ptr< Population_Manager_Base > g_AManager
Definition: ALMaSS_CmdLine.cpp:148
TOP_NoSpecies
Definition: PopulationManager.h:58
MapErrorMsg::SetWarnLevel
void SetWarnLevel(MapErrorState a_level)
Definition: MapErrorMsg.cpp:58
MapErrorMsg::Warn
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: MapErrorMsg.cpp:69
TOP_RoeDeer
Definition: PopulationManager.h:66
TOP_foobar
Definition: PopulationManager.h:85
TOP_Predators
Definition: PopulationManager.h:80
CfgInt::value
int value() const
Definition: Configurator.h:116
g_files
char * g_files[100]
Definition: ALMaSS_CmdLine.cpp:153
Population_Manager_Base::SetStepCounterInADay
void SetStepCounterInADay(int a_counter)
Set step counter in a day.
Definition: PopulationManager.h:603
g_PopulationManagerList
PopulationManagerList g_PopulationManagerList
Definition: ALMaSS_CmdLine.cpp:162
g_Year
int g_Year
Definition: ALMaSS_CmdLine.cpp:158
cfg_ProbeName
CfgStr cfg_ProbeName("PROBE_NAME", CFG_CUSTOM, "Probe.res")
TOP_Ladybird
Definition: PopulationManager.h:76
g_weather
class Weather * g_weather
Definition: Weather.cpp:49
g_NoProbes
int g_NoProbes
Definition: ALMaSS_CmdLine.cpp:160
CreatePopulationManager
bool CreatePopulationManager()
Definition: ALMaSS_CmdLine.cpp:328
Landscape::DumpVegAreaData
void DumpVegAreaData(int a_day)
Saves the information on vegetation types and areas.
Definition: Landscape.cpp:7804
g_msg
MapErrorMsg * g_msg
Definition: MapErrorMsg.cpp:41
TOP_Lacewing
Definition: PopulationManager.h:74
GetProbeInput_ini
void GetProbeInput_ini(std::shared_ptr< Population_Manager_Base >, std::string filename)
Definition: ALMaSS_CmdLine.cpp:528
CfgInt
Integer configurator entry class.
Definition: Configurator.h:102
g_NoOfPredProbes
unsigned g_NoOfPredProbes
Definition: ALMaSS_CmdLine.cpp:161
TOP_Vole
Definition: PopulationManager.h:60
PopulationManagerList::GetPopulation_smart
std::shared_ptr< Population_Manager_Base > GetPopulation_smart(int a_pt, int a_index=0)
Definition: PopulationManager.h:966
g_ALandscape
Landscape * g_ALandscape
Definition: ALMaSS_CmdLine.cpp:147
g_time
int g_time
Definition: ALMaSS_CmdLine.cpp:157
CFG_CUSTOM
Definition: Configurator.h:70
ReadBatchINI
bool ReadBatchINI(const char *filename)
Definition: ALMaSS_CmdLine.cpp:575
TOP_Oedothorax
Definition: PopulationManager.h:71
Calendar::TickMinute10
bool TickMinute10(void)
Definition: Calendar.cpp:167
cfg_DisturbersNo
static CfgInt cfg_DisturbersNo("DISTURBERS_NO", CFG_CUSTOM, 1, 0, 1000)
Population_Manager_Base::Run
virtual void Run(int a_NoTSteps)
A place holder for the run function for all population managers, this must be reimplemented in descen...
Definition: PopulationManager.h:575
PopulationManagerList::GetPopulation
Population_Manager_Base * GetPopulation(int a_pt, int a_index=0)
Definition: PopulationManager.h:962
g_letype
class LE_TypeClass * g_letype
Definition: Elements.cpp:806
TOP_OliveMoth
Definition: PopulationManager.h:72
g_torun
int g_torun
Definition: ALMaSS_CmdLine.cpp:152
Landscape::Warn
void Warn(std::string a_msg1, std::string a_msg2)
Wrapper for the g_msg Warn function.
Definition: Landscape.h:2250
PopulationManagerList::GetPopulationManagerNum
int GetPopulationManagerNum(int a_pt)
Returns the number of population manager,.
Definition: PopulationManager.h:957
Landscape::SetThePopManagerList
void SetThePopManagerList(PopulationManagerList *a_ptr)
Set the pointer to the list of active population managers.
Definition: Landscape.h:319
g_Predfiles
char * g_Predfiles[100]
Definition: ALMaSS_CmdLine.cpp:154
TOP_Erigone
Definition: PopulationManager.h:61
g_pest
class Pesticide * g_pest
Definition: Pesticide.cpp:219
g_crops
class PlantGrowthData * g_crops
Definition: Plants.cpp:40
Landscape::SimulationClosingActions
void SimulationClosingActions()
Definition: Landscape.cpp:2934
CreatePesticide
Pesticide * CreatePesticide(Landscape *l)
Definition: Pesticide.cpp:2005