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

Unexpected behaviour in for loop #12

Closed
thomasfrederikse opened this issue Jun 1, 2020 · 6 comments
Closed

Unexpected behaviour in for loop #12

thomasfrederikse opened this issue Jun 1, 2020 · 6 comments

Comments

@thomasfrederikse
Copy link

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
Copy link

dankelley commented Jun 1, 2020

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
Copy link
Author

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

@kouketsu
Copy link
Collaborator

kouketsu commented Jun 2, 2020

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
Copy link
Author

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

@Alexander-Barth
Copy link
Member

@kouketsu should we make a new release?

@kouketsu
Copy link
Collaborator

@Alexander-Barth yes.

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

No branches or pull requests

4 participants