Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue using hysplit_trajectory on Linux: missing return in SETUP.CFG #40

Closed
ajblomberg opened this issue Sep 25, 2019 · 2 comments
Closed

Comments

@ajblomberg
Copy link

Hello, and thanks for the great package.

I'm using splitr on a linux platform. When I use the hysplit_trajectory function, I get a blank tibble.

> library(splitr)
> packageVersion("splitr")
[1] ‘0.4.0.9000’
> 
> setwd("/n/scratchlfs/koutrakis_lab/H")
> trajectory <- hysplit_trajectory(lat = 42,
+                                  lon = -80,
+                                  height = 50,
+                                  duration = 24,
+                                  days = "2001-03-12",
+                                  daily_hours = c(0),
+                                  direction = "backward",
+                                  met_type = "narr",
+                                  extended_met = FALSE,
+                                  exec_dir = "/n/scratchlfs/koutrakis_lab/H",
+                                  met_dir = "/n/scratchlfs/koutrakis_lab/H")
> trajectory
# A tibble: 0 x 12
# … with 12 variables: run <int>, receptor <int>, hour_along <int>, traj_dt <dttm>, lat <dbl>,
#   lon <dbl>, height <dbl>, traj_dt_i <dttm>, lat_i <dbl>, lon_i <dbl>, height_i <dbl>,
#   pressure <dbl>

Using the SETUP.CFG file and CONTROL file created by hysplit_trajectory gives the following error:

[ajm806@boslogin04 H]$ /n/home00/ajm806/apps/R/splitr/linux-amd64/hyts_std
 HYSPLIT4 - Initialization
 Last Changed Rev: 742
 Last Changed Date: 2015-04-02 08:54:24 -0400 (Thu, 02 Apr 2015)

At line 345 of file ../source/hymodelt.F (unit = 75, file = 'SETUP.CFG')
Fortran runtime error: End of file

After some troubleshooting, it appears that the SETUP.CFG file needs a return at the end of the file to work (at least in linux). The following code fixed the problem:

> # New function to add line at end of SETUP.CFG file
> write_config_list <- function (config_list, dir) {
+   paste0("&SETUP\n", 
+          paste0(names(config_list)," = ", config_list, ",\n",
+                 collapse = ""),
+          "/\n") %>% 
+     cat(file = file.path(dir, "SETUP.CFG"))
+   print("use new config write function")
+ }
> 
> assignInNamespace("write_config_list", write_config_list, ns="splitr")
> 
> #' Run hysplit_trajectory
> trajectory <- hysplit_trajectory(lat = 42,
+                                  lon = -80,
+                                  height = 50,
+                                  duration = 24,
+                                  days = "2001-03-12",
+                                  daily_hours = c(0),
+                                  direction = "backward",
+                                  met_type = "narr",
+                                  extended_met = FALSE,
+                                  exec_dir = "/n/scratchlfs/koutrakis_lab/H",
+                                  met_dir = "/n/scratchlfs/koutrakis_lab/H")
[1] "use new config write function"
> trajectory
# A tibble: 25 x 12
     run receptor hour_along traj_dt               lat   lon height traj_dt_i           lat_i lon_i
   <int>    <int>      <int> <dttm>              <dbl> <dbl>  <dbl> <dttm>              <dbl> <dbl>
 1     1        1          0 2001-03-12 00:00:00  42   -80     50   2001-03-12 00:00:00    42   -80
 2     1        1         -1 2001-03-11 23:00:00  42.1 -80.1   33.8 2001-03-12 00:00:00    42   -80
 3     1        1         -2 2001-03-11 22:00:00  42.2 -80.3   20.4 2001-03-12 00:00:00    42   -80
 4     1        1         -3 2001-03-11 21:00:00  42.3 -80.4   12.8 2001-03-12 00:00:00    42   -80
@rich-iannone
Copy link
Owner

Thanks so much for reporting this issue and for all of the troubleshooting work! I will fix this in master shortly.

@rich-iannone
Copy link
Owner

@ajblomberg This should now be fixed. Please let me know if this is still a problem. Closing this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants