dleutnant / swmmr

R Interface for US EPA's SWMM
https://cran.r-project.org/package=swmmr
39 stars 15 forks source link

Error executing function "run_swmm" caused by: In normalizePath(path.expand(path), winslash, mustWork) #83

Closed RonaldoAG closed 1 year ago

RonaldoAG commented 1 year ago

Running the example shown at https://github.com/dleutnant/swmmr , when starting the simulation execution using the "run_swmm" function, the following is obtained: In normalizePath(path.expand(path), winslash, mustWork) : path[1]="C:/Users/R/Documents/R/win-library/4.0/swmmr/extdata/Example1.out": The system does not can find the specified file

hsonne commented 1 year ago

Hi, @RonaldoAG, @dleutnant asked me to help him maintain this package. Since the last weeks I worked a lot on the code. I already tried to improve the error reporting. I do all changes on the dev branch of this repository. Would you like to install the package from there:

remotes::install_github("dleutnant/swmmr@dev")

and check the error messages that you receive when you try to reproduce what you were reporting about here?

Kleckers commented 1 year ago

Hi, @hsonne , we are facing the same issue as @RonaldoAG . The issue started after installing "/swmmr@dev". First, we had problems with the read_out. But this problem is solved with the new version. But now starting the simulation does not always work. The first run_swmm does not work. Second just works fine. But I don't see any real difference. Maybe this helps?

Error message: "Warnung: path[1]="[...]/Input/inpfile.out": The system does not can find the specified file"

# does not work
path <- getwd()
run_swmm(
  inp = paste(path, "/Input/inpfile.inp",
              sep = ""),
  out = paste(path, "/Input/inpfile.out",
              sep = ""),
  exec = "C:/Program Files/EPA SWMM 5.2.1 (64-bit)/runswmm.exe"
)

# works 
setwd(path)
run_swmm(
  inp = paste("Input/inpfile.inp",
              sep = ""),
  out = paste("Input/inpfile.out",
              sep = ""),
  exec = "C:/Program Files/EPA SWMM 5.2.1 (64-bit)/runswmm.exe"
)

 

dleutnant commented 1 year ago

@Kleckers What happens if you don't specify the out-argument?

path <- getwd()
run_swmm(
  inp = paste(path, "/Input/inpfile.inp",
              sep = ""),
  exec = "C:/Program Files/EPA SWMM 5.2.1 (64-bit)/runswmm.exe"
)
Kleckers commented 1 year ago

@dleutnant : Nothing changes. We still recieve the error message: "Error message: "Warnung: path[1]="[...]/Input/inpfile.out": The system does not can find the specified file"

hsonne commented 1 year ago

Hi, @Kleckers and @dleutnant!

That's interesting. I did a change and, more importantly, I added an argument debug to the run_swmm() function.

@Kleckers, would you like to

  1. install swmmr from my fix-83 branch:
    remotes::install_github("hsonne/swmmr@fix-83")
  2. restart R,
  3. run your examples again,
  4. run your examples, by additionally setting debug = TRUE in the call to run_swmm(),
  5. report about what you experienced?

By the way,

paste(path, "/Input/inpfile.inp", sep = "")

can be simplified by using paste0() (which inherently sets sep = "")

paste0(path, "/Input/inpfile.inp")

However, best would probably be to use file.path() (that sets the separator between path and file):

file.path(path, "Input/inpfile.inp")
Kleckers commented 1 year ago

Hi @hsonne, with the new branch "fix-83" the simulation runs without any error. It seems to fix the issue.

Thank you very much for the advices. Always glad to become more efficient!

hsonne commented 1 year ago

I am glad to hear that. I will then merge this branch to dev, see #109