TEOS-10 / GSW-R

R implementation of the Thermodynamic Equation Of Seawater - 2010 (TEOS-10)
http://teos-10.github.io/GSW-R/
Other
8 stars 5 forks source link

test whether gsw_SAAR segfaults sometimes #26

Closed dankelley closed 7 years ago

dankelley commented 7 years ago

In a discussion of the Python (and C) versions -- see https://github.com/TEOS-10/GSW-C/pull/2#issuecomment-284603324 -- it is seen that gsw_saar() can segfault sometimes in the C version.

I wanted to test this in the R version. It seems not to be a problem, with the develop branch commit f25c9b76eadfa6427358ee47407c3b224155c85b. (But note: I have not decided whether to call this gsw_saar() or gsw_SAAR(). At the moment it is the latter, but I reserve the "right" to change it in the next few days.)

> library(gsw)
> str(gsw_SAAR(1000, -30, 5))
List of 2
 $ saar   : num 0.000133
 $ inocean: int 1
> str(gsw_SAAR(1000, 60, 40))
List of 2
 $ saar   : num 0
 $ inocean: int 1
dankelley commented 7 years ago

Oh, the in_ocean part looks very simple (https://github.com/TEOS-10/GSW-Matlab/blob/master/Toolbox/library/gsw_SAAR.m#L230). Thanks, @PaulMBarker, for putting the source code into GH.

dankelley commented 7 years ago

I'm closing this because it does not segfault. (I won't bother raising an issue on the fact that the R function gsw_SAAR only makes a reasonable guess on in_ocean, because that problem is documented in the docs for the function. I suppose a full solution awaits coding of this in_ocean part in Fortran and then in C ... stages that are beyond my present purview.