Simplified test code:
using GibbsSeaWater
# julia> i=79; (SP[i], P[i], Lon[i], Lat[i])
# (34.05199699401855, 10.0, 377.5, -62.5)
# gsw_sa_from_sp(34.0, 10.0, 377.5, -62.5)
gsw_saar(10.0, 377.5, -62.5)
https://github.com/TEOS-10/GSW-C/blob/13ab33cea0e9059d3b3f3dfef78e9591c94af9f8/gsw_saar.c#L33-L42
Is 377.5 a legal longitude?
julia> Lon[61:82]
22-element Vector{Float64}:
359.5
360.5
361.5
362.5
363.5
364.5
365.5
366.5
367.5
368.5
369.5
370.5
371.5
372.5
373.5
374.5
375.5
376.5
377.5
378.5
379.5
20.5
Next you can compile GSW-C in debug mode, then call gsw_saar with the same arguments and debug with gdb to find out which line is wrong.
https://github.com/TEOS-10/GSW-C/blob/13ab33cea0e9059d3b3f3dfef78e9591c94af9f8/gsw_saar.c#L69-L70
Breakpoint 6, gsw_saar (p=10, lon=377.5, lat=-62.5) at gsw_saar.c:69
69 indx0 = floor(0 + (nx-1)*(lon-longs_ref[0])/(longs_ref[nx-1]-
70 longs_ref[0]));
(gdb) p nx
$13 = 91
(gdb) p lon
$14 = 377.5
(gdb) p longs_ref[0]
$15 = 0
(gdb) p longs_ref[nx - 1]
$16 = 360
When lon > 360, indx0 > (nx-1), which then causes the array (longs_ref[indx0]) to go out of bounds.
I can reproduce the error in WSL (Ubuntu 20.04.3 LTS).
julia> SA = gsw_sa_from_sp.(SP, P, Lon, Lat);
signal (11): Segmentation fault
in expression starting at REPL[10]:1
gsw_saar at /home/woclass/.julia/packages/GibbsSeaWater/vq3GE/deps/usr/lib/libgswteos-10.so (unknown line)
gsw_sa_from_sp at /home/woclass/.julia/packages/GibbsSeaWater/vq3GE/deps/usr/lib/libgswteos-10.so (unknown line)
gsw_sa_from_sp at /home/woclass/.julia/packages/GibbsSeaWater/vq3GE/src/gen_gswteos10.jl:534 [inlined]
On Windows, everything works fine.
win REPL
julia> SA
201-element Vector{Float64}:
33.978850980733235
34.112732625974715
34.20779818246909
34.26127607610699
34.29615007324156
34.29711167161423
34.28884564139484
34.318206662266995
34.32395340273992
34.33207869075504
34.345693213139945
34.36708801832739
34.374648814324125
⋮
33.96205590976534
33.957670222578585
33.948449301367084
33.937740328020595
33.93005643268858
33.92895873943964
33.93384238282935
33.93726330942629
33.93330105293442
33.92392157797163
33.91456389969976
33.908278813955846
(@v1.7) pkg> st
Status `C:\Users\woclass\.julia\environments\v1.7\Project.toml`
[6e4b80f9] BenchmarkTools v1.2.2
[31a5f54b] Debugger v0.6.8
[9a22fb26] GibbsSeaWater v0.1.1
[23992714] MAT v0.10.2
julia> versioninfo()
Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, skylake)