Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
r2ogs6
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ogs
OpenGeoSys Tools
r2ogs6
Commits
3eb8dad6
Commit
3eb8dad6
authored
4 years ago
by
Ruben Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
[base] added overwrite flag to ogs6_run_sim and ogs6_export_sim_files
parent
3e796243
No related branches found
No related tags found
1 merge request
!15
Resolve "Add overwrite flag to run_simulation function"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/sim_utils.R
+13
-8
13 additions, 8 deletions
R/sim_utils.R
with
13 additions
and
8 deletions
R/sim_utils.R
+
13
−
8
View file @
3eb8dad6
...
...
@@ -11,15 +11,18 @@
#' directory will be created in \code{ogs6$sim_path} directory
#' @param ogs6_bin_path string: Optional: OpenGeoSys 6 bin folder path. Defaults
#' to \code{options("r2ogs6.default_ogs6_bin_path")}
#' @param overwrite flag: Should existing files be overwritten?
#' @param verbose flag
#' @export
ogs6_run_simulation
<-
function
(
ogs6_obj
,
write_logfile
=
TRUE
,
ogs6_bin_path
,
overwrite
=
T
,
verbose
=
F
)
{
# Export (and / or copy referenced) simulation files
ogs6_export_sim_files
(
ogs6_obj
=
ogs6_obj
,
overwrite
=
overwrite
,
test_mode
=
FALSE
)
exit_code
<-
ogs6_call_ogs6
(
ogs6_obj
=
ogs6_obj
,
...
...
@@ -40,10 +43,12 @@ ogs6_run_simulation <- function(ogs6_obj,
#' @description Creates \code{ogs6$sim_path} directory if it does not exist yet
#' and exports and / or copies all simulation files to it.
#' @param ogs6_obj OGS6: Simulation object
#' @param overwrite flag: Should existing files be overwritten?
#' @param test_mode flag: If \code{TRUE}, Will not check status of
#' \code{ogs6_obj} before exporting files. Defaults to \code{FALSE}
#' @export
ogs6_export_sim_files
<-
function
(
ogs6_obj
,
overwrite
=
T
,
test_mode
=
FALSE
){
assertthat
::
assert_that
(
inherits
(
ogs6_obj
,
"OGS6"
))
...
...
@@ -60,13 +65,8 @@ ogs6_export_sim_files <- function(ogs6_obj,
if
(
!
dir.exists
(
ogs6_obj
$
sim_path
))
{
dir.create
(
ogs6_obj
$
sim_path
)
}
else
{
if
(
length
(
list.files
(
ogs6_obj
$
sim_path
))
!=
0
)
{
warning
(
paste0
(
"sim_path directory '"
,
ogs6_obj
$
sim_path
,
"' is not empty. Files may be overwritten."
),
call.
=
FALSE
)
if
(
!
overwrite
){
assertthat
::
assert_that
(
length
(
list.files
(
ogs6_obj
$
sim_path
))
==
0
)
}
}
...
...
@@ -160,9 +160,14 @@ ogs6_call_ogs6 <- function(ogs6_obj,
if
(
!
dir.exists
(
logfile_dir
)){
dir.create
(
logfile_dir
)
}
else
{
# If old logfile exists, delete it
if
(
file.exists
(
ogs6_obj
$
logfile
)){
file.remove
(
ogs6_obj
$
logfile
)
}
}
assertthat
::
assert_that
(
!
file.exists
(
ogs6_obj
$
logfile
))
# (Re)create
logfile
file.create
(
ogs6_obj
$
logfile
)
if
(
verbose
){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment