diff --git a/src/SW_R_lib.c b/src/SW_R_lib.c index 1ead6875..32b06cc4 100644 --- a/src/SW_R_lib.c +++ b/src/SW_R_lib.c @@ -992,13 +992,14 @@ SEXP sw_consts(void) { "eFirst", "eNCIn", "eNCInAtt", "eNCOutVars", "eDomain", - "eModel", "eLog", + "eModel", "eSite", "eLayers", "eSWRCp", "eWeather", "eMarkovProb", "eMarkovCov", "eSky", "eVegProd", "eVegEstab", "eCarbon", "eSoilwat", - "eOutput", "eOutputDaily", "eOutputWeekly", "eOutputMonthly", "eOutputYearly", + "eOutput", "eLog", + "eOutputDaily", "eOutputWeekly", "eOutputMonthly", "eOutputYearly", "eOutputDaily_soil", "eOutputWeekly_soil", "eOutputMonthly_soil", "eOutputYearly_soil" }; diff --git a/src/rSW_Domain.c b/src/rSW_Domain.c index 112a5126..7b2e80d5 100644 --- a/src/rSW_Domain.c +++ b/src/rSW_Domain.c @@ -42,11 +42,6 @@ -/* =================================================== */ -/* Local Variables */ -/* --------------------------------------------------- */ -static char *MyFileName; - /* =================================================== */ /* Global Function Definitions */ /* --------------------------------------------------- */ @@ -252,16 +247,14 @@ void onSet_SW_MDL(SEXP SW_MDL, LOG_INFO* LogInfo) { TimeInt d; char enddyval[6], errstr[MAX_ERROR]; - MyFileName = SoilWatDomain.SW_PathInputs.txtInFiles[eModel]; - if (!IS_S4_OBJECT(SW_MDL)) { - LogError(LogInfo, LOGERROR, "%s: No input.", MyFileName); + LogError(LogInfo, LOGERROR, "modelrun.in: missing input."); return; // Exit function prematurely due to error } PROTECT(StartYear = GET_SLOT(SW_MDL, install("StartYear"))); if (INTEGER(StartYear)[0] < 0) { - LogError(LogInfo, LOGERROR, "%s: Negative start year (%d)", MyFileName, INTEGER(StartYear)[0]); + LogError(LogInfo, LOGERROR, "Negative start year (%d)", INTEGER(StartYear)[0]); UNPROTECT(1); return; // Exit function prematurely due to error @@ -269,20 +262,20 @@ void onSet_SW_MDL(SEXP SW_MDL, LOG_INFO* LogInfo) { m->startyr = INTEGER(StartYear)[0]; PROTECT(EndYear = GET_SLOT(SW_MDL, install("EndYear"))); if (isNull(EndYear) || INTEGER(EndYear)[0] == NA_INTEGER) { - LogError(LogInfo, LOGERROR, "%s: Ending year not found.", MyFileName); + LogError(LogInfo, LOGERROR, "Ending year not found."); UNPROTECT(2); return; // Exit function prematurely due to error } if (INTEGER(EndYear)[0] < 0) { - LogError(LogInfo, LOGERROR, "%s: Negative ending year (%d)", MyFileName, INTEGER(EndYear)[0]); + LogError(LogInfo, LOGERROR, "Negative ending year (%d)", INTEGER(EndYear)[0]); UNPROTECT(2); return; // Exit function prematurely due to error } m->endyr = INTEGER(EndYear)[0]; if (m->endyr < m->startyr) { - LogError(LogInfo, LOGERROR, "%s: Start Year > End Year", MyFileName); + LogError(LogInfo, LOGERROR, "Start Year > End Year"); UNPROTECT(2); return; // Exit function prematurely due to error @@ -303,7 +296,7 @@ void onSet_SW_MDL(SEXP SW_MDL, LOG_INFO* LogInfo) { fhemi = TRUE; if (!(fstartdy && fenddy && fhemi)) { - snprintf(errstr, MAX_ERROR, "\nNot found in %s:\n", MyFileName); + snprintf(errstr, MAX_ERROR, "\nNot found in inputs:\n"); if (!fstartdy) { strcat(errstr, "\tStart Day - using 1\n"); m->startstart = 1; diff --git a/src/rSW_Files.c b/src/rSW_Files.c index 237c0195..ea7b6019 100644 --- a/src/rSW_Files.c +++ b/src/rSW_Files.c @@ -89,7 +89,9 @@ void onSet_SW_F(SEXP SW_F_construct, LOG_INFO* LogInfo) { free(SoilWatDomain.SW_PathInputs.txtInFiles[i]); } for (i = 0; i < j; i++) { - SoilWatDomain.SW_PathInputs.txtInFiles[i] = Str_Dup(CHAR(STRING_ELT(FilesIn,i)), LogInfo); + // txtInFiles is unused if values set by rSOILWAT2 + // SoilWatDomain.SW_PathInputs.txtInFiles[i] = Str_Dup(CHAR(STRING_ELT(FilesIn,i)), LogInfo); + SoilWatDomain.SW_PathInputs.txtInFiles[i] = NULL; if(LogInfo->stopRun) { UNPROTECT(2); // Unprotect the two protected variables before exiting return; // Exit function prematurely diff --git a/src/rSW_Output.c b/src/rSW_Output.c index 102f026a..c4605dc8 100644 --- a/src/rSW_Output.c +++ b/src/rSW_Output.c @@ -40,12 +40,6 @@ -/* =================================================== */ -/* Module-Level Variables */ -/* --------------------------------------------------- */ -static char *MyFileName; - - /* =================================================== */ /* Global Function Definitions */ /* --------------------------------------------------- */ @@ -69,7 +63,6 @@ void onSet_SW_OUT(SEXP OUT, LOG_INFO* LogInfo) { #ifdef RSWDEBUG if (debug) sw_printf("onSet_SW_OUT: start ..."); #endif - MyFileName = SoilWatDomain.SW_PathInputs.txtInFiles[eOutput]; PROTECT(sep = GET_SLOT(OUT, install("outputSeparator"))); diff --git a/src/rSW_Site.c b/src/rSW_Site.c index 8b2587b6..f6c0d97d 100644 --- a/src/rSW_Site.c +++ b/src/rSW_Site.c @@ -42,9 +42,6 @@ /* Local Variables */ /* --------------------------------------------------- */ -static char *MyFileName; - - static char *cSW_SIT[] = { "SWClimits", "ModelFlags", "ModelCoefficients", "SnowSimulationParameters", "DrainageCoefficient", "EvaporationCoefficients", @@ -126,9 +123,6 @@ static void onSet_SW_LYR(SEXP SW_LYR, LOG_INFO* LogInfo) { soildensity, imperm, soiltemp, f_gravel, som_frac; double *p_Layers; - /* note that Files.read() must be called prior to this. */ - MyFileName = SoilWatDomain.SW_PathInputs.txtInFiles[eLayers]; - j = nrows(SW_LYR); p_Layers = REAL(SW_LYR); columns = ncols(SW_LYR); @@ -139,8 +133,8 @@ static void onSet_SW_LYR(SEXP SW_LYR, LOG_INFO* LogInfo) { LogError( LogInfo, LOGERROR, - "%s : Too few columns in layers specified (%d).\n", - MyFileName, columns + "soils.in : Too few columns in layers specified (%d).\n", + columns ); return; // Exit function prematurely due to error } @@ -181,9 +175,9 @@ static void onSet_SW_LYR(SEXP SW_LYR, LOG_INFO* LogInfo) { LogError( LogInfo, LOGERROR, - "%s : Too many layers specified (%d).\n" + "soils.in : Too many layers specified (%d).\n" "Maximum number of layers is %d\n", - MyFileName, lyrno + 1, MAX_LAYERS + lyrno + 1, MAX_LAYERS ); return; // Exit function prematurely due to error } @@ -258,16 +252,13 @@ static void onSet_SW_SWRCp(SEXP SW_SWRCp, LOG_INFO* LogInfo) { int i, k; double *p_SWRCp; - /* note that Files.read() must be called prior to this. */ - MyFileName = SoilWatDomain.SW_PathInputs.txtInFiles[eSWRCp]; - /* Check that we have n = `SWRC_PARAM_NMAX` values per layer */ if (ncols(SW_SWRCp) != SWRC_PARAM_NMAX) { LogError( LogInfo, LOGERROR, - "%s : Bad number of SWRC parameters %d -- must be %d.\n", - MyFileName, ncols(SW_SWRCp), SWRC_PARAM_NMAX + "swrcp.in : Bad number of SWRC parameters %d -- must be %d.\n", + ncols(SW_SWRCp), SWRC_PARAM_NMAX ); return; // Exit function prematurely due to error } @@ -277,9 +268,9 @@ static void onSet_SW_SWRCp(SEXP SW_SWRCp, LOG_INFO* LogInfo) { LogError( LogInfo, LOGERROR, - "%s : Number of layers with SWRC parameters (%d) " + "swrcp.in : Number of layers with SWRC parameters (%d) " "must match number of soil layers (%d)\n", - MyFileName, nrows(SW_SWRCp), SoilWatRun.Site.n_layers + nrows(SW_SWRCp), SoilWatRun.Site.n_layers ); return; // Exit function prematurely due to error } @@ -400,8 +391,6 @@ SEXP onGet_SW_SIT(void) { char *cTranspirationRegions[] = { "ndx", "layer" }; int *p_transp; // ideally `LyrIndex` so that same type as `_TranspRgnBounds`, but R API INTEGER() is signed - MyFileName = SoilWatDomain.SW_PathInputs.txtInFiles[eSite]; - PROTECT(swSite = MAKE_CLASS("swSite")); PROTECT(SW_SIT = NEW_OBJECT(swSite)); @@ -579,8 +568,6 @@ void onSet_SW_SIT(SEXP SW_SIT, LOG_INFO* LogInfo) { int debug = 0; #endif - MyFileName = SoilWatDomain.SW_PathInputs.txtInFiles[eSite]; - #ifdef RSWDEBUG if (debug) sw_printf("'onSet_SW_SIT':"); #endif diff --git a/src/rSW_Sky.c b/src/rSW_Sky.c index 983d6df7..b0c7d059 100644 --- a/src/rSW_Sky.c +++ b/src/rSW_Sky.c @@ -32,12 +32,6 @@ #include -/* =================================================== */ -/* Local Variables */ -/* --------------------------------------------------- */ -static char *MyFileName; - - /* =================================================== */ /* Global Function Definitions */ /* --------------------------------------------------- */ @@ -94,8 +88,6 @@ void onSet_SW_SKY(SEXP sxp_SW_SKY) { PROTECT(sxp_SW_SKY); p_Cloud = REAL(GET_SLOT(sxp_SW_SKY, install("Cloud"))); - MyFileName = SoilWatDomain.SW_PathInputs.txtInFiles[eSky]; - for (i = 0; i < 12; i++) { //i=columns v->cloudcov[i] = p_Cloud[0 + k * i]; v->windspeed[i] = p_Cloud[1 + k * i]; diff --git a/src/rSW_SoilWater.c b/src/rSW_SoilWater.c index d2b015d5..909210ac 100644 --- a/src/rSW_SoilWater.c +++ b/src/rSW_SoilWater.c @@ -43,7 +43,6 @@ /* =================================================== */ /* Local Variables */ /* --------------------------------------------------- */ -static char *MyFileName; static int swcdataIndex; @@ -102,7 +101,6 @@ void onSet_SW_SWC(SEXP SWC, LOG_INFO* LogInfo) { SEXP swcFirstYear; SEXP swcMethod; - MyFileName = SoilWatDomain.SW_PathInputs.txtInFiles[eSoilwat]; LyrIndex i; ForEachSoilLayer(i, SoilWatRun.Site.n_layers) v->avgLyrTemp[i] = SoilWatRun.Site.soils.avgLyrTempInit[i]; diff --git a/src/rSW_VegProd.c b/src/rSW_VegProd.c index 0a3fd770..693fcacd 100644 --- a/src/rSW_VegProd.c +++ b/src/rSW_VegProd.c @@ -40,9 +40,6 @@ vegetation production parameter information. /* =================================================== */ /* Local Variables */ /* --------------------------------------------------- */ -static char *MyFileName; - - static char *cVegProd_names[] = { "veg_method", "Composition", "Albedo", "CanopyHeight", "VegetationInterceptionParameters", "LitterInterceptionParameters", @@ -439,8 +436,6 @@ void onSet_SW_VPD(SEXP SW_VPD, LOG_INFO* LogInfo) { SEXP CO2Coefficients; double *p_Grasslands, *p_Shrublands, *p_Forest, *p_Forb; - MyFileName = SoilWatDomain.SW_PathInputs.txtInFiles[eVegProd]; - PROTECT(veg_method = GET_SLOT(SW_VPD, install(cVegProd_names[0]))); v->veg_method = INTEGER(veg_method)[0]; diff --git a/src/rSW_Weather.c b/src/rSW_Weather.c index afe179e6..859adcb5 100644 --- a/src/rSW_Weather.c +++ b/src/rSW_Weather.c @@ -39,7 +39,6 @@ /* =================================================== */ /* Local Variables */ /* --------------------------------------------------- */ -static char *MyFileName; static char *cSW_WTH_names[] = { "MonthlyScalingParams", @@ -220,7 +219,6 @@ void onSet_SW_WTH_setup(SEXP SW_WTH, LOG_INFO* LogInfo) { double *p_MonthlyValues; int *p_dailyInputFlags; - MyFileName = SoilWatDomain.SW_PathInputs.txtInFiles[eWeather]; // Copy weather prefix from PathInfo to Weather within `SoilWatRun` strcpy(SoilWatRun.Weather.name_prefix, SoilWatDomain.SW_PathInputs.txtWeatherPrefix); @@ -286,10 +284,10 @@ void onSet_SW_WTH_setup(SEXP SW_WTH, LOG_INFO* LogInfo) { LogError( logfp, LOGERROR, - "%s : Model year (%d) starts before weather files (%d)" + "Model year (%d) starts before weather files (%d)" " and weather generator turned off.\n" " Please synchronize the years or set up the weather generator files", - MyFileName, SW_Model.startyr, w->startYear + SW_Model.startyr, w->startYear ); } */