Skip to content

R program that interfaces with the STEPWAT2 C code and runs in parallel for multiple sites, climate scenarios, disturbance regimes, and time periods

Notifications You must be signed in to change notification settings

MartinHoldrege/rSFSTEP2

 
 

Repository files navigation

rSFSTEP2

Cloning the repository:

git clone --branch master https://github.com/DrylandEcology/rSFSTEP2.git

Instructions for running rSFSTEP2

Required R packages for rSFSTEP2: DBI, RSQLite, rSOILWAT2, rSW2utils, doParallel, synchronicity

On a super computer:

  1. Make sure all the scripts are executable (i.e. given executable permissions) prior to following the steps below: chmod +x nameoffile
  2. Copy the weather database to the inputs folder within rSFSTEP2.
  3. Set the location of the weather database in the Main.R script of the R_program folder (where it says set database location), along with the name of the weather database (where it says Provide the name of the database in quotes).
  4. In Main.R, set the proc_count based on the number of CPUs on each node of the super computer.
  5. Edit the default climate scenarios you wish to run, specified in climate.conditions. The number of GCMs listed here must match <number_of_scenarios> below in the call to generate_rSFSTEP2_structure.sh (RCPs and time periods are not counted). For example - if you have 10 GCMs for 2 RCPs and "Current" in climate.conditions, the correct <number_of_scenarios> = 11 in the generate_rSFSTEP2_structure.sh call.
  6. Ensure that the weather database variables listed in Main.R match those in the weather database you are using. This includes: climate.conditions, simstartyr, endyr, climate.ambient, deltaFutureToSimStart_yr, downscaling.method, and YEARS.
  7. Add site ids, you wish to run the wrapper on, to the siteid variable (third line from top) in the generate_rSFSTEP2_structure.sh script. Site 1 and 2 are present as examples.
  8. Edit jobname, accountname and the location of results.txt (last line) in the sample.sh script, located in the R_program folder. Adjust wall time and nodes/cpus required if necessary.
  9. Edit jobname and accountname in the outputdatabase.sh script, located in R_program folder.
  10. Run the cloneSTEPWAT2.sh script.
  11. Run the generate_rSFSTEP2_structure.sh script. The parameters are <R_program> <number_of_sites> <number_of_scenarios>
  12. Run the call_sbatch.sh script. The parameter is <number_of_sites>.

Once the sbatch tasks have been succesfully completed, follow the steps below to compile all output.csv files into a SQLite database:

  1. Reset the number of GCMs used in OutputDatabase.R if not 14.
  2. Run the call_sbatch_database.sh script.
  3. Once the data is compiled into a SQLite database (for individual sites), edit the number of sites (variable site) and location (variable path) where you wish to collect the data, in the copydata.sh script.
  4. Run the copydata.sh script to copy the SQLite databases from each folder into a master folder.

On a local machine:

  1. Make sure all the scripts are executable (i.e. given executable permissions) prior to following the steps below: chmod +x nameoffile
  2. Copy the weather database to the inputs folder within rSFSTEP2.
  3. Set the location of the weather database in the Main.R script of the R_program folder (where it says set database location), along with the name of the weather database (where it says Provide the name of the database in quotes).
  4. In Main.R, set the proc_count based on the number of cores on the computer.
  5. Edit the default climate scenarios you wish to run, specified in climate.conditions. The number of GCMs listed here must match <number_of_scenarios> below in the call to generate_rSFSTEP2_structure.sh (RCPs and time periods are not counted). For example - if you have 10 GCMs for 2 RCPs and "Current" in climate.conditions, the correct <number_of_scenarios> = 11 in the generate_rSFSTEP2_structure.sh call.
  6. Ensure that the weather database variables listed in Main.R match those in the weather database you are using. This includes: climate.conditions, simstartyr, endyr, climate.ambient, deltaFutureToSimStart_yr, downscaling.method, and YEARS.
  7. Add site ids, you wish to run the wrapper on, to the siteid variable (third line from top) in the generate_rSFSTEP2_structure.sh script. Site 1 and 2 are present as examples.
  8. Run the cloneSTEPWAT2.sh script.
  9. Run the generate_rSFSTEP2_structure.sh script. The parameters are <R_program> <number_of_sites> <number_of_scenarios>
  10. Run the run_local.sh script. The parameter is <number_of_sites>.

Once the sbatch tasks have been succesfully completed, follow the steps below to compile all output.csv files into a SQLite database:

  1. Reset the number of GCMs used in OutputDatabase.R if not 14.
  2. Run the run_local_database.sh script.
  3. Once the data is compiled into a SQLite database (for individual sites), edit the number of sites (variable site) and location (variable path) where you wish to collect the data, in the copydata.sh script.
  4. Run the copydata.sh script to copy the SQLite databases from each folder into a master folder.

Note: The method to run a shell script is present as a comment in the respective script.

Comparing generated files

rSFSTEP2 has the options to scale phenological activity, biomass, litter, and % live fractions along with space based on site-specific current or future climate. After running the simulation you can generate statistics and graphics demonstrating how the input files were modified.

On a local computer:

./compare_files.sh <number of sites>

On a supercomputer:

./compare_sbatch.sh <number of sites>

The results will be stored in rSFSTEP2/R_program_??/STEPWAT_DIST/output/ where ?? is the site number.

Note: repository renamed from StepWat_R_Wrapper_parallel to rSFSTEP2 on Feb 23, 2017

All existing information should automatically be redirected to the new name.

Contributors are encouraged, however, to update local clones to point to the new URL, i.e.,

git remote set-url origin https://github.com/Burke-Lauenroth-Lab/rSFSTEP2.git

All instructions and necessary parameters for running shell scripts are at the top of each file

See syntax_inputs.txt in the inputs folder for a description of the input options and how to specify site-specific and fixed inputs

About

R program that interfaces with the STEPWAT2 C code and runs in parallel for multiple sites, climate scenarios, disturbance regimes, and time periods

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • R 95.0%
  • Shell 3.8%
  • Python 1.2%