Commit 05cf6052 authored by jfuser's avatar jfuser
Browse files

remove print to stderr or stdout in C++

Use Rprintf when possible
Still have issue with data(landscapeTEST)
parent 4ea0672a
^\.gitlab\-ci\.yml$
^\.git$
^README\.md$
......@@ -13,8 +13,8 @@ Author: Loup Rimbaud [aut],
Maintainer: Jean-Francois Rey <jean-francois.rey@inra.fr>
Description: A description
License: GPL (>= 2) | file LICENSE
LazyData: False
BuildVignettes: False
LazyData: TRUE
BuildVignettes: FALSE
VignetteBuilder: knitr
SystemRequirements: C++11, gsl, gdal
Depends:
......
......@@ -29,7 +29,7 @@ nYears <- 10
Cmax0 <- 2
Cmax1 <- 2
data(landscapeTEST, envir = environment())
data(landscapeTEST)
landscape <- AgriLand(landscapeTEST,filename="paysageTEST",propSR,isolSR,propRR,isolRR,strat,Nhote,nYears,Cmax0,Cmax1)
......
# landsepi R package
## build and install
```
R CMD build .
R CMD check --as-cran landsepi_*.*.*.tar.gz
R CMD INSTALL landsepi_*.*.*tar.gz
```
for development :
```
R CMD INSTALL landsepi_*.*.*.tar.gz --with-keep.source --configure-args="--enable-debug=yes"
```
#### old notes
NOTE:
The landscapes are those generated by Julien (5 landscapes of about 155 polygons).
Connectivity matrices are computed using RCALI, before running the model
......
......@@ -3,13 +3,11 @@
\docType{data}
\title{
A landscape for testing
%% ~~ data name/kind ... ~~
}
\description{
a fucking landscape for testing
%% ~~ A concise (1-5 lines) description of the dataset. ~~
}
\usage{data("landscapeTEST", envir = environment())}
\usage{data("landscapeTEST")}
\format{
The format is:
Formal class 'SpatialPolygons' [package "sp"] with 4 slots
......@@ -1213,11 +1211,11 @@ Formal class 'SpatialPolygons' [package "sp"] with 4 slots
}
\details{
some details
%% ~~ If necessary, more details than the __description__ above ~~
}
\examples{
#data(landscapeTEST)
library(sp)
library(landsepi)
data("landscapeTEST", package="landsepi")
plot(landscapeTEST)
## maybe str(landscapeTEST) ; plot(landscapeTEST) ...
}
\keyword{datasets}
......@@ -56,8 +56,8 @@ void init_aggrFormula(int Npatho, int Naggr, int *adaptation, int ********aggrTo
}
}
if (Npatho < 101)
print_i2(stdout, Npatho, 8, pathoToAggr, (const char *)"pathoToAggr");
//if (Npatho < 101)
//print_i2(stdout, Npatho, 8, pathoToAggr, (const char *)"pathoToAggr");
}
......@@ -70,7 +70,7 @@ void init_mutkernel(double **mutkernelMG, double **mutkernelQR, double taumut, i
mutkernelMG[i][i] = 1 - taumut;
mutkernelMG[i][(int) pow((i-1), 2)] = taumut;
}
print_d2(stdout, 2,2,mutkernelMG,"mutkernelMG");
//print_d2(stdout, 2,2,mutkernelMG,"mutkernelMG");
/* Mutation matrix for quantitative resistance */
for (i=0 ; i<Naggr ; i++){
......@@ -86,7 +86,7 @@ void init_mutkernel(double **mutkernelMG, double **mutkernelQR, double taumut, i
mutkernelQR[i][i-1] = taumut/2;
}
}
print_d2(stdout, Naggr,Naggr,mutkernelQR,"mutkernelQR");
//print_d2(stdout, Naggr,Naggr,mutkernelQR,"mutkernelQR");
}
......@@ -98,7 +98,7 @@ void init_infectAggr(int Naggr, double MGeff, double QReff, double costInfect, d
infect[1][0] = 1 - costInfect;
infect[0][1] = 1 - MGeff;
infect[1][1] = 1;
print_d2(stdout,2,2,infect,"infectivity matrix [2][2]");
//print_d2(stdout,2,2,infect,"infectivity matrix [2][2]");
/* Aggressiveness matrix */
double aggr0=1-QReff;
......@@ -115,7 +115,7 @@ void init_infectAggr(int Naggr, double MGeff, double QReff, double costInfect, d
aggr[i][1] = aggr0 + gain[i]*QReff;
aggr[i][0] = 1 - cost[i]*costAggr;
}
print_d2(stdout, Naggr,2,aggr,"aggressiveness matrix [aggr][2]");
//print_d2(stdout, Naggr,2,aggr,"aggressiveness matrix [aggr][2]");
free(cost);
free(gain);
......
......@@ -222,8 +222,8 @@ void bottleneck(const gsl_rng *gen, int Npoly, int Nhote, int Npatho, double pSu
} /* for poly */
} /* for hote */
} /* for patho */
if (printOn)
print_i3sum1(stdout, Npoly,Npatho,Nhote,eqIsurv,"# Bottleneck: eqIsurv (sum poly)[patho][hote]");
//if (printOn)
// print_i3sum1(stdout, Npoly,Npatho,Nhote,eqIsurv,"# Bottleneck: eqIsurv (sum poly)[patho][hote]");
}
......@@ -284,10 +284,10 @@ void host_dynamic(const gsl_rng *gen, int Nhote, int Npatho, int area, double *C
/* ---------------- */
H2H = delta[hote] * (H[hote] - H2M) * (1 - ((N[hote] - H2M + Hnewind)/(double) K[hote]));
if (H2H < 0) { /* security */
printf("CAREFUL !!!!! H2H < 0 one of the areas may be 0: check if Npoly, NpolyTot and idLAN are correct\n");
Rprintf("CAREFUL !!!!! H2H < 0 one of the areas may be 0: check if Npoly, NpolyTot and idLAN are correct\n");
H2H = 0;
} else if ((N[hote] - H2M + Hnewind + H2H) > K[hote]) {
printf("CAREFUL !!!!! H2H too big\n");
Rprintf("CAREFUL !!!!! H2H too big\n");
H2H = K[hote] - (N[hote] - H2M + Hnewind);
}
......@@ -518,7 +518,7 @@ void dynepi(const gsl_rng *gen, int nYears, int nTSpY, int Npoly, int Nhote, int
intro_I(gen, nTSpY, Npoly, Nhote, Npatho, H, I, I2R, pI0, Tspo, resistance, infect, aggr, ID_E, ID_S);
for (year = 1; year < (nYears+1); year++) {
printf("----------------------------- YEAR %d -----------------------------\n",year);
Rprintf("----------------------------- YEAR %d -----------------------------\n",year);
/* Create the files to write the output */
FILE *fH;
FILE *fHjuv;
......@@ -662,7 +662,7 @@ void modeleLandsLPI(Rcpp::List times, Rcpp::List landscape, Rcpp::List dispersio
OGRGeometry *poGeometry;
poGeometry = poFeature->GetGeometryRef();
if( poGeometry != NULL && (wkbFlatten(poGeometry->getGeometryType()) == wkbMultiPolygon || wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon)) NPoly++;
else cerr<<"WARNING unknow geometry type : "<<poGeometry->getGeometryType()<<endl;
else Rcerr<<"WARNING unknow geometry type : "<<poGeometry->getGeometryType()<<endl;
}
int ipoly=0;
......@@ -859,22 +859,22 @@ void modeleLandsLPI(Rcpp::List times, Rcpp::List landscape, Rcpp::List dispersio
FILE *fP;
fP = fopen("parameters.txt","w");
print_param(fP, seed, (char*)Rcpp::as<std::string>(nomfile_disppatho).c_str(), (char*)Rcpp::as<std::string>(nomfile_disphote).c_str(), "nomfile_habitat1", "nomfile_habitat2", nYears, nTSpY, pSurv, eff, Tlat, repro, Tspo, NPoly, NPoly, Nhote, Npatho, Naggr, C0, pI0, Cmax, delta, reproH, area, habitat, rotation, mort, strat, propRR, resistance, adaptation, MGeff, QReff, taumut, costInfect, costAggr, beta);
print_param(stdout, seed, (char*)Rcpp::as<std::string>(nomfile_disppatho).c_str(), (char*)Rcpp::as<std::string>(nomfile_disphote).c_str(), "nomfile_habitat1", "nomfile_habitat2", nYears, nTSpY, pSurv, eff, Tlat, repro, Tspo, NPoly, NPoly, Nhote, Npatho, Naggr, C0, pI0, Cmax, delta, reproH, area, habitat, rotation, mort, strat, propRR, resistance, adaptation, MGeff, QReff, taumut, costInfect, costAggr, beta);
//print_param(stdout, seed, (char*)Rcpp::as<std::string>(nomfile_disppatho).c_str(), (char*)Rcpp::as<std::string>(nomfile_disphote).c_str(), "nomfile_habitat1", "nomfile_habitat2", nYears, nTSpY, pSurv, eff, Tlat, repro, Tspo, NPoly, NPoly, Nhote, Npatho, Naggr, C0, pI0, Cmax, delta, reproH, area, habitat, rotation, mort, strat, propRR, resistance, adaptation, MGeff, QReff, taumut, costInfect, costAggr, beta);
fclose(fP);
printf("Pathogen dispersal matrix [poly][poly]\n");
Rprintf("Pathogen dispersal matrix [poly][poly]\n");
for (i=0 ; i<NPoly ; i++){
for (j=0 ; j<NPoly ; j++)
disppatho[i][j] = disppathoTot[i][j];
if (NPoly<11)
print_d1(stdout, NPoly, disppatho[i], "");
/*if (NPoly<11)
print_d1(stdout, NPoly, disppatho[i], "");*/
}
printf("Host dispersal matrix [poly][poly]\n");
Rprintf("Host dispersal matrix [poly][poly]\n");
for (i=0 ; i<NPoly ; i++){
for (j=0 ; j<NPoly ; j++)
disphote[i][j] = disphoteTot[i][j];
if (NPoly<11)
print_d1(stdout, NPoly, disphote[i],"");
/*if (NPoly<11)
print_d1(stdout, NPoly, disphote[i],""); */
}
/*-----------------------------------------*/
......@@ -901,7 +901,7 @@ void modeleLandsLPI(Rcpp::List times, Rcpp::List landscape, Rcpp::List dispersio
/* -------------- */
/* Epidemic model */
/* -------------- */
printf("\n*** SPATIOTEMPORAL MODEL SIMULATING THE SPREAD OF AN EPIDEMIC IN A LANDSCAPE ***\n\n");
Rprintf("\n*** SPATIOTEMPORAL MODEL SIMULATING THE SPREAD OF AN EPIDEMIC IN A LANDSCAPE ***\n\n");
dynepi(gen, nYears, nTSpY, NPoly, Nhote, Npatho, area, habitat, rotation, C0, pI0, pSurv, Cmax, mort, delta, reproH, disphote, disppatho, eff, Tlat, repro, Tspo, mutkernelMG, mutkernelQR, pathoToAggr, aggrToPatho, Naggr, infect, aggr, strat, resistance, adaptation, printOn);
/* ----------- */
......
......@@ -159,7 +159,7 @@ int lire(int MAX_LINE, int N_elements, char *nomfile, char *pdelim, double *y) {
fpi = fopen (nomfile, "r");
if (!fpi) {
printf("Peut pas ouvrir le fichier: %s \n",nomfile);
exit(1);
return(0);
}
/* Lecture de la 1iere ligne */
......@@ -215,7 +215,7 @@ void write_HHjuvSLIR(int Npoly, int Npatho, int Nhote, int t, int **H, int **Hju
} /* for poly */
/* Print model output on screen */
if (printOn) {
/*if (printOn) {
printf("### t = %d\n", t);
print_i2(stdout, Npoly,Npatho,S,"S [poly][patho]");
print_i2(stdout, Npoly,Nhote,H,"H [poly][hote]");
......@@ -223,7 +223,7 @@ void write_HHjuvSLIR(int Npoly, int Npatho, int Nhote, int t, int **H, int **Hju
print_i3sum1(stdout, Npoly,Npatho,Nhote,L,"L (sum poly)[patho][hote]");
print_i3sum1(stdout, Npoly,Npatho,Nhote,I,"I (sum poly)[patho][hote]");
print_i3sum1(stdout, Npoly,Npatho,Nhote,R,"R (sum poly)[patho][hote]");
}
}*/
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment