Skip to content

Commit

Permalink
update aswpb internal functions
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcaceres committed Oct 27, 2024
1 parent e41e51d commit d7058cf
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 24 deletions.
4 changes: 2 additions & 2 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ aspwbInput <- function(crop_factor, control, soil) {
.Call(`_medfate_aspwbInput`, crop_factor, control, soil)
}

.aspwb_day_inner <- function(internalCommunication, x, meteovec, elevation, slope, aspect, runon = 0.0, lateralFlows = NULL, waterTableDepth = NA_real_, verbose = FALSE) {
.Call(`_medfate_aspwb_day_inner`, internalCommunication, x, meteovec, elevation, slope, aspect, runon, lateralFlows, waterTableDepth, verbose)
.aspwb_day_inner <- function(internalCommunication, x, date, meteovec, latitude, elevation, slope = NA_real_, aspect = NA_real_, runon = 0.0, lateralFlows = NULL, waterTableDepth = NA_real_, modifyInput = TRUE) {
.Call(`_medfate_aspwb_day_inner`, internalCommunication, x, date, meteovec, latitude, elevation, slope, aspect, runon, lateralFlows, waterTableDepth, modifyInput)
}

#' @rdname aspwb
Expand Down
8 changes: 4 additions & 4 deletions inst/include/medfate_RcppExports.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ namespace medfate {
return Rcpp::as<List >(rcpp_result_gen);
}

inline List _aspwb_day_inner(List internalCommunication, List x, NumericVector meteovec, double elevation, double slope, double aspect, double runon = 0.0, Nullable<NumericVector> lateralFlows = R_NilValue, double waterTableDepth = NA_REAL, bool verbose = false) {
typedef SEXP(*Ptr__aspwb_day_inner)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP);
inline List _aspwb_day_inner(List internalCommunication, List x, CharacterVector date, NumericVector meteovec, double latitude, double elevation, double slope = NA_REAL, double aspect = NA_REAL, double runon = 0.0, Nullable<NumericVector> lateralFlows = R_NilValue, double waterTableDepth = NA_REAL, bool modifyInput = true) {
typedef SEXP(*Ptr__aspwb_day_inner)(SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP,SEXP);
static Ptr__aspwb_day_inner p__aspwb_day_inner = NULL;
if (p__aspwb_day_inner == NULL) {
validateSignature("List(*_aspwb_day_inner)(List,List,NumericVector,double,double,double,double,Nullable<NumericVector>,double,bool)");
validateSignature("List(*_aspwb_day_inner)(List,List,CharacterVector,NumericVector,double,double,double,double,double,Nullable<NumericVector>,double,bool)");
p__aspwb_day_inner = (Ptr__aspwb_day_inner)R_GetCCallable("medfate", "_medfate__aspwb_day_inner");
}
RObject rcpp_result_gen;
{
RNGScope RCPP_rngScope_gen;
rcpp_result_gen = p__aspwb_day_inner(Shield<SEXP>(Rcpp::wrap(internalCommunication)), Shield<SEXP>(Rcpp::wrap(x)), Shield<SEXP>(Rcpp::wrap(meteovec)), Shield<SEXP>(Rcpp::wrap(elevation)), Shield<SEXP>(Rcpp::wrap(slope)), Shield<SEXP>(Rcpp::wrap(aspect)), Shield<SEXP>(Rcpp::wrap(runon)), Shield<SEXP>(Rcpp::wrap(lateralFlows)), Shield<SEXP>(Rcpp::wrap(waterTableDepth)), Shield<SEXP>(Rcpp::wrap(verbose)));
rcpp_result_gen = p__aspwb_day_inner(Shield<SEXP>(Rcpp::wrap(internalCommunication)), Shield<SEXP>(Rcpp::wrap(x)), Shield<SEXP>(Rcpp::wrap(date)), Shield<SEXP>(Rcpp::wrap(meteovec)), Shield<SEXP>(Rcpp::wrap(latitude)), Shield<SEXP>(Rcpp::wrap(elevation)), Shield<SEXP>(Rcpp::wrap(slope)), Shield<SEXP>(Rcpp::wrap(aspect)), Shield<SEXP>(Rcpp::wrap(runon)), Shield<SEXP>(Rcpp::wrap(lateralFlows)), Shield<SEXP>(Rcpp::wrap(waterTableDepth)), Shield<SEXP>(Rcpp::wrap(modifyInput)));
}
if (rcpp_result_gen.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
Expand Down
18 changes: 10 additions & 8 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,31 @@ RcppExport SEXP _medfate_aspwbInput(SEXP crop_factorSEXP, SEXP controlSEXP, SEXP
return rcpp_result_gen;
}
// aspwb_day_inner
List aspwb_day_inner(List internalCommunication, List x, NumericVector meteovec, double elevation, double slope, double aspect, double runon, Nullable<NumericVector> lateralFlows, double waterTableDepth, bool verbose);
static SEXP _medfate_aspwb_day_inner_try(SEXP internalCommunicationSEXP, SEXP xSEXP, SEXP meteovecSEXP, SEXP elevationSEXP, SEXP slopeSEXP, SEXP aspectSEXP, SEXP runonSEXP, SEXP lateralFlowsSEXP, SEXP waterTableDepthSEXP, SEXP verboseSEXP) {
List aspwb_day_inner(List internalCommunication, List x, CharacterVector date, NumericVector meteovec, double latitude, double elevation, double slope, double aspect, double runon, Nullable<NumericVector> lateralFlows, double waterTableDepth, bool modifyInput);
static SEXP _medfate_aspwb_day_inner_try(SEXP internalCommunicationSEXP, SEXP xSEXP, SEXP dateSEXP, SEXP meteovecSEXP, SEXP latitudeSEXP, SEXP elevationSEXP, SEXP slopeSEXP, SEXP aspectSEXP, SEXP runonSEXP, SEXP lateralFlowsSEXP, SEXP waterTableDepthSEXP, SEXP modifyInputSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< List >::type internalCommunication(internalCommunicationSEXP);
Rcpp::traits::input_parameter< List >::type x(xSEXP);
Rcpp::traits::input_parameter< CharacterVector >::type date(dateSEXP);
Rcpp::traits::input_parameter< NumericVector >::type meteovec(meteovecSEXP);
Rcpp::traits::input_parameter< double >::type latitude(latitudeSEXP);
Rcpp::traits::input_parameter< double >::type elevation(elevationSEXP);
Rcpp::traits::input_parameter< double >::type slope(slopeSEXP);
Rcpp::traits::input_parameter< double >::type aspect(aspectSEXP);
Rcpp::traits::input_parameter< double >::type runon(runonSEXP);
Rcpp::traits::input_parameter< Nullable<NumericVector> >::type lateralFlows(lateralFlowsSEXP);
Rcpp::traits::input_parameter< double >::type waterTableDepth(waterTableDepthSEXP);
Rcpp::traits::input_parameter< bool >::type verbose(verboseSEXP);
rcpp_result_gen = Rcpp::wrap(aspwb_day_inner(internalCommunication, x, meteovec, elevation, slope, aspect, runon, lateralFlows, waterTableDepth, verbose));
Rcpp::traits::input_parameter< bool >::type modifyInput(modifyInputSEXP);
rcpp_result_gen = Rcpp::wrap(aspwb_day_inner(internalCommunication, x, date, meteovec, latitude, elevation, slope, aspect, runon, lateralFlows, waterTableDepth, modifyInput));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _medfate_aspwb_day_inner(SEXP internalCommunicationSEXP, SEXP xSEXP, SEXP meteovecSEXP, SEXP elevationSEXP, SEXP slopeSEXP, SEXP aspectSEXP, SEXP runonSEXP, SEXP lateralFlowsSEXP, SEXP waterTableDepthSEXP, SEXP verboseSEXP) {
RcppExport SEXP _medfate_aspwb_day_inner(SEXP internalCommunicationSEXP, SEXP xSEXP, SEXP dateSEXP, SEXP meteovecSEXP, SEXP latitudeSEXP, SEXP elevationSEXP, SEXP slopeSEXP, SEXP aspectSEXP, SEXP runonSEXP, SEXP lateralFlowsSEXP, SEXP waterTableDepthSEXP, SEXP modifyInputSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_medfate_aspwb_day_inner_try(internalCommunicationSEXP, xSEXP, meteovecSEXP, elevationSEXP, slopeSEXP, aspectSEXP, runonSEXP, lateralFlowsSEXP, waterTableDepthSEXP, verboseSEXP));
rcpp_result_gen = PROTECT(_medfate_aspwb_day_inner_try(internalCommunicationSEXP, xSEXP, dateSEXP, meteovecSEXP, latitudeSEXP, elevationSEXP, slopeSEXP, aspectSEXP, runonSEXP, lateralFlowsSEXP, waterTableDepthSEXP, modifyInputSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
Expand Down Expand Up @@ -5834,7 +5836,7 @@ static int _medfate_RcppExport_validate(const char* sig) {
static std::set<std::string> signatures;
if (signatures.empty()) {
signatures.insert("List(*aspwbInput)(double,List,DataFrame)");
signatures.insert("List(*.aspwb_day_inner)(List,List,NumericVector,double,double,double,double,Nullable<NumericVector>,double,bool)");
signatures.insert("List(*.aspwb_day_inner)(List,List,CharacterVector,NumericVector,double,double,double,double,double,Nullable<NumericVector>,double,bool)");
signatures.insert("List(*aspwb_day)(List,CharacterVector,NumericVector,double,double,double,double,double,Nullable<NumericVector>,double,bool)");
signatures.insert("List(*.defineASPWBDailyOutput)(double,double,double,double,CharacterVector,List)");
signatures.insert("void(*.fillASPWBDailyOutput)(List,List,List,int)");
Expand Down Expand Up @@ -5977,7 +5979,7 @@ RcppExport SEXP _medfate_RcppExport_registerCCallable() {

static const R_CallMethodDef CallEntries[] = {
{"_medfate_aspwbInput", (DL_FUNC) &_medfate_aspwbInput, 3},
{"_medfate_aspwb_day_inner", (DL_FUNC) &_medfate_aspwb_day_inner, 10},
{"_medfate_aspwb_day_inner", (DL_FUNC) &_medfate_aspwb_day_inner, 12},
{"_medfate_aspwb_day", (DL_FUNC) &_medfate_aspwb_day, 11},
{"_medfate_defineASPWBDailyOutput", (DL_FUNC) &_medfate_defineASPWBDailyOutput, 6},
{"_medfate_fillASPWBDailyOutput", (DL_FUNC) &_medfate_fillASPWBDailyOutput, 4},
Expand Down
32 changes: 22 additions & 10 deletions src/aspwb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ List aspwbInput(double crop_factor, List control, DataFrame soil) {
return(input);
}

// [[Rcpp::export(".aspwb_day_inner")]]
List aspwb_day_inner(List internalCommunication, List x, NumericVector meteovec,
List aspwb_day_private(List internalCommunication, List x, NumericVector meteovec,
double elevation, double slope, double aspect,
double runon = 0.0, Nullable<NumericVector> lateralFlows = R_NilValue, double waterTableDepth = NA_REAL,
bool verbose = false) {
Expand Down Expand Up @@ -168,10 +167,8 @@ List aspwb_day_inner(List internalCommunication, List x, NumericVector meteovec,
return(l);
}

//' @rdname aspwb
//' @keywords internal
// [[Rcpp::export("aspwb_day")]]
List aspwb_day(List x, CharacterVector date, NumericVector meteovec,
// [[Rcpp::export(".aspwb_day_inner")]]
List aspwb_day_inner(List internalCommunication, List x, CharacterVector date, NumericVector meteovec,
double latitude, double elevation, double slope = NA_REAL, double aspect = NA_REAL,
double runon = 0.0, Nullable<NumericVector> lateralFlows = R_NilValue, double waterTableDepth = NA_REAL,
bool modifyInput = true) {
Expand Down Expand Up @@ -217,13 +214,28 @@ List aspwb_day(List x, CharacterVector date, NumericVector meteovec,
Named("rad") = rad,
Named("pet") = pet,
Named("rint") = Rint);

return(aspwb_day_private(internalCommunication, x, meteovec_inner,
elevation, slope, aspect,
runon, lateralFlows, waterTableDepth,
verbose));
}

//' @rdname aspwb
//' @keywords internal
// [[Rcpp::export("aspwb_day")]]
List aspwb_day(List x, CharacterVector date, NumericVector meteovec,
double latitude, double elevation, double slope = NA_REAL, double aspect = NA_REAL,
double runon = 0.0, Nullable<NumericVector> lateralFlows = R_NilValue, double waterTableDepth = NA_REAL,
bool modifyInput = true) {

DataFrame soil = Rcpp::as<Rcpp::DataFrame>(x["soil"]);
List internalCommunication = List::create(_["SWBcommunication"] = communicationSoilWaterBalance(soil.nrow()));
return(aspwb_day_inner(internalCommunication, x, meteovec_inner,
elevation, slope, aspect,

return(aspwb_day_inner(internalCommunication, x, date, meteovec,
latitude, elevation, slope, aspect,
runon, lateralFlows, waterTableDepth,
verbose));
modifyInput));
}


Expand Down Expand Up @@ -606,7 +618,7 @@ List aspwb(List x, DataFrame meteo, double latitude,
Named("pet") = PET[i],
Named("rint") = Rint);
try{
s = aspwb_day_inner(internalCommunication, x, meteovec,
s = aspwb_day_private(internalCommunication, x, meteovec,
elevation, slope, aspect,
0.0, R_NilValue, waterTableDepth,
verbose);
Expand Down

0 comments on commit d7058cf

Please sign in to comment.