Skip to content

Commit

Permalink
Merge pull request #17 from RangeShifter/cmake
Browse files Browse the repository at this point in the history
Use Cmake
  • Loading branch information
TheoPannetier authored Nov 10, 2023
2 parents 47b1f5b + 3764f7a commit acbbb13
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 64 deletions.
87 changes: 87 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
.gitignore
#README.md

# CodeLite
/.build-debug/
/Debug/
/Release/
/RNG_test/
.codelite/
compile_commands.json
Makefile
.build-release/
build-Release/
*.project
*.workspace
*.mk
*.tags

# Hidden source
/RangeShiftR/src/.*

# Windows files
/RangeShiftR/src/*.dll

# History files
.Rhistory
.Rapp.history

# RStudio files
.Rproj.user/
/RangeShiftR/.Rproj.user/
#/RangeShiftR/RangeShiftR.Rproj
/RangeShiftR/Read-and-delete-me
/RangeShiftR/.Rhistory
#/RangeShiftR/.Rbuildignore

# Session Data files
.RData
tags

# User-specific files
.Ruserdata

# Example code in package build process
*-Ex.R

# Output files from R CMD build
*.tar.gz
/RangeShiftR/src/*.o
/RangeShiftR/src/RangeShiftR.so


# Windows files
/RangeShiftR/src/*.dll

# Output files from R CMD check
/*.Rcheck/

# Output from Rcpp compile.attributes()
#/RangeShiftR/R/RcppExports.R
#/RangeShiftR/src/RcppExports.cpp

# RStudio files
.Rproj.user/

# produced vignettes
vignettes/*.html
vignettes/*.pdf
#/RangeShiftR/man/

# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
.httr-oauth

# knitr and R markdown default cache directories
/*_cache/
/cache/

# Temporary files created by R markdown
*.utf8.md
*.knit.md

# compilation files
*.o

# Visual Studio
.vs/
out/
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Config file for compilation with CMake
# Only relevant for Batch mode, but this file needs to live in the RScore folder

add_library(RScore Species.cpp Cell.cpp Community.cpp FractalGenerator.cpp Genome.cpp Individual.cpp Landscape.cpp Model.cpp Parameters.cpp Patch.cpp Population.cpp RandomCheck.cpp RSrandom.cpp SubCommunity.cpp)

# pass config definitions to compiler
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_compile_definitions(RScore PRIVATE "RSDEBUG" "RSWIN64" "LINUX_CLUSTER")
else() # Windows
target_compile_definitions(RScore PRIVATE "RSDEBUG" "RSWIN64")
endif()
4 changes: 2 additions & 2 deletions Community.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1700,8 +1700,8 @@ Rcpp::IntegerMatrix Community::addYearToPopList(int rep, int yr) { // TODO: def
} else {
pSubComm = (SubCommunity*)subcomm;
pop = pSubComm->getPopStats();
//pop_map_year(ppLand.dimY-1-y,x) = pop.nInds; // use indices like this because matrix gets transposed upon casting it into a raster on R-level
pop_map_year(ppLand.dimY-1-y,x) = pop.nAdults;
pop_map_year(ppLand.dimY-1-y,x) = pop.nInds; // use indices like this because matrix gets transposed upon casting it into a raster on R-level
//pop_map_year(ppLand.dimY-1-y,x) = pop.nAdults;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Community.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ Last updated: 25 June 2021 by Anne-Kathleen Malchow
#include <vector>
#include <algorithm>
using namespace std;
//#if RS_RCPP && !R_CMD
#if RS_RCPP
#include "../Version.h"
//#endif
#endif

//#if !RS_RCPP && R_CMD
//#include "../../Batch/Version.h"
Expand Down
31 changes: 2 additions & 29 deletions Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,10 @@ DEBUGLOG << endl << "RunModel(): generating new landscape ..." << endl;
DEBUGLOG << "RunModel(): finished resetting landscape" << endl << endl;
#endif
pLandscape->generatePatches();
//#if VCL
if (v.viewLand || sim.saveMaps) {
pLandscape->setLandMap();
pLandscape->drawLandscape(rep,0,ppLand.landNum);
}
//#endif
//#if BATCH
// if (sim.saveMaps) {
// pLandscape->drawLandscape(rep,0,ppLand.landNum);
// }
//#endif
#if RSDEBUG
DEBUGLOG << endl << "RunModel(): finished generating patches" << endl;
#endif
Expand Down Expand Up @@ -313,12 +306,8 @@ DEBUGLOG << "RunModel(): completed updating carrying capacity" << endl;
DEBUGLOG << "RunModel(): completed initialisation, rep=" << rep
<< " pSpecies=" << pSpecies << endl;
#endif
#if BATCH
#if RS_RCPP && !R_CMD
#if BATCH && RS_RCPP && !R_CMD
Rcpp::Rcout << "RunModel(): completed initialisation " << endl;
#else
cout << "RunModel(): completed initialisation " << endl;
#endif
#endif

// open a new individuals file for each replicate
Expand Down Expand Up @@ -926,7 +915,7 @@ return errorfolder;
//For outputs and population visualisations pre-reproduction
void PreReproductionOutput(Landscape *pLand,Community *pComm,int rep,int yr,int gen)
{
#if RSDEBUG || VCL
#if RSDEBUG
landParams ppLand = pLand->getLandParams();
#endif
simParams sim = paramsSim->getSim();
Expand Down Expand Up @@ -1341,22 +1330,6 @@ if (dem.stageStruct){
outPar << endl;
}
}
#if VCL
else {
// NOTE: TO PREVENT COMPILING FOR BATCH MODE, THIS CODE NEEDS TO BE INCLUDED IN COMPILER
// CONDITIONAL BLOCK AS SHOWN
// outPar << "Row count: " << frmSpecies->transMatrix->RowCount << endl;
// outPar << "Col count: " << frmSpecies->transMatrix->ColCount << endl;
for (int i = 1; i < frmSpecies->transMatrix->RowCount; i++) {
for (int j = 1; j < frmSpecies->transMatrix->ColCount; j++) {
outPar << frmSpecies->transMatrix->Cells[j][i].ToDouble() << "\t";
}
outPar << endl;
}
}
#endif
outPar << endl;
#endif
*/
Expand Down
18 changes: 9 additions & 9 deletions Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ Last updated: 26 October 2021 by Steve Palmer
#include <sys/types.h>
#include <sys/stat.h>

