gadget-framework / gadget2

Gadget is the Globally applicable Area Disaggregated General Ecosystem Toolbox
GNU General Public License v2.0
18 stars 20 forks source link

gadget.fit with "spawning" stocks #20

Closed niafall closed 7 years ago

niafall commented 7 years ago

I've been unable to run gadget.fit with stocks where doesspawn was specified instead of doesrenew. Perhaps it is an issue with a newer version of gadget (I'm running a version downloaded on 29th of May with updated stomachcontent.cc file), R or one of the packages?

The error:

Joining, by = c(".id", "length")
Joining, by = c("year", "area", "fleet")
Joining, by = c("year", "area")
Error in mutate_impl(.data, dots) : object 'area' not found
In addition: Warning messages:
1: In file(con, "r") : cannot open file '0': No such file or directory
2: In file(con, "r") : cannot open file '0': No such file or directory

Session info:

R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
 [4] LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] grid      parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] gridExtra_2.2.1   pander_0.6.0      Rgadget_0.5       purrr_0.2.2       stringr_1.2.0    
 [6] lubridate_1.6.0   data.table_1.10.4 dplyr_0.5.0       reshape2_1.4.2    plyr_1.8.4       
[11] ggplot2_2.2.1    

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.10     digest_0.6.12    assertthat_0.2.0 R6_2.2.0         gtable_0.2.0     DBI_0.6-1       
 [7] magrittr_1.5     scales_0.4.1     stringi_1.1.5    lazyeval_0.2.0   tools_3.4.0      munsell_0.4.3   
[13] compiler_3.4.0   colorspace_1.3-2 tibble_1.3.0
pfrater commented 7 years ago

I was having this problem earlier this spring, but should have fixed the problem with this commit. Could you debug down a little further and see which function is causing the mutate_impl error?

niafall commented 7 years ago

Hi @pfrater , have you any suggestions for debugging this particular issue? Apologies, I am new to that side of things in R.

pfrater commented 7 years ago

No worries. What I usually do is run something like debug(gadget.fit). This will step you through the function line by line (or section by section). You can use this to sort of drill down and see where the error is coming from. Often times there is a small error in another one of the functions that is used inside gadget.fit. Then, when you find which function the error is coming from you can debug that function.

A couple of pointers: once you enter debug(gadget.fit) it will debug it every time you run gadget.fit until you call undebug(gadget.fit). For this reason I like to run debugonce(gadget.fit), which will only run the debug function once. You may have to do this several times to pinpoint where the error is, and then you an debug the function that is thowing it. Sometimes you have to drill down several levels. Without this process it is difficult to tell what is causing your error.

niafall commented 7 years ago

I'll look into this.

niafall commented 7 years ago

@pfrater ;

The best I can narrow it down, the error occurs when the res.by.year object is being created (line 160 of the gadget.fit function). I stepped into this llply call, and the error occurs at line 19:

(result <- withVisible(eval(quote(_fseq(_lhs)), env, env)))

As I said, this is only happening with models which spawn rather than renew.

Is this any help?

pfrater commented 7 years ago

@niafall

Is this any help?

Maybe. In WGTS/out.fit, check your prey and full files and compare them to a version that was working previously (i.e. one with renewal) just to make sure everything is okay there.

Otherwise you may just have to send me your model so I can check it out. If that's okay.

niafall commented 7 years ago

I cannot see a difference in the prey and/or full files in WGTS/out.fit.

What would be the best way for me to forward you the model?

pfrater commented 7 years ago

Apologies for not noticing earlier. This issue should have been posted to the Rgadget github site. Please see this commit for a solution to this problem.