rich-iannone / splitr

Use the HYSPLIT model from inside R and do more with it
Other
141 stars 60 forks source link

Error mv: cannot stat - Error in file(con, "r") #27

Closed nicrie closed 5 years ago

nicrie commented 5 years ago

Running the example given in the description

setwd("~/HYSPLIT/ArabianSea")

library(SplitR)
library(magrittr)

trajectory <- 
  hysplit_trajectory(
    lat = 42.83752,
    lon = -80.30364,
    height = 50,
    duration = 24,
    run_period = "2012-03-12",
    daily_hours = c(0, 6, 12, 18),
    direction = "forward",
    met_type = "gdas1",
    extended_met = TRUE)

throws the following error (after having successfully downloaded the data sets which were saved in the working directory):

mv: cannot stat 'traj--fwd-12-03-12-00-1lat_42p83752_lon_-80p30364-hgt_50-24h': No such file or directory
mv: cannot stat 'traj--fwd-12-03-12-06-1lat_42p83752_lon_-80p30364-hgt_50-24h': No such file or directory
mv: cannot stat 'traj--fwd-12-03-12-12-1lat_42p83752_lon_-80p30364-hgt_50-24h': No such file or directory
mv: cannot stat 'traj--fwd-12-03-12-18-1lat_42p83752_lon_-80p30364-hgt_50-24h': No such file or directory
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: In system(paste0("(cd ", exec_dir, " && ", binary_path, " >> /dev/null 2>&1)")) :
  error in running command
2: In system(paste0("(cd ", exec_dir, " && ", binary_path, " >> /dev/null 2>&1)")) :
  error in running command
3: In system(paste0("(cd ", exec_dir, " && ", binary_path, " >> /dev/null 2>&1)")) :
  error in running command
4: In system(paste0("(cd ", exec_dir, " && ", binary_path, " >> /dev/null 2>&1)")) :
  error in running command
5: In file(con, "r") :
  cannot open file '/home/nrieger/HYSPLIT/ArabianSea/traj-2018-11-19-16-52-41/NA': No such file or directory

Can me someone give me a hint what I am missing? This seems to be a local problem on my machine though. I am using Linux 18.04 with RStudio (with R version 3.5.1) in Anaconda.

jobonaf commented 5 years ago

Hi. Maybe HYSPLIT didn't run. Has your OS been correctly detected?

get_os <- function() {
  if (.Platform$OS.type == "windows") { 
    "win"
  } else if (Sys.info()["sysname"] == "Darwin") {
    "mac" 
  } else if (.Platform$OS.type == "unix") { 
    "unix"
  } else {
    stop("Unknown OS")
  }
}
get_os()

If the result is unix, then check if the file hyts_std is in the right place and if it's executable

 file.access(system.file("linux-amd64/hyts_std",package = "SplitR"),1)==0

Moreover, check whether a 64-bit architecture is present

.Machine$sizeof.pointer == 8
nicrie commented 5 years ago

Thank you very much for your help! Though I still couldn't find the error. I checked your ideas but everything seems to work correctly:

get_os <- function() {
  if (.Platform$OS.type == "windows") { 
    "win"
  } else if (Sys.info()["sysname"] == "Darwin") {
    "mac" 
  } else if (.Platform$OS.type == "unix") { 
    "unix"
  } else {
    stop("Unknown OS")
  }
}
get_os()

throws "unix".

If the result is unix, then check if the file hyts_std is in the right place and if it's executable

 file.access(system.file("linux-amd64/hyts_std",package = "SplitR"),1)==0

"TRUE" Moreover, check whether a 64-bit architecture is present

.Machine$sizeof.pointer == 8

"TRUE"

It's even more confusing as I just put on a fresh installation of Ubuntu (and therefore Anaconda/RStudio).

Since the error message states that there is a problem with moving files in/out a directory which does not exist: Could it be due to overlong file/directory names? I don't know if SplitR is internally calling HYSPLIT GUI which complained about too long directory names on my machine (seems to be a known bug as others reported it too).

jobonaf commented 5 years ago
nicrie commented 5 years ago
* check from the shell if the Hysplit output files are there
ls -l /home/nrieger/HYSPLIT/ArabianSea/*

Output


-rw-r--r-- 1 nrieger nrieger       269 nov.  23 01:12 /home/nrieger/HYSPLIT/ArabianSea/ASCDATA.CFG
-rw-r--r-- 1 nrieger nrieger       389 nov.  23 01:24 /home/nrieger/HYSPLIT/ArabianSea/CONTROL
-rw-r--r-- 1 nrieger nrieger 598888640 nov.  23 01:15 /home/nrieger/HYSPLIT/ArabianSea/gdas1.mar12.w1
-rw-r--r-- 1 nrieger nrieger 598888640 nov.  23 01:18 /home/nrieger/HYSPLIT/ArabianSea/gdas1.mar12.w2
-rw-r--r-- 1 nrieger nrieger 598888640 nov.  23 01:20 /home/nrieger/HYSPLIT/ArabianSea/gdas1.mar12.w3
-rw-r--r-- 1 nrieger nrieger 598888640 nov.  23 01:23 /home/nrieger/HYSPLIT/ArabianSea/gdas1.mar12.w4
-rw-r--r-- 1 nrieger nrieger 256666560 nov.  23 01:24 /home/nrieger/HYSPLIT/ArabianSea/gdas1.mar12.w5
-rw-r--r-- 1 nrieger nrieger       100 nov.  23 01:24 /home/nrieger/HYSPLIT/ArabianSea/met_file_list
-rw-r--r-- 1 nrieger nrieger       661 nov.  23 01:12 /home/nrieger/HYSPLIT/ArabianSea/SETUP.CFG

/home/nrieger/HYSPLIT/ArabianSea/datasets: total 352936 -rw-r--r-- 1 nrieger nrieger 54 nov. 22 22:27 met_file_list -rw-r--r-- 1 nrieger nrieger 123110672 nov. 22 22:26 RP199912.gbl -rw-r--r-- 1 nrieger nrieger 123110672 nov. 22 22:26 RP200001.gbl -rw-r--r-- 1 nrieger nrieger 115168048 nov. 22 22:27 RP200002.gbl

/home/nrieger/HYSPLIT/ArabianSea/storage: total 0

/home/nrieger/HYSPLIT/ArabianSea/traj-2018-11-23-01-12-39: total 0

/home/nrieger/HYSPLIT/ArabianSea/working: total 0


The additional datasets `RP******.gbl` were downloaded in another test run I did earlier.

>     * check the file `MESSAGE`
> 
> 
> ```
> less /home/nrieger/HYSPLIT/ArabianSea/MESSAGE
> ```

The `MESSAGE` file, however, does not exist!?
jobonaf commented 5 years ago

uhm, no output (traj--*), no log (MESSAGE) from Hysplit... try to execute it and please paste the standard output/error

binary_path <- system.file("linux-amd64/hyts_std",package = "SplitR")
setwd("/home/nrieger/HYSPLIT/ArabianSea/")
system(binary_path)
nicrie commented 5 years ago

Output

/home/nrieger/anaconda3/envs/rstudio/lib/R/library/SplitR/linux-amd64/hyts_std: error while loading shared libraries: libgfortran.so.3: cannot open shared object file: No such file or directory
Warning message:
In system(binary_path) : error in running command

Indeed, only libgfortran.so.4 was available in my libraries. Just installed additionally .so.3 alongside via

sudo apt-get install libgfortran3

Now it works like a charm - thanks a lot @jobonaf :+1: