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

Using gsw_nsquared #45

Closed mukund-gupta closed 3 years ago

mukund-gupta commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

Yes, you are right! Sorry about that