runCRHM | R Documentation |
Runs CRHM with a specified .prj
file and (optionally) .obs
file(s)
and .par
file(s). Under OSX and Linux, CRHM requires either 1) the program Wine
to
run CRHM.exe
or 2) a native-compiled version. This function will use Wine
if it is
indicated (the executable file has the extension .exe
), and the parameter useWine
=
TRUE
.
runCRHM(
CRHMfile = "",
prjFile = "",
obsFiles = "",
parFiles = "",
outFile = "",
logfile = "",
useWine = FALSE
)
CRHMfile |
Required. CRHM executable file (i.e. |
prjFile |
Required. Name of |
obsFiles |
Optional. Name(s) of obs file(s). |
parFiles |
Optional. Name(s) of parameter file(s). |
outFile |
Optional. Name(s) of output file(s). If not specified, the original CRHM output file name (e.g. CRHM_output_1.txt) is kept. |
logfile |
Optional. Name of the file to be used for logging the action. Normally not used. |
useWine |
Optional. If |
Running a CRHM model requires that the .prj file has been setup to run autmatically,
as shown in the function automatePrj
.
If Wine
is required, the function will copy the specified .obs, and .par files to
the directory of the .prj file, before execution of CRHM. After the program has finished, the copies
will be deleted.
If the CRHM executable file is not located on the system path, and is not found in the specified directory, then an error message will be returned.
If successful, returns TRUE
. If unsuccessful, returns FALSE
.
Kevin Shook
automatePrj
## Not run:
# Automate the .prj before use
automatePrj("c:/BadLake/BadLake1975.prj")
# Using specified paths - in this case the .obs files reference in
# the .prj must contain the file path.
# It's a good idea to use absolute paths for the .prj and .obs files.
# If you use relative paths, they have to be w.r.t. the CRHM executable file.
setPrjObs("c:/BadLake/BadLake1975.prj", obsFiles = "c:/BadLake/Badlake73_76.obs")
result <- runCRHM("c:/CRHM/CRHM.exe", "c:/BadLake/BadLake1975.prj",
outfile = "c:/BadLake/BadLake1975Output.txt")
# Omitting paths - all files are stored in the current directory.
# Remove paths from the reference to the .obs files in the .prj file
setPrjObs("c:/BadLake/BadLake1975.prj", obsFiles = "Badlake73_76.obs")
# Set the working directory to the one holding the model files.
setwd("c:/BadLake")
# Execute the model.
result <- runCRHM("c:/CRHM/CRHM.exe", "BadLake1975.prj",
outfile = "BadLake1975Output.txt")
# If CRHM is on the system path you can run it without specifying the location.
# This command will show the current path:
Sys.getenv("PATH")
# Execute the model without specifying the path to CRHM.
result <- runCRHM("CRHM.exe", "BadLake1975.prj",
outfile = "BadLake1975Output.txt")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.