TEOS-10 / GibbsSeaWater.jl

Gibbs-SeaWater (GSW) Oceanographic Toolbox in Julia
http://www.teos-10.org
Other
23 stars 3 forks source link

Unexpected behaviour in for loop #12

Closed thomasfrederikse closed 4 years ago

thomasfrederikse commented 4 years ago

I got some unexpected outcomes while running GSW-julia inside a for loop. If I run the same GSW function with the same input arguments consecutively, the results change between iterations.

A minimal working example that produces the unexpected behaviour:

for i in 1:10
   println(gsw_p_from_z(-780.0,32.0))
end

I expected that on every line the right answer 786.9634207624217 would be printed, but I get as output:

786.9634207624217 786.9634207624217 1821.1936700582019 1821.1990180813314 1821.1990181089222 1821.1990181089227 1821.1990181089227 1821.1990181089227 1821.1990181089227 1821.1990181089227

I'm using GibbsSeaWater.jl version 0.10.0 on Julia 1.4.1. This behavior is not limited to 'gsw_p_from_z', but occurs in other functions as well.

dankelley commented 4 years ago

In case it's of any help, the first number is the same as what I get in R, viz.

> library(gsw)
> options(digits=16)
> for (i in 1:10)
+    print(gsw_p_from_z(-780.0,32.0))
[1] 786.9634207624217
[1] 786.9634207624217
[1] 786.9634207624217
[1] 786.9634207624217
[1] 786.9634207624217
[1] 786.9634207624217
[1] 786.9634207624217
[1] 786.9634207624217
[1] 786.9634207624217
[1] 786.9634207624217
thomasfrederikse commented 4 years ago

Yes, the output you show is what I'd expect in Julia as well.

kouketsu commented 4 years ago

Thanks @thomasfrederikse and @dankelley. I think the wrapper script "gen_gswteos10.jl" was old and did not work well with GSW-C#95a9cae. So I updated it (and add wrapper functions for "gsw_p_from_z").

Please try master branch (through pkg>update GibbsSeaWater#master).

thomasfrederikse commented 4 years ago

Thanks @kouketsu! Just updated the code, and now I get the correct results. Again, thanks for the quick fix!

Alexander-Barth commented 4 years ago

@kouketsu should we make a new release?

kouketsu commented 4 years ago

@Alexander-Barth yes.