//#if RS_RCPP && !R_CMD
#if RS_RCPP
#include "../Version.h"
//#endif
#endif

//#if !RS_RCPP && R_CMD
//#include "../../Batch/Version.h"
Expand All @@ -75,12 +75,12 @@ extern ofstream DEBUGLOG;
#if RS_RCPP && !R_CMD
Rcpp::List RunModel(
Landscape*, // pointer to Landscape
int // sequential simulation number (always 0 for VCL version)
int // sequential simulation number
);
#else
int RunModel(
Landscape*, // pointer to Landscape
int // sequential simulation number (always 0 for VCL version)
int // sequential simulation number
);
#endif // RS_RCPP && !R_CMD
bool CheckDirectory(void);
Expand Down Expand Up @@ -125,11 +125,11 @@ extern Community *pComm;
const bool batchMode = true;
extern string landFile;
extern vector <string> hfnames;
extern string habmapname; // see FormLand.cpp (VCL) OR Main.cpp (batch)
extern string patchmapname; // see FormLand.cpp (VCL) OR Main.cpp (batch)
extern string distnmapname; // see FormLand.cpp (VCL) OR Main.cpp (batch)
extern string costmapname; // see FormMove.cpp (VCL) OR Main.cpp (batch)
extern string genfilename; // see FormGenetics.cpp (VCL) OR Main.cpp (batch)
extern string habmapname; // see Main.cpp (batch)
extern string patchmapname; // see Main.cpp (batch)
extern string distnmapname; // see Main.cpp (batch)
extern string costmapname; // see Main.cpp (batch)
extern string genfilename; // see Main.cpp (batch)
extern RSrandom *pRandom;

// these functions to have different version for GUI and batch applications ...
Expand Down
4 changes: 2 additions & 2 deletions Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ Last updated: 25 June 2021 by Steve Palmer
#include <stdlib.h>
#include <vector>
using namespace std;
//#if RS_RCPP && !R_CMD
#if RS_RCPP
#include "../Version.h"
//#endif
#endif

//#if !RS_RCPP && R_CMD
//#include "../../Batch/Version.h"
Expand Down
4 changes: 2 additions & 2 deletions Patch.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ Last updated: 25 June 2021 by Steve Palmer
#include <vector>
using namespace std;

//#if RS_RCPP && !R_CMD
#if RS_RCPP
#include "../Version.h"
//#endif
#endif

//#if !RS_RCPP && R_CMD
//#include "../../Batch/Version.h"
Expand Down
10 changes: 0 additions & 10 deletions Population.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,6 @@ void Population::reproduction(const float localK,const float envval,const int re
int ninds = (int)inds.size();
#if RSDEBUG
//DEBUGLOG << "Population::reproduction(): this=" << this
//#if BUTTERFLYDISP
// << " option=" << option
//#endif // BUTTERFLYDISP
//#if RS_CONTAIN
// << " hab=" << hab
//#endif // RS_CONTAIN
// << " ninds=" << ninds
// << endl;
#endif // RSDEBUG
Expand All @@ -464,12 +458,8 @@ if (dem.repType == 0) nsexes = 1; else nsexes = 2;

#if RSDEBUG
//DEBUGLOG << "Population::reproduction(): this=" << this
//#if RS_CONTAIN
// << " hab=" << hab
//#else
// << " pSpecies=" << pSpecies
// << " localK=" << localK << " envval=" << envval << " resol=" << resol
//#endif // RS_CONTAIN
// << " sstruct.nStages=" << sstruct.nStages << " nsexes=" << nsexes << " ninds=" << ninds
// << endl;
#endif
Expand Down
4 changes: 2 additions & 2 deletions RSrandom.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ Last updated: 12 January 2021 by Steve Palmer
#include <fstream>
//#include <iostream>

//#if RS_RCPP && !R_CMD
#if RS_RCPP
#include "../Version.h"
//#endif
#endif

//#if !RS_RCPP && R_CMD
//#include "../../Batch/Version.h"
Expand Down
4 changes: 2 additions & 2 deletions RandomCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
#include <fstream>
using namespace std;

//#if RS_RCPP && !R_CMD
#if RS_RCPP
#include "../Version.h"
//#endif
#endif

//#if !RS_RCPP && R_CMD
//#include "../../Batch/Version.h"
Expand Down
4 changes: 2 additions & 2 deletions Species.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ Last updated: 28 July 2021 by Greta Bocedi
#ifndef SpeciesH
#define SpeciesH

//#if RS_RCPP && !R_CMD
#if RS_RCPP
#include "../Version.h"
//#endif
#endif

//#if !RS_RCPP && R_CMD
//#include "../../Batch/Version.h"
Expand Down
4 changes: 2 additions & 2 deletions SubCommunity.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ Last updated: 26 October 2021 by Steve Palmer
#include <algorithm>
using namespace std;

//#if RS_RCPP && !R_CMD
#if RS_RCPP
#include "../Version.h"
//#endif
#endif

//#if !RS_RCPP && R_CMD
//#include "../../Batch/Version.h"
Expand Down

0 comments on commit acbbb13

Please sign in to comment.