DrylandEcology / rSFSTEP2

R program that interfaces with the STEPWAT2 C code and runs in parallel for multiple sites, climate scenarios, disturbance regimes, and time periods
0 stars 1 forks source link

Update grepl statements to ensure an exact condition is met (i.e. site ID), rather than contains this site ID #245

Closed kpalmqui closed 3 years ago

kpalmqui commented 3 years ago

This is a bug where the current grepl statements in Main.R fail when executing a fixed input treatment (soils, species, rgroup) for multiple sites (i.e. 1, 11). The problem only occurs when one site ID in contained within another (i.e. 1 is contained within 11). As a result, site 1 is run for all sites that contain a 1 in their ID (i.e. 1, 11, 111), rather than the site-specific conditions meant for site 1. Therefore, extra output is generated that is not needed.

Solution, ensure an exact site ID match is found:

site2=paste("\<",site,"\>",sep='') if(grepl(site2,j))

This has been updated for all input files (species, soils, rgroup) where one can specify fixed inputs for a string of sites.

kpalmqui commented 3 years ago

Resolved by f36089b