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

Using gsw_nsquared #45

Closed
mukund-gupta opened this issue Dec 22, 2020 · 2 comments
Closed

Using gsw_nsquared #45

mukund-gupta opened this issue Dec 22, 2020 · 2 comments

Comments

@mukund-gupta
Copy link

Hello, I am trying to use gsw_nsquared as follows:

using GibbsSeaWater

# Constants
g = 9.81
Nz = 64
Δz = 2.5
Lz = Δz*Nz
z = -((Δz/2):Δz:(Lz-Δz/2))
Stop = 34.1 
Sbot = 34.7
Ttop = -0.5
Tbot = 0
ztop = -40
zbot = -Lz
dSdz = (Sbot - Stop)/(zbot - ztop)
dTdz = (Tbot - Ttop)/(zbot - ztop)

# Profiles
S = Stop .+ dSdz*(z .< ztop).*(z .- ztop)
T = Ttop .+ dTdz*(z .< ztop).*(z .- ztop)
Pres = -rho_O*g*z*1e-4
N2 = float(Nz-1)
Pmid = float(Nz-1)
a = gsw_nsquared.(S, T, Pres, 0, Nz, N2, Pmid)

But get the following error:

 ERROR: LoadError: MethodError: no method matching unsafe_convert(::Type{Ptr{Float64}}, ::Float64)
Closest candidates are:
  unsafe_convert(::Type{T}, ::T) where T<:Ptr at essentials.jl:391
  unsafe_convert(::Type{Ptr{T}}, ::Ptr{Tuple{Vararg{T,N}}}) where {N, T} at refpointer.jl:136
  unsafe_convert(::Type{P}, ::Ptr) where P<:Ptr at essentials.jl:392
  ...
Stacktrace:
 [1] gsw_nsquared(::Float64, ::Float64, ::Float64, ::Int64, ::Int64, ::Float64, ::Float64) at /Users/guptam/.julia/packages/GibbsSeaWater/vq3GE/src/gen_gswteos10.jl:370
 [2] _broadcast_getindex_evalf at ./broadcast.jl:648 [inlined]
 [3] _broadcast_getindex at ./broadcast.jl:621 [inlined]
 [4] getindex at ./broadcast.jl:575 [inlined]
 [5] copy at ./broadcast.jl:876 [inlined]
 [6] materialize(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(gsw_nsquared),Tuple{Array{Float64,1},Array{Float64,1},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Int64,Int64,Float64,Float64}}) at ./broadcast.jl:837
 [7] top-level scope at compare_nsquared.jl:137
 [8] include(::String) at ./client.jl:457
 [9] top-level scope at REPL[14]:1
in expression starting at compare_nsquared.jl:137

Could you advise how I should use gsw_nsquared instead?
Many thanks.

@ocefpaf
Copy link
Member

ocefpaf commented Dec 22, 2020

@mukund-gupta looks like you are using the Julia version of GSW, not the R one. If that is correct you should close this issue and open it at https://github.com/TEOS-10/GibbsSeaWater.jl/issues.

@mukund-gupta
Copy link
Author

Yes, you are right! Sorry about that

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

2 participants